motel-activerecord 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf8d15a90723e29a1cfd4fb21f02d210036bb734
4
- data.tar.gz: 22560e25d8808e51fbe7e3b2d3c043505f2201a5
3
+ metadata.gz: 8e6d9032d0282402d7614ce54ba275eece042195
4
+ data.tar.gz: 69029443e84cbcbbfc29807f0d33ff3467412a80
5
5
  SHA512:
6
- metadata.gz: 8256b2e4a4465f010539b44511201a01091ffce29355079ef03e94cfc2088a7701976cf88da044a37d571fa4810340db86c465e45c81b463999548b17dad4a0d
7
- data.tar.gz: 69df363fa7a2d08471cc4ea2ff6a4fe59ed74497ecad0ba1527c75c2d477761a8d2bb09f6b6a02073a9abb0bc2daf669c7c24c1f24ca06049789f1ee81cfad9b
6
+ metadata.gz: 43978db6dc9237717afce5e7352162237227527542efacd971ef4063e91de2e99b4283728776944ee27f0fdff3f69574124b18f5a6a740abec519d5879d94459
7
+ data.tar.gz: e524af21dd5090ea2921eee78481ae22eee9dc5336406f21df7c580fcee322b7d2a0f24f32eb6a389c69c6b76eeaf0d525e0fb047866146089bb6d73b035379b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
data/lib/motel/railtie.rb CHANGED
@@ -16,9 +16,11 @@ module Motel
16
16
  Rails.application.config.motel.tenants_source_configurations
17
17
  )
18
18
 
19
+ # Set a current tenant allow to db:create:all task get the connection
19
20
  Motel::Manager.current_tenant = "ActiveRecord::Base"
20
21
 
21
22
  ActiveRecord::Tasks::DatabaseTasks.database_configuration = Motel::Manager.tenants
23
+ ActiveRecord::Base.configurations = ActiveRecord::Tasks::DatabaseTasks.database_configuration
22
24
  ActiveRecord::Tasks::DatabaseTasks.env = Motel::Manager.determines_tenant
23
25
  end
24
26
  end
@@ -103,7 +103,7 @@ module Motel
103
103
 
104
104
  def connection_handler
105
105
  @connection_handler ||= begin
106
- handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
106
+ handler = Motel::ConnectionAdapters::ConnectionHandler.new
107
107
  handler.establish_connection self.class, spec
108
108
  handler
109
109
  end
@@ -121,11 +121,10 @@ describe Motel::Manager do
121
121
  end
122
122
 
123
123
  it 'returns true if tenant baz does exist' do
124
- resolver = ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(
125
- BAZ_SPEC, nil
126
- )
124
+ resolver = Motel::ConnectionAdapters::ConnectionSpecification::Resolver.new
125
+ spec = resolver.spec(BAZ_SPEC)
127
126
  handler = ActiveRecord::Base.connection_handler
128
- handler.establish_connection('baz', resolver.spec)
127
+ handler.establish_connection('baz', spec)
129
128
  expect(@manager.tenant?('baz')).to be_true
130
129
  end
131
130
 
@@ -5,9 +5,9 @@ describe Motel::Sources::Database do
5
5
  before(:all) do
6
6
  @klass = Class.new(ActiveRecord::Base) { def self.name; 'klass'; end }
7
7
 
8
- resolver = ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(TENANTS_SPEC, nil)
9
- @handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
10
- @handler.establish_connection(@klass, resolver.spec)
8
+ resolver = Motel::ConnectionAdapters::ConnectionSpecification::Resolver.new
9
+ @handler = Motel::ConnectionAdapters::ConnectionHandler.new
10
+ @handler.establish_connection(@klass, resolver.spec(TENANTS_SPEC))
11
11
 
12
12
  @table_name = 'tenant'
13
13
  @tenants_source = Motel::Sources::Database.new(
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motel-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Martínez Valdelamar
@@ -150,3 +150,4 @@ test_files:
150
150
  - spec/lib/motel/multi_tenant_spec.rb
151
151
  - spec/lib/motel/lobby_spec.rb
152
152
  - spec/lib/motel/manager_spec.rb
153
+ has_rdoc: