Add test for all functinality
new setting set to nil on test to prevent prevent unforeseen consequences on testing environment
This commit is contained in:
@@ -89,4 +89,36 @@ feature 'Admin settings' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
describe "Skip verification" do
|
||||||
|
|
||||||
|
scenario "deactivate skip verification", :js do
|
||||||
|
Setting["feature.user.skip_verification"] = 'true'
|
||||||
|
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||||
|
|
||||||
|
visit admin_settings_path
|
||||||
|
|
||||||
|
accept_alert do
|
||||||
|
find("#edit_setting_#{setting.id} .button").click
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content 'Value updated'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "activate skip verification", :js do
|
||||||
|
Setting["feature.user.skip_verification"] = nil
|
||||||
|
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||||
|
|
||||||
|
visit admin_settings_path
|
||||||
|
|
||||||
|
accept_alert do
|
||||||
|
find("#edit_setting_#{setting.id} .button").click
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content 'Value updated'
|
||||||
|
|
||||||
|
Setting["feature.user.skip_verification"] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -68,4 +68,22 @@ feature "Welcome screen" do
|
|||||||
expect(page).to have_current_path(root_path)
|
expect(page).to have_current_path(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'a regular users sees it the first time he logs in, with all options active
|
||||||
|
if the setting skip_verification is activated' do
|
||||||
|
|
||||||
|
Setting["feature.user.skip_verification"] = 'true'
|
||||||
|
|
||||||
|
user = create(:user)
|
||||||
|
|
||||||
|
login_through_form_as(user)
|
||||||
|
|
||||||
|
4.times do |i|
|
||||||
|
expect(page).to have_css ".user-permissions > ul:nth-child(2) >
|
||||||
|
li:nth-child(#{i + 1}) > span:nth-child(1)"
|
||||||
|
end
|
||||||
|
|
||||||
|
Setting["feature.user.skip_verification"] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ RSpec.configure do |config|
|
|||||||
DatabaseCleaner.strategy = :transaction
|
DatabaseCleaner.strategy = :transaction
|
||||||
I18n.locale = :en
|
I18n.locale = :en
|
||||||
load Rails.root.join('db', 'seeds.rb').to_s
|
load Rails.root.join('db', 'seeds.rb').to_s
|
||||||
|
Setting["feature.user.skip_verification"] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each, type: :feature) do
|
config.before(:each, type: :feature) do
|
||||||
|
|||||||
@@ -179,4 +179,79 @@ shared_examples_for "verifiable" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
describe "methods modified by Setting user.skip_verification" do
|
||||||
|
|
||||||
|
let(:user) {create(:user)}
|
||||||
|
|
||||||
|
before do
|
||||||
|
Setting["feature.user.skip_verification"] = 'true'
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
Setting["feature.user.skip_verification"] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#residence_verified?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
expect(user.residence_verified?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#sms_verified?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
expect(user.sms_verified?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#level_two_verified?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
expect(user.level_two_verified?).to eq(true)
|
||||||
|
|
||||||
|
user.update(residence_verified_at: Time.current)
|
||||||
|
expect(user.level_two_verified?).to eq(true)
|
||||||
|
|
||||||
|
user.update(confirmed_phone: "123456789", residence_verified_at: false)
|
||||||
|
expect(user.level_two_verified?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#level_three_verified?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
expect(user.level_three_verified?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#verification_email_sent?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
expect(user.verification_email_sent?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#verification_sms_sent?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
user.update(unconfirmed_phone: nil, sms_confirmation_code: "666")
|
||||||
|
expect(user.verification_sms_sent?).to eq(true)
|
||||||
|
|
||||||
|
user.update(unconfirmed_phone: "666666666", sms_confirmation_code: nil)
|
||||||
|
expect(user.verification_sms_sent?).to eq(true)
|
||||||
|
|
||||||
|
user.update(unconfirmed_phone: nil, sms_confirmation_code: nil)
|
||||||
|
expect(user.verification_sms_sent?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#verification_letter_sent?" do
|
||||||
|
it "is true if skipped" do
|
||||||
|
user.update(letter_requested_at: nil, letter_verification_code: "666")
|
||||||
|
expect(user.verification_letter_sent?).to eq(true)
|
||||||
|
|
||||||
|
user.update(letter_requested_at: Time.current, letter_verification_code: nil)
|
||||||
|
expect(user.verification_letter_sent?).to eq(true)
|
||||||
|
|
||||||
|
user.update(letter_requested_at: nil, letter_verification_code: nil)
|
||||||
|
expect(user.verification_letter_sent?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user