Files
grecia/spec/features/management/managed_users_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

163 lines
5.3 KiB
Ruby

require "rails_helper"
describe "Managed User" do
before do
login_as_manager
end
context "Currently managed user" do
scenario "No managed user" do
visit management_document_verifications_path
expect(page).not_to have_css ".account-info"
end
scenario "User is already level three verified" do
user = create(:user, :level_three)
visit management_document_verifications_path
fill_in "document_verification_document_number", with: user.document_number
click_button "Check document"
expect(page).to have_content "already verified"
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
scenario "User becomes verified as level three" do
user = create(:user, :level_two)
visit management_document_verifications_path
fill_in "document_verification_document_number", with: user.document_number
click_button "Check document"
expect(page).to have_content "Vote proposals"
click_button "Verify"
expect(page).to have_content "already verified"
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
scenario "User becomes verified as level two (pending email confirmation for level three)" do
login_as_manager
user = create(:user)
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
click_button "Check document"
within(".account-info") do
expect(page).not_to have_content "Identified as"
expect(page).not_to have_content "Username"
expect(page).not_to have_content "Email"
expect(page).to have_content "Document type"
expect(page).to have_content "Document number"
expect(page).to have_content "12345678Z"
end
expect(page).to have_content "Please introduce the email used on the account"
fill_in "email_verification_email", with: user.email
click_button "Send verification email"
expect(page).to have_content("In order to completely verify this user, it is necessary that the user clicks on a link")
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
scenario "User is created with email as level three from scratch" do
login_as_manager
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
click_button "Check document"
expect(page).to have_content "Please introduce the email used on the account"
click_link "Create a new account"
fill_in "user_username", with: "pepe"
fill_in "user_email", with: "pepe@gmail.com"
click_button "Create user"
expect(page).to have_content "We have sent an email"
expect(page).not_to have_content "Autogenerated password is"
user = User.last
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
scenario "User is created without email as level three from scratch" do
login_as_manager
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
click_button "Check document"
expect(page).to have_content "Please introduce the email used on the account"
click_link "Create a new account"
fill_in "user_username", with: "peppa"
fill_in "user_email", with: ""
click_button "Create user"
expect(page).not_to have_content "We have sent an email"
expect(page).to have_content "Autogenerated password is"
user = User.last
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content user.username.to_s
expect(page).to have_content user.document_number.to_s
end
end
end
scenario "Close the currently managed user session" do
user = create(:user, :level_three)
visit management_document_verifications_path
fill_in "document_verification_document_number", with: user.document_number
click_button "Check document"
expect(page).to have_content "already verified"
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content user.username.to_s
click_link "Change user"
end
expect(page).to have_content "User session signed out successfully."
expect(page).not_to have_content "Identified as"
expect(page).not_to have_content user.username.to_s
expect(page).to have_current_path(management_root_path)
end
end