Email confirmation modal specs

This commit is contained in:
Matt-Yorkley
2018-02-15 21:50:22 +00:00
committed by Maikel Linke
parent 595bc5d1a5
commit f5a0862655
2 changed files with 19 additions and 5 deletions

View File

@@ -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

View File

@@ -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)