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 +4 -4
- data/VERSION +1 -1
- data/lib/motel/railtie.rb +2 -0
- data/lib/motel/sources/database.rb +1 -1
- data/spec/lib/motel/manager_spec.rb +3 -4
- data/spec/lib/motel/sources/database_spec.rb +3 -3
- data/spec/tmp/tenants.sqlite3 +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e6d9032d0282402d7614ce54ba275eece042195
|
4
|
+
data.tar.gz: 69029443e84cbcbbfc29807f0d33ff3467412a80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43978db6dc9237717afce5e7352162237227527542efacd971ef4063e91de2e99b4283728776944ee27f0fdff3f69574124b18f5a6a740abec519d5879d94459
|
7
|
+
data.tar.gz: e524af21dd5090ea2921eee78481ae22eee9dc5336406f21df7c580fcee322b7d2a0f24f32eb6a389c69c6b76eeaf0d525e0fb047866146089bb6d73b035379b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.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 =
|
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 =
|
125
|
-
|
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',
|
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 =
|
9
|
-
@handler =
|
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(
|
data/spec/tmp/tenants.sqlite3
CHANGED
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.
|
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:
|