Fix docker implementation
This commit is contained in:
parent
1f8a95b4da
commit
eca89ea9b4
|
@ -65,7 +65,7 @@ Once you've installed dependencies for frontend and backend, you can run `./buil
|
||||||
##### BACKEND API RUBY TESTING
|
##### BACKEND API RUBY TESTING
|
||||||
|
|
||||||
1. Go to tests folder: `cd opensupports/tests`
|
1. Go to tests folder: `cd opensupports/tests`
|
||||||
2. Run `make install` to install ruby and its the required dependencies
|
2. Run `make build` to install ruby container and its required dependencies
|
||||||
|
|
||||||
- `make run` for running tests (database will be cleared)
|
- `make run` for running tests (database will be cleared)
|
||||||
- `make clear` for clearing database
|
- `make clear` for clearing database
|
||||||
|
|
|
@ -7,10 +7,6 @@ RUN apt-get update && \
|
||||||
(curl -s https://getcomposer.org/installer | php) && \
|
(curl -s https://getcomposer.org/installer | php) && \
|
||||||
mv composer.phar /usr/local/bin/composer
|
mv composer.phar /usr/local/bin/composer
|
||||||
|
|
||||||
RUN echo 'LISTEN 8080' >> /etc/apache2/apache2.conf
|
|
||||||
RUN sed -i "1s/.*/<VirtualHost *:8080>/" /etc/apache2/sites-enabled/000-default.conf
|
|
||||||
RUN sed -i "5s/.*/Listen 8080/" /etc/apache2/ports.conf
|
|
||||||
|
|
||||||
# ENVIRONMENT VARIABLES
|
# ENVIRONMENT VARIABLES
|
||||||
ENV MYSQL_HOST 127.0.0.1
|
ENV MYSQL_HOST opensupports-db
|
||||||
ENV MYSQL_PORT 4040
|
ENV MYSQL_PORT 3306
|
||||||
|
|
|
@ -9,14 +9,15 @@ build:
|
||||||
@docker build -t opensupports-srv . || echo "A${red}An error occurred${reset}"
|
@docker build -t opensupports-srv . || echo "A${red}An error occurred${reset}"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
@docker network create os-net || true
|
||||||
@docker exec -it opensupports-srv bash -c "cd /var/www/html && composer install" || echo "${red}Please execute 'make run' first${reset}"
|
@docker exec -it opensupports-srv bash -c "cd /var/www/html && composer install" || echo "${red}Please execute 'make run' first${reset}"
|
||||||
@docker exec -it opensupports-db bash -c "mysql -u root -e \"CREATE DATABASE IF NOT EXISTS development;\" " || echo "${red}Please execute 'make run' first${reset}"
|
@docker exec -it opensupports-db bash -c "mysql -u root -e \"CREATE DATABASE IF NOT EXISTS development;\" " || echo "${red}Please execute 'make run' first${reset}"
|
||||||
|
|
||||||
run:
|
run: stop
|
||||||
@docker run -d --name opensupports-db -p 4040:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -v $(PWD)/.dbdata/:/var/lib/mysql mysql:5.6
|
@docker run -d --network os-net --name opensupports-db -p 4040:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -v $(PWD)/.dbdata/:/var/lib/mysql mysql:5.6
|
||||||
@docker run -d --name opensupports-myadmin --link opensupports-db:db -p 6060:80 phpmyadmin/phpmyadmin
|
@docker run -d --network os-net --name opensupports-myadmin --link opensupports-db:db -p 6060:80 phpmyadmin/phpmyadmin
|
||||||
@docker run -d --name opensupports-fakesmtp -p 7070:25 -v ${PWD}/.fakemail/:/var/mail munkyboy/fakesmtp
|
@docker run -d --network os-net --name opensupports-fakesmtp -p 7070:25 -v ${PWD}/.fakemail/:/var/mail munkyboy/fakesmtp
|
||||||
@docker run -d --name opensupports-srv --net=host --rm -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug -v ${PWD}:/var/www/html opensupports-srv
|
@docker run -d --network os-net --name opensupports-srv -p 8080:80 --link opensupports-db:mysql --rm -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug -v ${PWD}:/var/www/html opensupports-srv
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@./run-tests.sh
|
@./run-tests.sh
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt update
|
||||||
|
RUN apt install build-essential openssl curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison --yes
|
||||||
|
RUN apt install mysql-client --yes
|
||||||
|
RUN apt install ruby-full --yes
|
||||||
|
RUN apt install libmysqlclient-dev ruby-dev --yes
|
||||||
|
RUN gem install bundler
|
||||||
|
|
||||||
|
COPY Gemfile /app
|
||||||
|
RUN bundle install
|
|
@ -1,5 +1,5 @@
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
gem 'mysql'
|
gem 'mysql2'
|
||||||
gem 'bacon'
|
gem 'bacon'
|
||||||
gem 'mechanize'
|
gem 'mechanize'
|
||||||
gem 'mailfactory'
|
gem 'mailfactory'
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
DB_HOST ?= `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' opensupports-db`
|
DB_HOST ?= `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' opensupports-db`
|
||||||
|
|
||||||
install:
|
build:
|
||||||
@apt-get install ruby-full
|
@docker build -t opensupports-tests .
|
||||||
@apt-get install libmysqlclient-dev ruby-dev
|
|
||||||
@gem install bundler
|
|
||||||
@bundle install
|
|
||||||
|
|
||||||
run: export MYSQL_HOST=127.0.0.1
|
|
||||||
run: export MYSQL_PORT=4040
|
|
||||||
run:
|
run:
|
||||||
|
@docker run -it --network os-net -v ${PWD}:/app -v ${PWD}/../server:/server opensupports-tests make test
|
||||||
|
|
||||||
|
clear:
|
||||||
|
@docker run -it --network os-net -v ${PWD}:/app -v ${PWD}/../server:/server opensupports-tests make truncate-db
|
||||||
|
|
||||||
|
test: export MYSQL_HOST=opensupports-db
|
||||||
|
test: export MYSQL_PORT=3306
|
||||||
|
test: export API_URL=http://opensupports-srv
|
||||||
|
test:
|
||||||
./run-tests.sh
|
./run-tests.sh
|
||||||
|
|
||||||
|
|
||||||
clear: export MYSQL_HOST=127.0.0.1
|
truncate-db: export MYSQL_HOST=opensupports-db
|
||||||
clear: export MYSQL_PORT=4040
|
truncate-db: export MYSQL_PORT=3306
|
||||||
clear:
|
truncate-db:
|
||||||
./clean_db.sh && \
|
./truncate_db.sh && \
|
||||||
./clean_db.sh && \
|
./truncate_db.sh && \
|
||||||
./clean_db.sh
|
./truncate_db.sh
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe 'Article path' do
|
||||||
row = $database.getRow('topic', 'Private Topic', 'name')
|
row = $database.getRow('topic', 'Private Topic', 'name')
|
||||||
|
|
||||||
result['status'].should.equal('success')
|
result['status'].should.equal('success')
|
||||||
(row['private']).should.equal('1')
|
(row['private']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should create article' do
|
it 'should create article' do
|
||||||
|
@ -41,8 +41,8 @@ describe 'Article path' do
|
||||||
article = $database.getRow('article', @article_id)
|
article = $database.getRow('article', @article_id)
|
||||||
(article['title']).should.equal('Some article')
|
(article['title']).should.equal('Some article')
|
||||||
(article['content']).should.equal('This is an article about server management.')
|
(article['content']).should.equal('This is an article about server management.')
|
||||||
(article['topic_id']).should.equal(@topic_id.to_s)
|
(article['topic_id']).should.equal(@topic_id)
|
||||||
(article['position']).should.equal('1')
|
(article['position']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('ADD_ARTICLE')
|
(lastLog['type']).should.equal('ADD_ARTICLE')
|
||||||
|
@ -60,8 +60,8 @@ describe 'Article path' do
|
||||||
article = $database.getRow('article', @article_id)
|
article = $database.getRow('article', @article_id)
|
||||||
(article['title']).should.equal('Some article')
|
(article['title']).should.equal('Some article')
|
||||||
(article['content']).should.equal('This is an article about server management2.')
|
(article['content']).should.equal('This is an article about server management2.')
|
||||||
(article['topic_id']).should.equal(@topic_id.to_s)
|
(article['topic_id']).should.equal(@topic_id)
|
||||||
(article['position']).should.equal('1')
|
(article['position']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('EDIT_ARTICLE')
|
(lastLog['type']).should.equal('EDIT_ARTICLE')
|
||||||
|
@ -87,8 +87,8 @@ describe 'Article path' do
|
||||||
article = $database.getRow('article', @article_id)
|
article = $database.getRow('article', @article_id)
|
||||||
(article['title']).should.equal('Some article')
|
(article['title']).should.equal('Some article')
|
||||||
(article['content']).should.equal('This is an article about server management2.')
|
(article['content']).should.equal('This is an article about server management2.')
|
||||||
(article['topic_id']).should.equal((@topic_id+1).to_s)
|
(article['topic_id']).should.equal((@topic_id+1))
|
||||||
(article['position']).should.equal('1')
|
(article['position']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should delete article' do
|
it 'should delete article' do
|
||||||
|
@ -157,6 +157,5 @@ describe 'Article path' do
|
||||||
(result['data'][1]['icon']).should.equal('photo')
|
(result['data'][1]['icon']).should.equal('photo')
|
||||||
(result['data'][1]['iconColor']).should.equal('blue')
|
(result['data'][1]['iconColor']).should.equal('blue')
|
||||||
(result['data'][1]['private']).should.equal('0')
|
(result['data'][1]['private']).should.equal('0')
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe 'Topic paths' do
|
||||||
(topic['name']).should.equal('Server management')
|
(topic['name']).should.equal('Server management')
|
||||||
(topic['icon_color']).should.equal('red')
|
(topic['icon_color']).should.equal('red')
|
||||||
(topic['icon']).should.equal('cogs')
|
(topic['icon']).should.equal('cogs')
|
||||||
(topic['private']).should.equal('0')
|
(topic['private']).should.equal(0)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('ADD_TOPIC')
|
(lastLog['type']).should.equal('ADD_TOPIC')
|
||||||
|
@ -40,7 +40,7 @@ describe 'Topic paths' do
|
||||||
(topic['name']).should.equal('Installation issues')
|
(topic['name']).should.equal('Installation issues')
|
||||||
(topic['icon_color']).should.equal('blue')
|
(topic['icon_color']).should.equal('blue')
|
||||||
(topic['icon']).should.equal('cogs')
|
(topic['icon']).should.equal('cogs')
|
||||||
(topic['private']).should.equal('1')
|
(topic['private']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should delete topic correctly' do
|
it 'should delete topic correctly' do
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'net/http'
|
||||||
require 'net/imap'
|
require 'net/imap'
|
||||||
require 'net/smtp'
|
require 'net/smtp'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'mysql'
|
require 'mysql2'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'mechanize'
|
require 'mechanize'
|
||||||
require 'mailfactory'
|
require 'mailfactory'
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
$agent = Mechanize.new
|
$agent = Mechanize.new
|
||||||
|
|
||||||
|
$apiURL = ENV['API_URL'] || 'http://localhost:8080'
|
||||||
|
|
||||||
def plainRequest(path, data = {}, method = 'POST')
|
def plainRequest(path, data = {}, method = 'POST')
|
||||||
uri = 'http://localhost:8080' + path
|
uri = $apiURL + path
|
||||||
|
|
||||||
if method == 'POST'
|
if method == 'POST'
|
||||||
@response = $agent.post(uri, data)
|
@response = $agent.post(uri, data)
|
||||||
|
@ -13,7 +15,7 @@ def plainRequest(path, data = {}, method = 'POST')
|
||||||
end
|
end
|
||||||
|
|
||||||
def request(path, data = {})
|
def request(path, data = {})
|
||||||
uri = 'http://localhost:8080' + path
|
uri = $apiURL + path
|
||||||
response = $agent.post(uri, data)
|
response = $agent.post(uri, data)
|
||||||
|
|
||||||
return JSON.parse(response.body)
|
return JSON.parse(response.body)
|
||||||
|
@ -25,7 +27,13 @@ class Database
|
||||||
mysqlPort = ENV['MYSQL_PORT'] || '3306'
|
mysqlPort = ENV['MYSQL_PORT'] || '3306'
|
||||||
mysqlUser = ENV['MYSQL_USER'] || 'root'
|
mysqlUser = ENV['MYSQL_USER'] || 'root'
|
||||||
mysqlPass = ENV['MYSQL_PASSWORD'] || ''
|
mysqlPass = ENV['MYSQL_PASSWORD'] || ''
|
||||||
@connection = Mysql.new(mysqlHost, mysqlUser, mysqlPass, 'development', mysqlPort.to_i)
|
@connection = Mysql2::Client.new(
|
||||||
|
host: mysqlHost,
|
||||||
|
username: mysqlUser,
|
||||||
|
password: mysqlPass,
|
||||||
|
port: mysqlPort.to_i,
|
||||||
|
database: 'development'
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def close()
|
def close()
|
||||||
|
@ -35,13 +43,13 @@ class Database
|
||||||
def getRow(table, value, field = 'id')
|
def getRow(table, value, field = 'id')
|
||||||
queryResponse = @connection.query("select * from #{table} where #{field}='#{value.to_s}'")
|
queryResponse = @connection.query("select * from #{table} where #{field}='#{value.to_s}'")
|
||||||
|
|
||||||
return queryResponse.fetch_hash
|
return queryResponse.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def getLastRow(table)
|
def getLastRow(table)
|
||||||
queryResponse = @connection.query("select * from #{table} order by id desc limit 1")
|
queryResponse = @connection.query("select * from #{table} order by id desc limit 1")
|
||||||
|
|
||||||
return queryResponse.fetch_hash
|
return queryResponse.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def query(query_string)
|
def query(query_string)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
./clean_db.sh
|
./truncate_db.sh
|
||||||
./clean_db.sh
|
./truncate_db.sh
|
||||||
./clean_db.sh
|
./truncate_db.sh
|
||||||
bacon init.rb
|
bacon init.rb
|
||||||
|
|
|
@ -20,15 +20,15 @@ describe '/staff/assign-ticket' do
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
|
|
||||||
(ticket['owner_id']).should.equal('1')
|
(ticket['owner_id']).should.equal(1)
|
||||||
|
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
|
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
|
||||||
|
|
||||||
(staff_ticket['staff_id']).should.equal('1')
|
(staff_ticket['staff_id']).should.equal(1)
|
||||||
|
|
||||||
(staff_ticket['ticket_id']).should.equal('1')
|
(staff_ticket['ticket_id']).should.equal(1)
|
||||||
end
|
end
|
||||||
it 'should assign ticket if a staff choose another to assing a ticket ' do
|
it 'should assign ticket if a staff choose another to assing a ticket ' do
|
||||||
staffId = $database.getRow('staff','ayra2@opensupports.com','email')['id']
|
staffId = $database.getRow('staff','ayra2@opensupports.com','email')['id']
|
||||||
|
@ -46,7 +46,7 @@ describe '/staff/assign-ticket' do
|
||||||
|
|
||||||
(ticket['owner_id']).should.equal(staffId)
|
(ticket['owner_id']).should.equal(staffId)
|
||||||
|
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail if ticket is already owned' do
|
it 'should fail if ticket is already owned' do
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe'/staff/delete' do
|
||||||
(row).should.equal(nil)
|
(row).should.equal(nil)
|
||||||
|
|
||||||
row = $database.getRow('department', 1, 'id')
|
row = $database.getRow('department', 1, 'id')
|
||||||
(row['owners']).should.equal('4')
|
(row['owners']).should.equal(4)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,6 +31,6 @@ describe'/staff/delete' do
|
||||||
(result['message']).should.equal('INVALID_STAFF')
|
(result['message']).should.equal('INVALID_STAFF')
|
||||||
|
|
||||||
row = $database.getRow('department', 1, 'id')
|
row = $database.getRow('department', 1, 'id')
|
||||||
(row['owners']).should.equal('4')
|
(row['owners']).should.equal(4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,17 +18,17 @@ describe'/staff/edit' do
|
||||||
row = $database.getRow('staff', staffId, 'id')
|
row = $database.getRow('staff', staffId, 'id')
|
||||||
|
|
||||||
(row['email']).should.equal('littlelannister@opensupports.com')
|
(row['email']).should.equal('littlelannister@opensupports.com')
|
||||||
(row['level']).should.equal('1')
|
(row['level']).should.equal(1)
|
||||||
|
|
||||||
rows = $database.getRow('department_staff', staffId, 'staff_id')
|
rows = $database.getRow('department_staff', staffId, 'staff_id')
|
||||||
|
|
||||||
(rows['department_id']).should.equal('1')
|
(rows['department_id']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('department', 1, 'id')
|
row = $database.getRow('department', 1, 'id')
|
||||||
(row['owners']).should.equal('4')
|
(row['owners']).should.equal(4)
|
||||||
|
|
||||||
row = $database.getRow('department', 2, 'id')
|
row = $database.getRow('department', 2, 'id')
|
||||||
(row['owners']).should.equal('3')
|
(row['owners']).should.equal(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should edit own data staff' do
|
it 'should edit own data staff' do
|
||||||
|
@ -67,17 +67,17 @@ describe'/staff/edit' do
|
||||||
row = $database.getRow('staff', 'Arya Stark', 'name')
|
row = $database.getRow('staff', 'Arya Stark', 'name')
|
||||||
|
|
||||||
(row['email']).should.equal('ayra2@opensupports.com')
|
(row['email']).should.equal('ayra2@opensupports.com')
|
||||||
(row['level']).should.equal('2')
|
(row['level']).should.equal(2)
|
||||||
(row['send_email_on_new_ticket']).should.equal('0')
|
(row['send_email_on_new_ticket']).should.equal(0)
|
||||||
|
|
||||||
row = $database.getRow('department', 1, 'id')
|
row = $database.getRow('department', 1, 'id')
|
||||||
(row['owners']).should.equal('5')
|
(row['owners']).should.equal(5)
|
||||||
|
|
||||||
row = $database.getRow('department', 2, 'id')
|
row = $database.getRow('department', 2, 'id')
|
||||||
(row['owners']).should.equal('4')
|
(row['owners']).should.equal(4)
|
||||||
|
|
||||||
row = $database.getRow('department', 3, 'id')
|
row = $database.getRow('department', 3, 'id')
|
||||||
(row['owners']).should.equal('2')
|
(row['owners']).should.equal(2)
|
||||||
|
|
||||||
Scripts.logout()
|
Scripts.logout()
|
||||||
Scripts.login('ayra2@opensupports.com', 'starkpassword', true)
|
Scripts.login('ayra2@opensupports.com', 'starkpassword', true)
|
||||||
|
@ -88,7 +88,7 @@ describe'/staff/edit' do
|
||||||
})
|
})
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
row = $database.getRow('staff', 'Arya Stark', 'name')
|
row = $database.getRow('staff', 'Arya Stark', 'name')
|
||||||
(row['send_email_on_new_ticket']).should.equal('1')
|
(row['send_email_on_new_ticket']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail if is not staff logged' do
|
it 'should fail if is not staff logged' do
|
||||||
|
@ -106,7 +106,5 @@ describe'/staff/edit' do
|
||||||
|
|
||||||
(result['status']).should.equal('fail')
|
(result['status']).should.equal('fail')
|
||||||
(result['message']).should.equal('NO_PERMISSION')
|
(result['message']).should.equal('NO_PERMISSION')
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,10 +28,10 @@ describe'/staff/invite' do
|
||||||
(row['name']).should.equal('Tyrion Lannister')
|
(row['name']).should.equal('Tyrion Lannister')
|
||||||
(row['email']).should.equal('tyrion@opensupports.com')
|
(row['email']).should.equal('tyrion@opensupports.com')
|
||||||
(row['profile_pic']).should.equal('')
|
(row['profile_pic']).should.equal('')
|
||||||
(row['level']).should.equal('2')
|
(row['level']).should.equal(2)
|
||||||
|
|
||||||
row = $database.getRow('department', 1, 'id')
|
row = $database.getRow('department', 1, 'id')
|
||||||
(row['owners']).should.equal('4')
|
(row['owners']).should.equal(4)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('INVITE')
|
(lastLog['type']).should.equal('INVITE')
|
||||||
|
@ -52,6 +52,6 @@ describe'/staff/invite' do
|
||||||
(result['message']).should.equal('ALREADY_A_STAFF')
|
(result['message']).should.equal('ALREADY_A_STAFF')
|
||||||
|
|
||||||
row = $database.getRow('department', 1, 'id')
|
row = $database.getRow('department', 1, 'id')
|
||||||
(row['owners']).should.equal('4')
|
(row['owners']).should.equal(4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe '/staff/un-assign-ticket' do
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
|
|
||||||
(ticket['owner_id']).should.equal(nil)
|
(ticket['owner_id']).should.equal(nil)
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
|
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ describe '/staff/un-assign-ticket' do
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
|
|
||||||
(ticket['owner_id']).should.equal(nil)
|
(ticket['owner_id']).should.equal(nil)
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
|
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe'system/add-department' do
|
||||||
row = $database.getRow('department', 4, 'id')
|
row = $database.getRow('department', 4, 'id')
|
||||||
|
|
||||||
(row['name']).should.equal('Tech support')
|
(row['name']).should.equal('Tech support')
|
||||||
(row['private']).should.equal("0")
|
(row['private']).should.equal(0)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
||||||
|
@ -32,7 +32,7 @@ describe'system/add-department' do
|
||||||
row = $database.getRow('department', 6, 'id')
|
row = $database.getRow('department', 6, 'id')
|
||||||
|
|
||||||
(row['name']).should.equal('new department')
|
(row['name']).should.equal('new department')
|
||||||
(row['private']).should.equal("0")
|
(row['private']).should.equal(0)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
||||||
|
@ -49,7 +49,7 @@ describe'system/add-department' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
row = $database.getRow('department', 'a private department', 'name')
|
row = $database.getRow('department', 'a private department', 'name')
|
||||||
(row['private']).should.equal('1')
|
(row['private']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
||||||
|
|
|
@ -97,8 +97,8 @@ describe 'Custom fields' do
|
||||||
($database.getRow('customfieldoption', 'option2', 'name')['customfield_id']).should.equal(custom_field_row_id)
|
($database.getRow('customfieldoption', 'option2', 'name')['customfield_id']).should.equal(custom_field_row_id)
|
||||||
($database.getRow('customfieldoption', 'option3', 'name')['customfield_id']).should.equal(custom_field_row_id)
|
($database.getRow('customfieldoption', 'option3', 'name')['customfield_id']).should.equal(custom_field_row_id)
|
||||||
|
|
||||||
quantity_of_options = $database.query("SELECT COUNT(*) as qt FROM customfieldoption WHERE customfield_id='#{custom_field_row_id}'").fetch_hash['qt']
|
quantity_of_options = $database.query("SELECT COUNT(*) as qt FROM customfieldoption WHERE customfield_id='#{custom_field_row_id}'").first['qt']
|
||||||
(quantity_of_options).should.equal("3")
|
(quantity_of_options).should.equal(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail if field name already exists' do
|
it 'should fail if field name already exists' do
|
||||||
|
|
|
@ -85,14 +85,14 @@ describe 'system/delete-department' do
|
||||||
ticket2 = $database.getRow('ticket', ticket2, 'ticket_number')
|
ticket2 = $database.getRow('ticket', ticket2, 'ticket_number')
|
||||||
ticket3 = $database.getRow('ticket', ticket3, 'ticket_number')
|
ticket3 = $database.getRow('ticket', ticket3, 'ticket_number')
|
||||||
|
|
||||||
(ticket1['department_id']).should.equal('3')
|
(ticket1['department_id']).should.equal(3)
|
||||||
(ticket1['owner_id']).should.equal(nil)
|
(ticket1['owner_id']).should.equal(nil)
|
||||||
|
|
||||||
(ticket2['department_id']).should.equal('3')
|
(ticket2['department_id']).should.equal(3)
|
||||||
(ticket2['owner_id']).should.equal(nil)
|
(ticket2['owner_id']).should.equal(nil)
|
||||||
|
|
||||||
(ticket3['department_id']).should.equal('3')
|
(ticket3['department_id']).should.equal(3)
|
||||||
(ticket3['owner_id']).should.equal($csrf_userid)
|
(ticket3['owner_id']).should.equal($csrf_userid.to_i)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('DELETE_DEPARTMENT')
|
(lastLog['type']).should.equal('DELETE_DEPARTMENT')
|
||||||
|
|
|
@ -65,31 +65,31 @@ describe'system/edit-settings' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
row = $database.getRow('language', 'en', 'code')
|
row = $database.getRow('language', 'en', 'code')
|
||||||
(row['supported']).should.equal('1')
|
(row['supported']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'pt', 'code')
|
row = $database.getRow('language', 'pt', 'code')
|
||||||
(row['supported']).should.equal('1')
|
(row['supported']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'jp', 'code')
|
row = $database.getRow('language', 'jp', 'code')
|
||||||
(row['supported']).should.equal('1')
|
(row['supported']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'ru', 'code')
|
row = $database.getRow('language', 'ru', 'code')
|
||||||
(row['supported']).should.equal('1')
|
(row['supported']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'en', 'code')
|
row = $database.getRow('language', 'en', 'code')
|
||||||
(row['allowed']).should.equal('1')
|
(row['allowed']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'pt', 'code')
|
row = $database.getRow('language', 'pt', 'code')
|
||||||
(row['allowed']).should.equal('1')
|
(row['allowed']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'jp', 'code')
|
row = $database.getRow('language', 'jp', 'code')
|
||||||
(row['allowed']).should.equal('1')
|
(row['allowed']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'ru', 'code')
|
row = $database.getRow('language', 'ru', 'code')
|
||||||
(row['allowed']).should.equal('1')
|
(row['allowed']).should.equal(1)
|
||||||
|
|
||||||
row = $database.getRow('language', 'de', 'code')
|
row = $database.getRow('language', 'de', 'code')
|
||||||
(row['allowed']).should.equal('1')
|
(row['allowed']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('EDIT_SETTINGS')
|
(lastLog['type']).should.equal('EDIT_SETTINGS')
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe 'File Upload and Download' do
|
||||||
ticket = $database.getLastRow('ticket')
|
ticket = $database.getLastRow('ticket')
|
||||||
|
|
||||||
(ticket['file'].include? 'upload_3_.txt').should.equal(true)
|
(ticket['file'].include? 'upload_3_.txt').should.equal(true)
|
||||||
(ticket['file'].include? ('' + ticket['ticket_number'] + '_')).should.equal(true)
|
(ticket['file'].include? ('' + ticket['ticket_number'].to_s + '_')).should.equal(true)
|
||||||
(File.exist? ('../server/files/' + ticket['file'])).should.equal(true)
|
(File.exist? ('../server/files/' + ticket['file'])).should.equal(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,8 @@ describe'system/mandatory-login' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(result['data']['ticketNumber']).should.equal($ticketRow['ticket_number'].to_i)
|
(result['data']['ticketNumber']).should.equal($ticketRow['ticket_number'].to_i)
|
||||||
($userRow['email']).should.equal('nonuser@os4.com')
|
($userRow['email']).should.equal('nonuser@os4.com')
|
||||||
($userRow['not_registered']).should.equal('1')
|
($userRow['not_registered']).should.equal(1)
|
||||||
($userRow['tickets']).should.equal('1')
|
($userRow['tickets']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should allow the creator creates another ticket and not create another user' do
|
it 'should allow the creator creates another ticket and not create another user' do
|
||||||
|
@ -133,7 +133,7 @@ describe'system/mandatory-login' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(result['data']['ticketNumber']).should.equal($ticketRow['ticket_number'].to_i)
|
(result['data']['ticketNumber']).should.equal($ticketRow['ticket_number'].to_i)
|
||||||
($userRow['email']).should.equal('nonuser@os4.com')
|
($userRow['email']).should.equal('nonuser@os4.com')
|
||||||
($userRow['tickets']).should.equal('2')
|
($userRow['tickets']).should.equal(2)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ describe'system/mandatory-login' do
|
||||||
})
|
})
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(result['data']['userId']).should.equal($userRow['id'])
|
(result['data']['userId']).should.equal($userRow['id'].to_s)
|
||||||
(result['data']['ticketNumber']).should.equal($ticketRow['ticket_number'])
|
(result['data']['ticketNumber']).should.equal($ticketRow['ticket_number'].to_s)
|
||||||
|
|
||||||
$sessionToken = result['data']['token']
|
$sessionToken = result['data']['token']
|
||||||
$sessionId = result['data']['userId']
|
$sessionId = result['data']['userId']
|
||||||
|
@ -257,7 +257,7 @@ describe'system/mandatory-login' do
|
||||||
|
|
||||||
($ticketRow['title']).should.equal('new title of ticket created without login')
|
($ticketRow['title']).should.equal('new title of ticket created without login')
|
||||||
($ticketRow['content']).should.equal('this is the first edited-comment without login')
|
($ticketRow['content']).should.equal('this is the first edited-comment without login')
|
||||||
($ticketRow['closed']).should.equal('1')
|
($ticketRow['closed']).should.equal(1)
|
||||||
|
|
||||||
result = request('/ticket/delete', {
|
result = request('/ticket/delete', {
|
||||||
csrf_token: $sessionToken,
|
csrf_token: $sessionToken,
|
||||||
|
|
|
@ -46,8 +46,8 @@ describe '/ticket/change-department' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
(ticket['department_id']).should.equal('4')
|
(ticket['department_id']).should.equal(4)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('DEPARTMENT_CHANGED')
|
(lastLog['type']).should.equal('DEPARTMENT_CHANGED')
|
||||||
|
@ -74,8 +74,8 @@ describe '/ticket/change-department' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
(ticket['department_id']).should.equal('3')
|
(ticket['department_id']).should.equal(3)
|
||||||
(ticket['owner_id']).should.equal(nil)
|
(ticket['owner_id']).should.equal(nil)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
|
@ -94,7 +94,7 @@ describe '/ticket/change-department' do
|
||||||
})
|
})
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(ticket['department_id']).should.equal('1')
|
(ticket['department_id']).should.equal(1)
|
||||||
|
|
||||||
request('/staff/edit', {
|
request('/staff/edit', {
|
||||||
csrf_userid: $csrf_userid,
|
csrf_userid: $csrf_userid,
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe '/ticket/change-priority' do
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
(ticket['priority']).should.equal('high')
|
(ticket['priority']).should.equal('high')
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('PRIORITY_CHANGED')
|
(lastLog['type']).should.equal('PRIORITY_CHANGED')
|
||||||
|
@ -38,7 +38,7 @@ describe '/ticket/change-priority' do
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
(ticket['priority']).should.equal('medium')
|
(ticket['priority']).should.equal('medium')
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('PRIORITY_CHANGED')
|
(lastLog['type']).should.equal('PRIORITY_CHANGED')
|
||||||
|
@ -58,7 +58,7 @@ describe '/ticket/change-priority' do
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
(ticket['priority']).should.equal('low')
|
(ticket['priority']).should.equal('low')
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('PRIORITY_CHANGED')
|
(lastLog['type']).should.equal('PRIORITY_CHANGED')
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe '/ticket/close' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
|
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
|
||||||
(ticket['closed']).should.equal('1')
|
(ticket['closed']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('CLOSE')
|
(lastLog['type']).should.equal('CLOSE')
|
||||||
|
@ -50,7 +50,7 @@ describe '/ticket/close' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
|
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
|
||||||
(ticket['closed']).should.equal('1')
|
(ticket['closed']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('CLOSE')
|
(lastLog['type']).should.equal('CLOSE')
|
||||||
|
@ -71,7 +71,7 @@ describe '/ticket/close' do
|
||||||
(result['message']).should.equal('NO_PERMISSION')
|
(result['message']).should.equal('NO_PERMISSION')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 'tickettoclose2', 'title')
|
ticket = $database.getRow('ticket', 'tickettoclose2', 'title')
|
||||||
(ticket['closed']).should.equal('0')
|
(ticket['closed']).should.equal(0)
|
||||||
|
|
||||||
request('/staff/edit', {
|
request('/staff/edit', {
|
||||||
csrf_userid: $csrf_userid,
|
csrf_userid: $csrf_userid,
|
||||||
|
@ -95,7 +95,7 @@ describe '/ticket/close' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 'tickettoclose3', 'title')
|
ticket = $database.getRow('ticket', 'tickettoclose3', 'title')
|
||||||
(ticket['closed']).should.equal('1')
|
(ticket['closed']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('CLOSE')
|
(lastLog['type']).should.equal('CLOSE')
|
||||||
|
|
|
@ -44,8 +44,8 @@ describe '/ticket/comment/' do
|
||||||
comment = $database.getRow('ticketevent', ticket['id'], 'ticket_id')
|
comment = $database.getRow('ticketevent', ticket['id'], 'ticket_id')
|
||||||
(comment['content']).should.equal('some comment content')
|
(comment['content']).should.equal('some comment content')
|
||||||
(comment['type']).should.equal('COMMENT')
|
(comment['type']).should.equal('COMMENT')
|
||||||
(comment['author_user_id']).should.equal($csrf_userid)
|
(comment['author_user_id']).should.equal($csrf_userid.to_i)
|
||||||
(ticket['unread_staff']).should.equal('1')
|
(ticket['unread_staff']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('COMMENT')
|
(lastLog['type']).should.equal('COMMENT')
|
||||||
|
@ -67,8 +67,8 @@ describe '/ticket/comment/' do
|
||||||
comment = $database.getRow('ticketevent', ticket['id'], 'ticket_id')
|
comment = $database.getRow('ticketevent', ticket['id'], 'ticket_id')
|
||||||
(comment['content']).should.equal('some comment content')
|
(comment['content']).should.equal('some comment content')
|
||||||
(comment['type']).should.equal('COMMENT')
|
(comment['type']).should.equal('COMMENT')
|
||||||
(comment['author_staff_id']).should.equal($csrf_userid)
|
(comment['author_staff_id']).should.equal($csrf_userid.to_i)
|
||||||
(ticket['unread_staff']).should.equal('1')
|
(ticket['unread_staff']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('COMMENT')
|
(lastLog['type']).should.equal('COMMENT')
|
||||||
|
@ -100,7 +100,7 @@ describe '/ticket/comment/' do
|
||||||
comment = $database.getRow('ticketevent', ticket['id'], 'ticket_id')
|
comment = $database.getRow('ticketevent', ticket['id'], 'ticket_id')
|
||||||
(comment['content']).should.equal('some comment content jeje')
|
(comment['content']).should.equal('some comment content jeje')
|
||||||
(comment['type']).should.equal('COMMENT')
|
(comment['type']).should.equal('COMMENT')
|
||||||
(comment['author_staff_id']).should.equal($csrf_userid)
|
(comment['author_staff_id']).should.equal($csrf_userid.to_i)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('COMMENT')
|
(lastLog['type']).should.equal('COMMENT')
|
||||||
|
@ -201,7 +201,7 @@ describe '/ticket/comment/' do
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
comment = $database.getRow('ticketevent', 'this is not a private comment', 'content')
|
comment = $database.getRow('ticketevent', 'this is not a private comment', 'content')
|
||||||
(comment['private']).should.equal("0")
|
(comment['private']).should.equal(0)
|
||||||
request('/user/logout')
|
request('/user/logout')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -227,6 +227,6 @@ describe '/ticket/comment/' do
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
comment = $database.getRow('ticketevent', 'this is a private comment', 'content')
|
comment = $database.getRow('ticketevent', 'this is a private comment', 'content')
|
||||||
(comment['private']).should.equal("1")
|
(comment['private']).should.equal(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,15 +125,15 @@ describe '/ticket/create' do
|
||||||
|
|
||||||
ticket = $database.getRow('ticket','Winter is coming!','title')
|
ticket = $database.getRow('ticket','Winter is coming!','title')
|
||||||
(ticket['content']).should.equal('The north remembers')
|
(ticket['content']).should.equal('The north remembers')
|
||||||
(ticket['unread']).should.equal('0')
|
(ticket['unread']).should.equal(0)
|
||||||
(ticket['closed']).should.equal('0')
|
(ticket['closed']).should.equal(0)
|
||||||
(ticket['priority']).should.equal('low')
|
(ticket['priority']).should.equal('low')
|
||||||
(ticket['department_id']).should.equal('1')
|
(ticket['department_id']).should.equal(1)
|
||||||
(ticket['author_id']).should.equal($csrf_userid)
|
(ticket['author_id']).should.equal($csrf_userid.to_i)
|
||||||
(ticket['ticket_number'].size).should.equal(6)
|
((Math.log10(ticket['ticket_number'].to_i)).ceil).should.equal(6)
|
||||||
|
|
||||||
ticket_user_relation = $database.getRow('ticket_user', ticket['id'],'ticket_id')
|
ticket_user_relation = $database.getRow('ticket_user', ticket['id'],'ticket_id')
|
||||||
(ticket_user_relation['user_id']).should.equal($csrf_userid)
|
(ticket_user_relation['user_id']).should.equal($csrf_userid.to_i)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('CREATE_TICKET')
|
(lastLog['type']).should.equal('CREATE_TICKET')
|
||||||
|
@ -191,7 +191,7 @@ describe '/ticket/create' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
ticket = $database.getRow('ticket', result['data']['ticketNumber'], 'ticket_number')
|
ticket = $database.getRow('ticket', result['data']['ticketNumber'], 'ticket_number')
|
||||||
(ticket['author_id']).should.equal(nil)
|
(ticket['author_id']).should.equal(nil)
|
||||||
(ticket['author_staff_id']).should.equal('1')
|
(ticket['author_staff_id']).should.equal(1)
|
||||||
|
|
||||||
$ticketNumberByStaff = result['data']['ticketNumber']
|
$ticketNumberByStaff = result['data']['ticketNumber']
|
||||||
request('/user/logout')
|
request('/user/logout')
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe '/ticket/edit-title' do
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(ticket['title']).should.equal('Valar dohaeris')
|
(ticket['title']).should.equal('Valar dohaeris')
|
||||||
(ticket['edited_title']).should.equal('1')
|
(ticket['edited_title']).should.equal(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should change the title of the ticket if staff is logged' do
|
it 'should change the title of the ticket if staff is logged' do
|
||||||
|
@ -50,8 +50,7 @@ describe '/ticket/edit-title' do
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(ticket['title']).should.equal('Valar dohaeris by Staff')
|
(ticket['title']).should.equal('Valar dohaeris by Staff')
|
||||||
(ticket['edited_title']).should.equal('1')
|
(ticket['edited_title']).should.equal(1)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not change the title if the user is not the author' do
|
it 'should not change the title if the user is not the author' do
|
||||||
|
|
|
@ -65,12 +65,12 @@ describe '/ticket/get/' do
|
||||||
|
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(result['data']['ticketNumber']).should.equal(ticket['ticket_number'])
|
(result['data']['ticketNumber']).should.equal(ticket['ticket_number'].to_s)
|
||||||
(result['data']['title']).should.equal(ticket['title'])
|
(result['data']['title']).should.equal(ticket['title'])
|
||||||
(result['data']['content']).should.equal(ticket['content'])
|
(result['data']['content']).should.equal(ticket['content'])
|
||||||
(result['data']['department']['id']).should.equal('1')
|
(result['data']['department']['id']).should.equal('1')
|
||||||
(result['data']['department']['name']).should.equal($database.getRow('department', 1)['name'])
|
(result['data']['department']['name']).should.equal($database.getRow('department', 1)['name'])
|
||||||
(result['data']['date']).should.equal(ticket['date'])
|
(result['data']['date'].to_i).should.equal(ticket['date'])
|
||||||
(result['data']['file']).should.equal(ticket['file'])
|
(result['data']['file']).should.equal(ticket['file'])
|
||||||
(result['data']['language']).should.equal(ticket['language'])
|
(result['data']['language']).should.equal(ticket['language'])
|
||||||
(result['data']['unread']).should.equal(false)
|
(result['data']['unread']).should.equal(false)
|
||||||
|
@ -98,7 +98,7 @@ describe '/ticket/get/' do
|
||||||
})
|
})
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(result['data']['ticketNumber']).should.equal(ticket['ticket_number'])
|
(result['data']['ticketNumber']).should.equal(ticket['ticket_number'].to_s)
|
||||||
(result['data']['title']).should.equal('titleofticket87')
|
(result['data']['title']).should.equal('titleofticket87')
|
||||||
(result['data']['content']).should.equal('contentoftheticket87')
|
(result['data']['content']).should.equal('contentoftheticket87')
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ describe '/ticket/get/' do
|
||||||
})
|
})
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
(result['data']['ticketNumber']).should.equal(ticket['ticket_number'])
|
(result['data']['ticketNumber'].to_i).should.equal(ticket['ticket_number'])
|
||||||
(result['data']['title']).should.equal('titleoftheticket107')
|
(result['data']['title']).should.equal('titleoftheticket107')
|
||||||
(result['data']['content']).should.equal('contentoftheticket107')
|
(result['data']['content']).should.equal('contentoftheticket107')
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,8 +14,8 @@ describe '/ticket/re-open' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 1 , 'id')
|
ticket = $database.getRow('ticket', 1 , 'id')
|
||||||
(ticket['closed']).should.equal('0')
|
(ticket['closed']).should.equal(0)
|
||||||
(ticket['unread']).should.equal('1')
|
(ticket['unread']).should.equal(1)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('RE_OPEN')
|
(lastLog['type']).should.equal('RE_OPEN')
|
||||||
|
@ -45,7 +45,7 @@ describe '/ticket/re-open' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 'contentoftheticketthatisgoingtosucces' , 'content')
|
ticket = $database.getRow('ticket', 'contentoftheticketthatisgoingtosucces' , 'content')
|
||||||
(ticket['closed']).should.equal('0')
|
(ticket['closed']).should.equal(0)
|
||||||
|
|
||||||
request('/staff/edit', {
|
request('/staff/edit', {
|
||||||
csrf_userid: $csrf_userid,
|
csrf_userid: $csrf_userid,
|
||||||
|
@ -76,7 +76,7 @@ describe '/ticket/re-open' do
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
ticket = $database.getRow('ticket', 'tickettoreopen', 'title')
|
ticket = $database.getRow('ticket', 'tickettoreopen', 'title')
|
||||||
(ticket['closed']).should.equal('0')
|
(ticket['closed']).should.equal(0)
|
||||||
|
|
||||||
lastLog = $database.getLastRow('log')
|
lastLog = $database.getLastRow('log')
|
||||||
(lastLog['type']).should.equal('RE_OPEN')
|
(lastLog['type']).should.equal('RE_OPEN')
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe '/ticket/seen' do
|
||||||
})
|
})
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
ticket = $database.getRow('ticket', 1, 'id')
|
ticket = $database.getRow('ticket', 1, 'id')
|
||||||
(ticket['unread_staff']).should.equal('0')
|
(ticket['unread_staff']).should.equal(0)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ describe '/ticket/seen' do
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
ticket = $database.getRow('ticket', 1, 'id')
|
ticket = $database.getRow('ticket', 1, 'id')
|
||||||
(ticket['unread']).should.equal('0')
|
(ticket['unread']).should.equal(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ describe '/user/get-user' do
|
||||||
|
|
||||||
user = $database.getRow('user', 4 , 'id')
|
user = $database.getRow('user', 4 , 'id')
|
||||||
(user['email']).should.equal(result['data']['email'])
|
(user['email']).should.equal(result['data']['email'])
|
||||||
(user['signup_date']).should.equal(result['data']['signupDate'])
|
(user['signup_date']).should.equal(result['data']['signupDate'].to_i)
|
||||||
(user['name']).should.equal(result['data']['name'])
|
(user['name']).should.equal(result['data']['name'])
|
||||||
(user['tickets']).should.equal(result['data']['tickets'].size.to_s)
|
(user['tickets']).should.equal(result['data']['tickets'].size)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -40,12 +40,12 @@ describe '/user/get' do
|
||||||
(result['data']['email']).should.equal('user_get@os4.com')
|
(result['data']['email']).should.equal('user_get@os4.com')
|
||||||
|
|
||||||
ticketFromUser = result['data']['tickets'][0]
|
ticketFromUser = result['data']['tickets'][0]
|
||||||
(ticketFromUser['ticketNumber']).should.equal(ticket['ticket_number'])
|
(ticketFromUser['ticketNumber']).should.equal(ticket['ticket_number'].to_s)
|
||||||
(ticketFromUser['title']).should.equal(ticket['title'])
|
(ticketFromUser['title']).should.equal(ticket['title'])
|
||||||
(ticketFromUser['content']).should.equal(ticket['content'])
|
(ticketFromUser['content']).should.equal(ticket['content'])
|
||||||
(ticketFromUser['department']['id']).should.equal('1')
|
(ticketFromUser['department']['id']).should.equal('1')
|
||||||
(ticketFromUser['department']['name']).should.equal($database.getRow('department', 1)['name'])
|
(ticketFromUser['department']['name']).should.equal($database.getRow('department', 1)['name'])
|
||||||
(ticketFromUser['date']).should.equal(ticket['date'])
|
(ticketFromUser['date'].to_i).should.equal(ticket['date'].to_i)
|
||||||
(ticketFromUser['file']).should.equal(ticket['file'])
|
(ticketFromUser['file']).should.equal(ticket['file'])
|
||||||
(ticketFromUser['language']).should.equal(ticket['language'])
|
(ticketFromUser['language']).should.equal(ticket['language'])
|
||||||
(ticketFromUser['unread']).should.equal(false)
|
(ticketFromUser['unread']).should.equal(false)
|
||||||
|
|
Loading…
Reference in New Issue