1
0
Fork 0

Rename factory "empty_account" to "guest_account"

This commit is contained in:
Alex Kotov 2018-12-06 06:56:52 +05:00
parent 83ad9a57e7
commit 4a76fcd9c9
No known key found for this signature in database
GPG Key ID: 4E831250F47DE154
6 changed files with 13 additions and 7 deletions

View File

@ -66,6 +66,10 @@ Style/Documentation:
Style/DoubleNegation:
Enabled: false
Style/RescueModifier:
Exclude:
- 'spec/**/*.rb'
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma

View File

@ -17,6 +17,7 @@ class Account < ApplicationRecord
def add_role(_role_name, _resource = nil)
raise 'can not add role to guest account' if guest?
super
end
end

View File

@ -1,9 +1,9 @@
# frozen_string_literal: true
FactoryBot.define do
factory :empty_account, class: Account
factory :guest_account, class: Account
factory :account_with_user, parent: :empty_account do
factory :account_with_user, parent: :guest_account do
association :user
end

View File

@ -2,7 +2,7 @@
FactoryBot.define do
factory :membership_application do
association :account, factory: :empty_account
association :account, factory: :guest_account
association :country_state
first_name { Faker::Name.first_name }

View File

@ -2,7 +2,7 @@
FactoryBot.define do
factory :user do
association :account, factory: :empty_account
association :account, factory: :guest_account
email { Faker::Internet.email }
password { Faker::Internet.password }

View File

@ -30,7 +30,7 @@ RSpec.describe Account do
describe '#add_role' do
context 'to guest account' do
subject { create :empty_account }
subject { create :guest_account }
let(:result) { subject.add_role :superuser }
@ -40,8 +40,9 @@ RSpec.describe Account do
end
specify do
expect { result rescue nil }.not_to \
change { subject.roles.reload.count }
expect { result rescue nil }.not_to(
change { subject.roles.reload.count },
)
end
end
end