Fix code style
This commit is contained in:
parent
f444564766
commit
2221710bdf
5 changed files with 13 additions and 4 deletions
|
@ -53,6 +53,10 @@ Rails/LexicallyScopedActionFilter:
|
|||
Exclude:
|
||||
- 'app/controllers/application_controller.rb'
|
||||
|
||||
Rails/SkipsModelValidations:
|
||||
Whitelist:
|
||||
- update_all
|
||||
|
||||
Style/AndOr:
|
||||
EnforcedStyle: conditionals
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ class Account < ApplicationRecord
|
|||
|
||||
has_many :account_roles,
|
||||
-> { where deleted_at: nil },
|
||||
dependent: :restrict_with_exception
|
||||
inverse_of: :account,
|
||||
dependent: :restrict_with_exception
|
||||
|
||||
has_many :roles, through: :account_roles
|
||||
|
||||
|
@ -69,6 +70,7 @@ class Account < ApplicationRecord
|
|||
def remove_role(role_name, resource = nil)
|
||||
role = self.class.role_class.find_by name: role_name, resource: resource
|
||||
return if role.nil?
|
||||
|
||||
account_roles.where(role: role).update_all(deleted_at: Time.zone.now)
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@ class Role < ApplicationRecord
|
|||
|
||||
has_many :account_roles,
|
||||
-> { where deleted_at: nil },
|
||||
dependent: :restrict_with_exception
|
||||
inverse_of: :role,
|
||||
dependent: :restrict_with_exception
|
||||
|
||||
has_many :accounts, through: :account_roles
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ RSpec.describe Account do
|
|||
it do
|
||||
is_expected.to \
|
||||
have_many(:account_roles)
|
||||
.inverse_of(:account)
|
||||
.dependent(:restrict_with_exception)
|
||||
end
|
||||
|
||||
|
@ -178,11 +179,11 @@ RSpec.describe Account do
|
|||
end
|
||||
|
||||
specify do
|
||||
expect { result }.not_to change { Role.count }
|
||||
expect { result }.not_to(change { Role.count })
|
||||
end
|
||||
|
||||
specify do
|
||||
expect { result }.not_to change { AccountRole.count }
|
||||
expect { result }.not_to(change { AccountRole.count })
|
||||
end
|
||||
|
||||
specify do
|
||||
|
|
|
@ -8,6 +8,7 @@ RSpec.describe Role do
|
|||
it do
|
||||
is_expected.to \
|
||||
have_many(:account_roles)
|
||||
.inverse_of(:role)
|
||||
.dependent(:restrict_with_exception)
|
||||
end
|
||||
|
||||
|
|
Reference in a new issue