diff --git a/app/components/account/verify_account_component.rb b/app/components/account/verify_account_component.rb index c1aa09c26..42f2a5cd6 100644 --- a/app/components/account/verify_account_component.rb +++ b/app/components/account/verify_account_component.rb @@ -6,6 +6,6 @@ class Account::VerifyAccountComponent < ApplicationComponent end def render? - !account.organization? + Setting["feature.user.skip_verification"].blank? && !account.organization? end end diff --git a/spec/components/account/verify_account_component_spec.rb b/spec/components/account/verify_account_component_spec.rb index a7921f716..1b425ec82 100644 --- a/spec/components/account/verify_account_component_spec.rb +++ b/spec/components/account/verify_account_component_spec.rb @@ -1,38 +1,54 @@ require "rails_helper" describe Account::VerifyAccountComponent do - it "shows a link to verify account to unverified users" do - account = User.new + context "verification is enabled" do + before { Setting["feature.user.skip_verification"] = false } - render_inline Account::VerifyAccountComponent.new(account) + it "shows a link to verify account to unverified users" do + account = User.new - expect(page).to have_content "To perform all the actions verify your account." - expect(page).to have_link "Verify my account" + render_inline Account::VerifyAccountComponent.new(account) + + expect(page).to have_content "To perform all the actions verify your account." + expect(page).to have_link "Verify my account" + end + + it "shows a link to complete verification to level two verified users" do + account = User.new(level_two_verified_at: Time.current) + + render_inline Account::VerifyAccountComponent.new(account) + + expect(page).to have_content "To perform all the actions verify your account." + expect(page).to have_link "Complete verification" + end + + it "shows information about a verified account to level three verified users" do + account = User.new(verified_at: Time.current) + + render_inline Account::VerifyAccountComponent.new(account) + + expect(page).not_to have_content "To perform all the actions verify your account." + expect(page).to have_content "Account verified" + end + + it "does not show verification info to organizations" do + account = User.new(organization: Organization.new) + + render_inline Account::VerifyAccountComponent.new(account) + + expect(page).not_to be_rendered + end end - it "shows a link to complete verification to level two verified users" do - account = User.new(level_two_verified_at: Time.current) + context "verification is disabled" do + before { Setting["feature.user.skip_verification"] = true } - render_inline Account::VerifyAccountComponent.new(account) + it "does not show verification info to anyone" do + account = User.new - expect(page).to have_content "To perform all the actions verify your account." - expect(page).to have_link "Complete verification" - end + render_inline Account::VerifyAccountComponent.new(account) - it "shows information about a verified account to level three verified users" do - account = User.new(verified_at: Time.current) - - render_inline Account::VerifyAccountComponent.new(account) - - expect(page).not_to have_content "To perform all the actions verify your account." - expect(page).to have_content "Account verified" - end - - it "does not show verification info to organizations" do - account = User.new(organization: Organization.new) - - render_inline Account::VerifyAccountComponent.new(account) - - expect(page).not_to be_rendered + expect(page).not_to be_rendered + end end end