Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEP-9115] Upgrade to Apartment 2 causes Patches to Fail #24

Merged
merged 2 commits into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified bin/console
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion lib/patches/tenant_run_concern.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Patches
module TenantRunConcern
def run(tenant_name, path = nil)
Apartment::Tenant.switch(tenant_name)
Apartment::Tenant.switch!(tenant_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

Apartment::Tenant.switch(tenant_name) do
  Patches::Runner.new(path).perform
end

As recommended by https://github.com/influitive/apartment#switching-tenants

I guess it's so that you don't end up staying switched to the last tenant at the end of the run.

It looks like the change was introduced in apartments v1.0.0:
https://github.com/influitive/apartment/blob/development/HISTORY.md#100

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @schlick. Good catch. I thought the block was introduced in v2.

Patches::Runner.new(path).perform
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/patches/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module Patches
VERSION = "3.0.1"
MAJOR = 3
MINOR = 1
PATCH = 0
VERSION = [MAJOR, MINOR, PATCH].compact.join(".").freeze
end
2 changes: 1 addition & 1 deletion spec/tenant_run_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DummyRun

describe '#run' do
it 'calls instance perform' do
expect(Apartment::Tenant).to receive(:switch).with('test')
expect(Apartment::Tenant).to receive(:switch!).with('test')
expect(Patches::Runner).to receive(:new).with('path').and_return(runner)
expect(runner).to receive(:perform)
subject.run('test', 'path')
Expand Down