Better user specs for joining tables
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
Feature: Joining an occupied table
|
||||
|
||||
@javascript
|
||||
Scenario: Happy flow
|
||||
Given There is an open supplier with a menu
|
||||
And there is a signed in user with an active order
|
||||
And I am on the user homepage
|
||||
When another user scans the QR code on the table
|
||||
And the other user clicks the join table button
|
||||
Then the other user should see a join table waiting message
|
||||
And the original user should see a join request message
|
||||
When the original user approves the other user's join request
|
||||
Then the original user should not see the join request anymore
|
||||
And the other user should be added to the active list
|
||||
And the other user should be redirected to the user menu page
|
||||
|
||||
@javascript
|
||||
Scenario: Original user rejects the join request
|
||||
Given There is an open supplier with a menu
|
||||
And there is a signed in user with an active order
|
||||
And I am on the user homepage
|
||||
When another user scans the QR code on the table
|
||||
And the other user clicks the join table button
|
||||
Then the other user should see a join table waiting message
|
||||
And the original user should see a join request message
|
||||
When the original user rejects the other user's join request
|
||||
Then the original user should not see the join request anymore
|
||||
And the other user should not be added to the active list
|
||||
And the other user should see a join reject message
|
||||
|
||||
#@javascript
|
||||
#Scenario: The other user just wants to see the table menu
|
||||
#Given There is an open supplier with a menu
|
||||
#And there is a signed in user with an active order
|
||||
#And I am on the user homepage
|
||||
#When another user scans the QR code on the table
|
||||
#And the other user clicks the show me the menu button
|
||||
@@ -7,6 +7,13 @@ step "the list is marked as in need of payment" do
|
||||
@list.needs_payment!
|
||||
end
|
||||
|
||||
step "the user has an active list" do
|
||||
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
|
||||
@user.reload
|
||||
@user.active_list_id = @list.id
|
||||
@user.save
|
||||
end
|
||||
|
||||
step "the list should be marked as closed" do
|
||||
@list.reload
|
||||
@list.state.should == 'closed'
|
||||
@@ -22,3 +29,17 @@ end
|
||||
step "I am signed in as a user" do
|
||||
step "I visit the user obtain token path"
|
||||
end
|
||||
|
||||
step "the other user should be added to the active list" do
|
||||
@other_user.reload
|
||||
@list.reload
|
||||
@other_user.active_list_id.should == @list.id
|
||||
@list.user_ids.should =~ [@user.id, @other_user.id]
|
||||
end
|
||||
|
||||
step "the other user should not be added to the active list" do
|
||||
@other_user.reload
|
||||
@list.reload
|
||||
@other_user.active_list_id.should be_nil
|
||||
@list.user_ids.should == [@user.id]
|
||||
end
|
||||
@@ -3,7 +3,20 @@ step "the user scans a table QR code" do
|
||||
page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})"
|
||||
end
|
||||
|
||||
step "another user scans the QR code on the table" do
|
||||
step 'there is another signed in user user'
|
||||
visit user_root_path
|
||||
page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})"
|
||||
end
|
||||
|
||||
|
||||
step 'there is a table' do
|
||||
step 'there is a section'
|
||||
@table ||= create :table, section: @section, supplier: @supplier
|
||||
end
|
||||
|
||||
step "the other user should see a join table waiting message" do
|
||||
#waiting_text = I18n.t('') #TODO: make better user client translation system, similar to supplier
|
||||
waiting_text = page.evaluate_script(%|t('join_request.requestor.waiting_for_confirmation')|)
|
||||
page.should have_content waiting_text
|
||||
end
|
||||
|
||||
@@ -10,3 +10,16 @@ step "the user should be redirected to the archived list path" do
|
||||
route_should_be 'user#history_list'
|
||||
page.should have_selector ".order-row-#{@order.id}"
|
||||
end
|
||||
|
||||
step 'there is another user' do
|
||||
@other_user ||= create :user
|
||||
end
|
||||
|
||||
step "the other user clicks the join table button" do
|
||||
find('.join-table-button').click
|
||||
end
|
||||
|
||||
step "the other user should be redirected to the user menu page" do
|
||||
Capybara.session_name = :other_user
|
||||
route_should_be 'user#list_products'
|
||||
end
|
||||
|
||||
@@ -23,6 +23,12 @@ step "I should be signed in as a user through facebook" do
|
||||
step "the newly created user info should be stored in the local storage"
|
||||
end
|
||||
|
||||
step 'there is another signed in user user' do
|
||||
Capybara.session_name = :other_user
|
||||
step 'there is another user'
|
||||
visit test_login_admin_users_path(email: @other_user.email)
|
||||
end
|
||||
|
||||
step "I should be redirected to the user home" do
|
||||
page.current_path.should == user_root_path
|
||||
end
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
step "the original user should see a join request message" do
|
||||
Capybara.session_name = :default
|
||||
request_text = page.evaluate_script(%|t('join_request.body', {email: '#{@other_user.email}'})|)
|
||||
request_text.should be_present
|
||||
page.should have_content request_text
|
||||
end
|
||||
|
||||
step "the original user should not see the join request anymore" do
|
||||
Capybara.session_name = :default
|
||||
request_text = page.evaluate_script(%|t('join_request.body', {email: '#{@other_user.email}'})|)
|
||||
request_text.should be_present
|
||||
page.should_not have_content request_text
|
||||
end
|
||||
|
||||
step "the original user approves the other user's join request" do
|
||||
find('.approve-join-request-button').click
|
||||
end
|
||||
|
||||
step "the original user rejects the other user's join request" do
|
||||
find('.reject-join-request-button').click
|
||||
end
|
||||
|
||||
step "the other user should see a join reject message" do
|
||||
Capybara.session_name = :other_user
|
||||
reject_text = I18n.t('messages.join_request_rejected')
|
||||
reject_text.should be_present
|
||||
reject_text.should_not include 'translation'
|
||||
page.should have_content reject_text
|
||||
end
|
||||
@@ -15,3 +15,15 @@ step "the user clicks on the user order button" do
|
||||
find('#active-order-table .btn-primary').click
|
||||
sleep 1
|
||||
end
|
||||
|
||||
step "the user has an active order" do
|
||||
step 'there is a section'
|
||||
step 'there is a table'
|
||||
step 'the user has an active list'
|
||||
|
||||
end
|
||||
|
||||
step "there is a signed in user with an active order" do
|
||||
step "I am signed in as a user"
|
||||
step "the user has an active order"
|
||||
end
|
||||
|
||||
+2
-1
@@ -12,7 +12,7 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
#Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f }
|
||||
Dir.glob("spec/acceptance_steps/**/*steps.rb") { |f| load f, true }
|
||||
|
||||
I18n.locale = Rails.configuration.i18n.default_locale
|
||||
I18n.locale =I18n.default_locale
|
||||
Devise.stretches = 1
|
||||
Capybara.javascript_driver = :webkit
|
||||
#Capybara.default_driver = :selenium
|
||||
@@ -113,6 +113,7 @@ RSpec.configure do |config|
|
||||
|
||||
config.before :each, type: :feature do
|
||||
#Supplier.any_instance.stub send_confirmation_instructions: true
|
||||
Capybara.session_name = :default
|
||||
end
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
|
||||
Reference in New Issue
Block a user