diff --git a/app/assets/javascripts/qwaiter.js.coffee b/app/assets/javascripts/qwaiter.js.coffee index 693a76fa..122e5a18 100644 --- a/app/assets/javascripts/qwaiter.js.coffee +++ b/app/assets/javascripts/qwaiter.js.coffee @@ -20,7 +20,7 @@ window.Qwaiter= .append('') .append('
'+content+'
').appendTo(wrapper) - ok_button = $('Yes') + ok_button = $('Yes') if typeof(options.ok) == 'function' ok_button.click(callback_wrapper) else @@ -28,7 +28,7 @@ window.Qwaiter= eval(options.ok) wrapper.modal('hide') footer = $('') - .append($('Close').click(callback_cancel_wrapper)) + .append($('Close').click(callback_cancel_wrapper)) .append(ok_button) .appendTo(wrapper) wrapper.modal() diff --git a/app/assets/javascripts/user/application.js.erb b/app/assets/javascripts/user/application.js.erb index fab51939..7dd2ceb0 100644 --- a/app/assets/javascripts/user/application.js.erb +++ b/app/assets/javascripts/user/application.js.erb @@ -79,7 +79,7 @@ var $translations = { cannot_move_to_occupied_table: 'You cannot move to an occupied table', moved_to_another_table: 'The table is changed.', confirmation_title: 'Move to another table?', - confirmation_body: 'Are you sure you want to move to another table?' + confirmation_body: 'Do you want to move to another table?' }, models: <%= I18n.t('activemodel.models', locale: :en).to_json %>, attributes: <%= I18n.t('activemodel.attributes', locale: :en).to_json %>, @@ -120,7 +120,7 @@ var $translations = { cannot_move_to_occupied_table: 'Je kan niet verhuizen naar een tafel die reeds gebruikt wordt.', moved_to_another_table: 'De tafel is gewijzigd.', confirmation_title: 'Naar een andere tafel verhuizen?', - confirmation_body: 'Ben je aan een andere tafel gaan zitten?' + confirmation_body: 'Wil je aan een andere tafel gaan zitten?' }, models: <%= I18n.t('activemodel.models', locale: :nl).to_json %>, attributes: <%= I18n.t('activemodel.attributes', locale: :nl).to_json %>, diff --git a/app/models/user.rb b/app/models/user.rb index f6dc68f8..534623bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -59,6 +59,11 @@ class User active_list_id.present? end + # only used for testing so far + def active_list + has_active_list? ? List.find(active_list_id) : nil + end + ##################################### # Taken from devise 2.2 ##################################### diff --git a/spec/acceptance/users/changing_table.feature b/spec/acceptance/users/changing_table.feature new file mode 100644 index 00000000..8c73becb --- /dev/null +++ b/spec/acceptance/users/changing_table.feature @@ -0,0 +1,24 @@ +Feature: Changing table + + @javascript + Scenario: Scanning a table not yet occupied and change to it + Given There is an open supplier with a menu + And there is a signed in user with an active order + And the user is on the homepage + And there is another table + When the user scans a QR code of another not occupied table + Then the user should see a popup asking the user if he would like to change table + When the uses indicates in the popup that he wants to change the table + And I wait 1 second + Then the user should see the supplier menu having the other table as base + And the user list should have been moved to the other table + + @javascript + Scenario: Scanning a table already occupied + Given There is an open supplier with a menu + And there is a signed in user with an active order + And the user is on the homepage + And there is another table with an active list of another user + When the user scans a QR code of another occupied table + Then the user should see a popup telling him that the table is already occupied + And the user list should not have been moved to the other table diff --git a/spec/acceptance/users/sign_up_with_facebook.feature b/spec/acceptance/users/sign_up_with_facebook.feature index 1a43b06f..b236ddcc 100644 --- a/spec/acceptance/users/sign_up_with_facebook.feature +++ b/spec/acceptance/users/sign_up_with_facebook.feature @@ -1,4 +1,5 @@ Feature: Sign up as user using facebook + Note that facebook is automatically signing in @javascript Scenario: Happy flow @@ -27,3 +28,5 @@ Feature: Sign up as user using facebook And I wait 4 seconds Then the newly created user info should be stored in the local storage + Scenario: Facebook problem OmniAuth.config.mock_auth[:facebook] = :invalid_credentials + Scenario: Valid facebook login, but declines information requested by scope diff --git a/spec/acceptance_steps/global_user_steps.rb b/spec/acceptance_steps/global_user_steps.rb index 7a51c6ba..d4a1bd58 100644 --- a/spec/acceptance_steps/global_user_steps.rb +++ b/spec/acceptance_steps/global_user_steps.rb @@ -1,4 +1,8 @@ step "I am on the user homepage" do + step "the user is on the homepage" +end + +step "the user is on the homepage" do visit user_root_path end diff --git a/spec/acceptance_steps/users/changing_table_steps.rb b/spec/acceptance_steps/users/changing_table_steps.rb new file mode 100644 index 00000000..251e1d31 --- /dev/null +++ b/spec/acceptance_steps/users/changing_table_steps.rb @@ -0,0 +1,54 @@ + +step "there is another table" do + @other_table = create :table, number: 89, section: @section, supplier: @supplier +end + +step "the user scans a QR code of another not occupied table" do + page.execute_script "Quser.actions_for_table({table_id: '#{@other_table.id}'})" +end + +step "the user should see a popup asking the user if he would like to change table" do + move_table_body = page.evaluate_script "t('move_table.confirmation_body')" + move_table_body.should be_present + page.should have_content move_table_body +end + +step "the uses indicates in the popup that he wants to change the table" do + find('.confirm-ok').click +end + +step "the user should see the supplier menu having the other table as base" do + route_should_be 'user#list_products' + find('.table-number').text.should == @other_table.number.to_s +end + +step "the user list should have been moved to the other table" do + @user.active_list.table.should == @other_table + @other_table.active_list.should == @user.active_list + @table.active_list.should_not be_present +end + +step "there is another table with an active list of another user" do + step "there is another table" + step 'there is another user' + @other_user_list = List.from_table @other_table, @other_user + +end + +step "the user scans a QR code of another occupied table" do + # same as not, since this is just a scan action. Whether the table + # is occupied is a responsibility of other steps + step "the user scans a QR code of another not occupied table" +end + +step "the user should see a popup telling him that the table is already occupied" do + table_occupied_body = page.evaluate_script "t('messages.table_is_occupied')" + table_occupied_body.should be_present + page.should have_content table_occupied_body +end + +step "the user list should not have been moved to the other table" do + @user.active_list.table.should == @table + @table.active_list.should == @user.active_list + @other_table.active_list.user_ids.should_not include @user.id +end