From febf6fc28928c64cc1fe55c0c12c65b8342734bc Mon Sep 17 00:00:00 2001 From: Emerson Xavier Date: Mon, 25 Nov 2019 08:48:40 +1100 Subject: [PATCH] [NEP-9115] Upgrade to Apartment 2 causes Patches to Fail (#24) * [NEP-9115] Upgrade to Apartment 2 causes Patches to Fail * [NEP-9115] replaces switch! with a block --- bin/console | 0 lib/patches/tenant_run_concern.rb | 5 +++-- lib/patches/version.rb | 5 ++++- spec/tenant_run_concern_spec.rb | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) mode change 100644 => 100755 bin/console diff --git a/bin/console b/bin/console old mode 100644 new mode 100755 diff --git a/lib/patches/tenant_run_concern.rb b/lib/patches/tenant_run_concern.rb index a189000..9f9e73d 100644 --- a/lib/patches/tenant_run_concern.rb +++ b/lib/patches/tenant_run_concern.rb @@ -1,8 +1,9 @@ module Patches module TenantRunConcern def run(tenant_name, path = nil) - Apartment::Tenant.switch(tenant_name) - Patches::Runner.new(path).perform + Apartment::Tenant.switch(tenant_name) do + Patches::Runner.new(path).perform + end end end end diff --git a/lib/patches/version.rb b/lib/patches/version.rb index 21184c1..e84689d 100644 --- a/lib/patches/version.rb +++ b/lib/patches/version.rb @@ -1,3 +1,6 @@ module Patches - VERSION = "3.0.1" + MAJOR = 3 + MINOR = 1 + PATCH = 0 + VERSION = [MAJOR, MINOR, PATCH].compact.join(".").freeze end diff --git a/spec/tenant_run_concern_spec.rb b/spec/tenant_run_concern_spec.rb index 67897b1..983e576 100644 --- a/spec/tenant_run_concern_spec.rb +++ b/spec/tenant_run_concern_spec.rb @@ -19,9 +19,9 @@ class DummyRun describe '#run' do it 'calls instance perform' do - expect(Apartment::Tenant).to receive(:switch).with('test') - expect(Patches::Runner).to receive(:new).with('path').and_return(runner) expect(runner).to receive(:perform) + expect(Patches::Runner).to receive(:new).with('path').and_return(runner) + expect(Apartment::Tenant).to receive(:switch).with('test').and_yield subject.run('test', 'path') end end