Skip to content

Commit

Permalink
testing "User preference: Redirect to ticket detail page on service r…
Browse files Browse the repository at this point in the history
…equest save redknitin#12"
  • Loading branch information
IlinDmitry committed Dec 14, 2017
1 parent d54b792 commit 6dca9ae
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions spec/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def app
Helpdesk
end

before :all do
@randomstr = Array.new(10){rand(36).to_s(36)}.join.downcase
@username = 'test_' + @randomstr
@password = 'nitiniswritingthistest'
end

#Check if the login page shows
it 'shows login' do
get '/' #App init is performed in here
Expand Down Expand Up @@ -51,15 +57,14 @@ def app
it 'registers new users' do
get '/' #App init is performed in here

randomstr = Array.new(10){rand(36).to_s(36)}.join.downcase
username = 'test_' + randomstr
password = 'nitiniswritingthistest'

post '/register-user', { :id => username, :pw => password, :confirmpw => password, :email => username + '@nospam.org', :phone => '+971501234567', :display => 'Test User ' + randomstr }
#randomstr = Array.new(10){rand(36).to_s(36)}.join.downcase
#username = 'test_' + randomstr
#password = 'nitiniswritingthistest'
post '/register-user', { :id => @username, :pw => @password, :confirmpw => @password, :email => @username + '@nospam.org', :phone => '+971501234567', :display => 'Test User ' + @randomstr }
expect(last_response).to be_redirect
expect(last_response.location).to include('/login')

post '/login', { :id => username, :pw => password }
post '/login', { :id => @username, :pw => @password }
expect(last_response.status).to eq 302
follow_redirect!
expect(last_response.body).to include('View Request Status') #Only logged in users can view request status
Expand All @@ -72,5 +77,18 @@ def app
expect(last_response.body).to eq (AppConfig::MASTER_LOC_STRUCT.map { |x| { :label => x[:name], :value => x[:code] } }.to_json)
end

#Login and create ticket, test ticket_details
it 'login and create' do
get '/' #App init is performed in here
post '/login', { :id => @username, :pw => @password }
post '/help-me', {:name => 'test', :complaint => 'test'}
expect(last_response.location).to include('/tickets-list') # :ticket_details => false
post '/userprofile', { :email => @username + '@nospam.org', :ticket_details => 'on' }
follow_redirect!
expect(last_response.body).to include('Saved')
post '/help-me', {:name => 'test', :complaint => 'test'}
expect(last_response.location).to include('/ticket-detail') # :ticket_details => true
end

#TODO Run tests for other locations based on the config; if config is empty, test passes
end

0 comments on commit 6dca9ae

Please sign in to comment.