Read cop description http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation to better understand reasons behind enforcing this rule On some cases the `only_path: true` was needed as argument of `have_current_path` matcher to avoid comparing the url parameters and just checking the path.
103 lines
2.6 KiB
Ruby
103 lines
2.6 KiB
Ruby
require 'rails_helper'
|
|
|
|
feature 'Verification path' do
|
|
|
|
scenario "User is an organization" do
|
|
user = create(:user, verified_at: Time.current)
|
|
create(:organization, user: user)
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
expect(page).to have_current_path(account_path)
|
|
end
|
|
|
|
scenario "User is verified" do
|
|
user = create(:user, verified_at: Time.current)
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
expect(page).to have_current_path(account_path)
|
|
expect(page).to have_content 'Your account is already verified'
|
|
end
|
|
|
|
scenario "User requested a letter" do
|
|
user = create(:user, confirmed_phone: "623456789", residence_verified_at: Time.current,
|
|
letter_requested_at: Time.current, letter_verification_code: "666")
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
expect(page).to have_current_path(edit_letter_path)
|
|
end
|
|
|
|
scenario "User is level two verified" do
|
|
user = create(:user, residence_verified_at: Time.current, confirmed_phone: "666666666")
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
expect(page).to have_current_path(new_letter_path)
|
|
end
|
|
|
|
scenario "User received a verification sms" do
|
|
user = create(:user, residence_verified_at: Time.current, unconfirmed_phone: "666666666", sms_confirmation_code: "666")
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
expect(page).to have_current_path(edit_sms_path)
|
|
end
|
|
|
|
scenario "User received verification email" do
|
|
user = create(:user, residence_verified_at: Time.current, email_verification_token: "1234")
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
verification_redirect = current_path
|
|
|
|
visit verified_user_path
|
|
|
|
expect(page).to have_current_path(verification_redirect)
|
|
end
|
|
|
|
scenario "User has verified residence" do
|
|
user = create(:user, residence_verified_at: Time.current)
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
verification_redirect = current_path
|
|
|
|
visit verified_user_path
|
|
|
|
expect(page).to have_current_path(verification_redirect)
|
|
end
|
|
|
|
scenario "User has not started verification process" do
|
|
user = create(:user)
|
|
|
|
login_as(user)
|
|
visit verification_path
|
|
|
|
expect(page).to have_current_path(new_residence_path)
|
|
end
|
|
|
|
scenario "A verified user can not access verification pages" do
|
|
user = create(:user, verified_at: Time.current)
|
|
|
|
login_as(user)
|
|
|
|
verification_paths = [new_residence_path, verified_user_path, edit_sms_path, new_letter_path]
|
|
verification_paths.each do |step_path|
|
|
visit step_path
|
|
|
|
expect(page).to have_current_path(account_path)
|
|
expect(page).to have_content 'Your account is already verified'
|
|
end
|
|
end
|
|
|
|
end
|