diff --git a/spec/controllers/user_confirmations_controller_spec.rb b/spec/controllers/user_confirmations_controller_spec.rb index 144acfc461..6b1e15fc4b 100644 --- a/spec/controllers/user_confirmations_controller_spec.rb +++ b/spec/controllers/user_confirmations_controller_spec.rb @@ -20,22 +20,26 @@ describe UserConfirmationsController, type: :controller do end it "redirects the user to login" do - expect(response).to redirect_to login_path - expect(flash[:error]).to eq I18n.t('devise.user_confirmations.spree_user.not_confirmed') + expect(response).to redirect_to login_path(confirmation: 'not_confirmed') end end context "that has not been confirmed" do it "redirects the user to login" do spree_get :show, confirmation_token: unconfirmed_user.confirmation_token - expect(response).to redirect_to login_path - expect(flash[:success]).to eq I18n.t('devise.user_confirmations.spree_user.confirmed') + expect(response).to redirect_to login_path(confirmation: 'confirmed') end it "confirms the user" do spree_get :show, confirmation_token: unconfirmed_user.confirmation_token expect(unconfirmed_user.reload.confirmed_at).not_to eq(nil) end + + it "redirects to previous url" do + session[:confirmation_return_url] = producers_path + '#/login' + spree_get :show, confirmation_token: unconfirmed_user.confirmation_token + expect(response).to redirect_to producers_path + '#/login?confirmation=confirmed' + end end end diff --git a/spec/features/consumer/authentication_spec.rb b/spec/features/consumer/authentication_spec.rb index 310afb2e79..b8d42a5a82 100644 --- a/spec/features/consumer/authentication_spec.rb +++ b/spec/features/consumer/authentication_spec.rb @@ -78,10 +78,12 @@ feature "Authentication", js: true, retry: 3 do fill_in "Email", with: "test@foo.com" fill_in "Choose a password", with: "test12345" fill_in "Confirm password", with: "test12345" + expect do click_signup_button - page.should have_content I18n.t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') + expect(page).to have_content I18n.t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') end.to enqueue_job Delayed::PerformableMethod + expect(Delayed::Job.last.payload_object.method_name).to eq(:send_on_create_confirmation_instructions_without_delay) end end @@ -120,6 +122,14 @@ feature "Authentication", js: true, retry: 3 do end end + describe "after following email confirmation link" do + scenario "shows confirmed message in modal" do + visit '/#/login?confirmation=confirmed' + expect(page).to have_login_modal + expect(page).to have_content I18n.t('devise.confirmations.confirmed') + end + end + scenario "Loggin by typing login/ redirects to /#/login" do visit "/login" uri = URI.parse(current_url)