1
0
Fork 0

Fix code style

This commit is contained in:
Alex Kotov 2019-02-02 09:27:42 +05:00
parent f444564766
commit 2221710bdf
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 13 additions and 4 deletions

View file

@ -53,6 +53,10 @@ Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/application_controller.rb'
Rails/SkipsModelValidations:
Whitelist:
- update_all
Style/AndOr:
EnforcedStyle: conditionals

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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