From b0a3b76f42e7abf6670bb533eb1b884a35abe199 Mon Sep 17 00:00:00 2001 From: Tomas Patro Date: Tue, 23 Mar 2021 10:56:42 +0100 Subject: [PATCH] Fix styling based on standardrb --- lib/acts_as_tenant.rb | 2 +- lib/acts_as_tenant/model_extensions.rb | 1 - spec/models/model_extensions_spec.rb | 10 ++++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/acts_as_tenant.rb b/lib/acts_as_tenant.rb index bba747c..8e8b208 100644 --- a/lib/acts_as_tenant.rb +++ b/lib/acts_as_tenant.rb @@ -121,7 +121,7 @@ def self.without_tenant(&block) def self.with_mutable_tenant(&block) ActsAsTenant.mutable_tenant!(true) - self.without_tenant(&block) + without_tenant(&block) ensure ActsAsTenant.mutable_tenant!(false) end diff --git a/lib/acts_as_tenant/model_extensions.rb b/lib/acts_as_tenant/model_extensions.rb index 163a446..e870baf 100644 --- a/lib/acts_as_tenant/model_extensions.rb +++ b/lib/acts_as_tenant/model_extensions.rb @@ -96,7 +96,6 @@ def validates_uniqueness_to_tenant(fields, args = {}) raise ActsAsTenant::Errors::ModelNotScopedByTenant unless respond_to?(:scoped_by_tenant?) fkey = reflect_on_association(ActsAsTenant.tenant_klass).foreign_key - pkey = reflect_on_association(ActsAsTenant.tenant_klass).active_record_primary_key validation_args = args.clone validation_args[:scope] = if args[:scope] diff --git a/spec/models/model_extensions_spec.rb b/spec/models/model_extensions_spec.rb index 07d6a93..c04d486 100644 --- a/spec/models/model_extensions_spec.rb +++ b/spec/models/model_extensions_spec.rb @@ -354,9 +354,7 @@ describe "::with_mutable_tenant" do it "should return the value of the block" do - value = ActsAsTenant.with_mutable_tenant do - "something" - end + value = ActsAsTenant.with_mutable_tenant { "something" } expect(value).to eq "something" end @@ -373,13 +371,13 @@ describe 'mutability' do before do - @account = Account.create!(:name => 'foo') - @project = @account.projects.create!(:name => 'bar') + @account = Account.create!(name: "foo") + @project = @account.projects.create!(name: "bar") end it "should allow tenant_id to change inside the block" do new_account_id = @account.id + 1 - expect{ ActsAsTenant.with_mutable_tenant { @project.account_id = new_account_id } }.to_not raise_error(ActsAsTenant::Errors::TenantIsImmutable) + expect { ActsAsTenant.with_mutable_tenant { @project.account_id = new_account_id } }.to_not raise_error(ActsAsTenant::Errors::TenantIsImmutable) expect(@project.account_id).to eq new_account_id end end