diff --git a/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee index 8e3f7368..be8d757a 100644 --- a/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee @@ -8,4 +8,7 @@ App.SettingsController = Ember.ObjectController.extend actions: saveSettings: -> @set 'saving', true - @get('model').save().then (supplier) => @set 'saving', false + @get('model').save().then (supplier) => + @set 'saving', false + $('.top-menu .supplier-name').text @get('model.name') + @transitionToRoute 'index' diff --git a/app/assets/javascripts/supplier/app/templates/settings.emblem b/app/assets/javascripts/supplier/app/templates/settings.emblem index 2210ba88..e62a9eff 100644 --- a/app/assets/javascripts/supplier/app/templates/settings.emblem +++ b/app/assets/javascripts/supplier/app/templates/settings.emblem @@ -1,7 +1,7 @@ h2=t 'settings.title' .form-row .form-label: label=t 'attributes.supplier.name' - .form-field: Ember.TextField valueBinding="controller.model.name" + .form-field: Ember.TextField valueBinding="controller.model.name" classNames="supplier-name" .form-row .form-label: label=t 'attributes.supplier.email' .form-field: App.EmailField valueBinding="controller.model.email" classNames="supplier-email" diff --git a/app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass b/app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass index f3ff318d..c5154ba3 100644 --- a/app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass @@ -78,6 +78,7 @@ header.top-menu left: 0 cursor: pointer z-index: 100 + font-size: 1.4em &.open color: white span diff --git a/app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass b/app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass index 4bb52a9e..d56748f9 100644 --- a/app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass @@ -6,6 +6,8 @@ aside.side-menu top: 0 width: 222px height: 100% + opacity: 0.9 + border-right: 2px solid black z-index: 50 h3 color: white diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 6da17d95..43d47c55 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -15,7 +15,7 @@ class ConfirmationsController < Devise::ConfirmationsController def after_confirmation_path_for(resource_name, resource) case resource_name - when :supplier then supplier_settings_path + when :supplier then supplier_root_path(anchor: '/settings') else root_path end end diff --git a/spec/acceptance/suppliers/settings.feature b/spec/acceptance/suppliers/settings.feature index 1a211279..50ff02cf 100644 --- a/spec/acceptance/suppliers/settings.feature +++ b/spec/acceptance/suppliers/settings.feature @@ -1,5 +1,15 @@ Feature: Manage settings + @javascript + Scenario: Changing the name + Given there is a confirmed and open supplier + And I am signed in as supplier + And I visit the supplier settings path + When the supplier changes the name to "Test8" in the settings page + And the supplier submits the supplier settings form + Then the supplier should be redirected to the root path + And the supplier name in the page should be "Test8" + @javascript Scenario: Changing the supplier email Given there is a confirmed and open supplier @@ -12,7 +22,7 @@ Feature: Manage settings And the supplier unconfirmed email should have been set to the new supplier email And an email should have been sent to the original supplier email with email confirmation instructions When the supplier clicks on the new email confirmation link - Then the supplier gets redirected to the supplier settings path + Then the supplier should be redirected to the supplier settings path And the supplier email is the new email and the unconfirmed email is empty @javascript @broken diff --git a/spec/acceptance/suppliers/signup.feature b/spec/acceptance/suppliers/signup.feature index d0ed5544..aa1e12ae 100644 --- a/spec/acceptance/suppliers/signup.feature +++ b/spec/acceptance/suppliers/signup.feature @@ -1,11 +1,13 @@ Feature: A supplier can sign up + + @javascript Scenario: It works When I visit the supplier signup path And fill in the supplier signup form with new credentials And click on the supplier signup submit button + And I wait 1 second Then a new unconfirmed supplier with the new signup credentials should be created And a supplier signup confirmation mail should be sent containing a link to the token When I visit the supplier signup confirmation path with the correct token Then the new signup supplier should be confirmed - And I should be redirected to the supplier settings page - + And the supplier should be redirected to the supplier settings path diff --git a/spec/acceptance_steps/supplier_steps.rb b/spec/acceptance_steps/supplier_steps.rb index cb05bdbb..c62bc450 100644 --- a/spec/acceptance_steps/supplier_steps.rb +++ b/spec/acceptance_steps/supplier_steps.rb @@ -23,3 +23,7 @@ step "the supplier has a night offset of :minutes minutes" do |minutes| @supplier.night_offset = minutes @supplier.save end + +step "the supplier name in the page should be :name" do |name| + page.find('.top-menu .supplier-name').text.should == name +end diff --git a/spec/acceptance_steps/suppliers/navigation_steps.rb b/spec/acceptance_steps/suppliers/navigation_steps.rb index c9619232..3062ad54 100644 --- a/spec/acceptance_steps/suppliers/navigation_steps.rb +++ b/spec/acceptance_steps/suppliers/navigation_steps.rb @@ -22,3 +22,10 @@ end step "I visit the supplier settings path" do visit "/supplier#/settings" end + + +## ASSERTIONS + +step "the supplier should be redirected to the root path" do + ember_route.should == '/' +end diff --git a/spec/acceptance_steps/suppliers/settings_steps.rb b/spec/acceptance_steps/suppliers/settings_steps.rb index 90d1449a..d02680ba 100644 --- a/spec/acceptance_steps/suppliers/settings_steps.rb +++ b/spec/acceptance_steps/suppliers/settings_steps.rb @@ -27,12 +27,17 @@ step "an email should have been sent to the original supplier email with email c @confirmation_link = confirmation_link_match[1] end +step "the supplier changes the name to :name in the settings page" do |new_name| + page.find('input.supplier-name').set new_name +end + step "the supplier clicks on the new email confirmation link" do visit @confirmation_link end -step "the supplier gets redirected to the supplier settings path" do - route_should_be 'supplier#edit' +step "the supplier should be redirected to the supplier settings path" do + # route_should_be 'supplier#edit' + ember_route.should == '/settings' end step "the supplier email is the new email and the unconfirmed email is empty" do diff --git a/spec/support/route_helpers.rb b/spec/support/route_helpers.rb index 4bf85422..295ea05f 100644 --- a/spec/support/route_helpers.rb +++ b/spec/support/route_helpers.rb @@ -19,6 +19,9 @@ module SpecRouteHelpers end def ember_route - page.evaluate_script %|App.__container__.lookup('router:main').location.lastSetURL| + # currentRouteName does not include model information: /list/123 => currentRouteName == 'list' + # page.evaluate_script %|App.__container__.lookup('controller:application').get('currentRouteName')| + # page.evaluate_script %|App.__container__.lookup('router:main').location.lastSetURL| # not working for direct path supplier#/settings + page.evaluate_script %{App.__container__ && (window.location.hash || "#/").substr(1)} end end