Fixes welcome specs and adds a couple more tests
This commit is contained in:
@@ -12,7 +12,7 @@ class Users::SessionsController < Devise::SessionsController
|
||||
|
||||
def stored_path_allows_welcome_screen?
|
||||
stored_path = session[stored_location_key_for(resource)]
|
||||
stored_path && stored_path[0..5] != "/email"
|
||||
stored_path.nil? || stored_path[0..5] != "/email"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,6 +10,24 @@ feature "Welcome screen" do
|
||||
expect(current_path).to eq(welcome_path)
|
||||
end
|
||||
|
||||
scenario 'a regular user does not see it when coing to /email' do
|
||||
|
||||
plain, encrypted = Devise.token_generator.generate(User, :email_verification_token)
|
||||
|
||||
user = create(:user, email_verification_token: plain)
|
||||
|
||||
visit email_path(email_verification_token: encrypted)
|
||||
|
||||
fill_in 'user_email', with: user.email
|
||||
fill_in 'user_password', with: user.password
|
||||
|
||||
click_button 'Log in'
|
||||
|
||||
expect(page).to have_content("You are now a verified user")
|
||||
|
||||
expect(current_path).to eq(account_path)
|
||||
end
|
||||
|
||||
scenario 'it is not shown more than once' do
|
||||
user = create(:user, sign_in_count: 2)
|
||||
|
||||
@@ -42,4 +60,12 @@ feature "Welcome screen" do
|
||||
expect(current_path).to eq(proposals_path)
|
||||
end
|
||||
|
||||
scenario 'is not shown to administrators' do
|
||||
administrator = create(:administrator)
|
||||
|
||||
login_through_form_as(administrator.user)
|
||||
|
||||
expect(current_path).to eq(proposals_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user