apartment 0.26.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -1
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +9 -0
  5. data/HISTORY.md +8 -0
  6. data/README.md +30 -7
  7. data/TODO.md +9 -0
  8. data/apartment.gemspec +9 -8
  9. data/lib/apartment.rb +9 -18
  10. data/lib/apartment/adapters/abstract_adapter.rb +63 -30
  11. data/lib/apartment/adapters/jdbc_mysql_adapter.rb +2 -2
  12. data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +3 -3
  13. data/lib/apartment/adapters/mysql2_adapter.rb +10 -6
  14. data/lib/apartment/adapters/postgresql_adapter.rb +15 -21
  15. data/lib/apartment/adapters/sqlite3_adapter.rb +4 -4
  16. data/lib/apartment/deprecation.rb +13 -0
  17. data/lib/apartment/elevators/generic.rb +3 -2
  18. data/lib/apartment/elevators/host_hash.rb +1 -1
  19. data/lib/apartment/migrator.rb +3 -3
  20. data/lib/apartment/tasks/enhancements.rb +31 -21
  21. data/lib/apartment/tenant.rb +10 -7
  22. data/lib/apartment/version.rb +1 -1
  23. data/lib/generators/apartment/install/templates/apartment.rb +41 -22
  24. data/lib/tasks/apartment.rake +1 -1
  25. data/spec/adapters/jdbc_mysql_adapter_spec.rb +1 -1
  26. data/spec/adapters/jdbc_postgresql_adapter_spec.rb +2 -2
  27. data/spec/adapters/mysql2_adapter_spec.rb +4 -2
  28. data/spec/adapters/postgresql_adapter_spec.rb +3 -3
  29. data/spec/adapters/sqlite3_adapter_spec.rb +1 -1
  30. data/spec/dummy_engine/.gitignore +8 -0
  31. data/spec/dummy_engine/Gemfile +15 -0
  32. data/spec/dummy_engine/Rakefile +34 -0
  33. data/spec/dummy_engine/bin/rails +12 -0
  34. data/spec/dummy_engine/config/initializers/apartment.rb +51 -0
  35. data/spec/dummy_engine/dummy_engine.gemspec +24 -0
  36. data/spec/dummy_engine/lib/dummy_engine.rb +4 -0
  37. data/spec/dummy_engine/lib/dummy_engine/engine.rb +4 -0
  38. data/spec/dummy_engine/lib/dummy_engine/version.rb +3 -0
  39. data/spec/dummy_engine/test/dummy/Rakefile +6 -0
  40. data/spec/dummy_engine/test/dummy/config.ru +4 -0
  41. data/spec/dummy_engine/test/dummy/config/application.rb +22 -0
  42. data/spec/dummy_engine/test/dummy/config/boot.rb +5 -0
  43. data/spec/dummy_engine/test/dummy/config/database.yml +25 -0
  44. data/spec/dummy_engine/test/dummy/config/environment.rb +5 -0
  45. data/spec/dummy_engine/test/dummy/config/environments/development.rb +37 -0
  46. data/spec/dummy_engine/test/dummy/config/environments/production.rb +78 -0
  47. data/spec/dummy_engine/test/dummy/config/environments/test.rb +39 -0
  48. data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +8 -0
  49. data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  51. data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +16 -0
  53. data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +4 -0
  54. data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +3 -0
  55. data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  56. data/spec/dummy_engine/test/dummy/config/locales/en.yml +23 -0
  57. data/spec/dummy_engine/test/dummy/config/routes.rb +56 -0
  58. data/spec/dummy_engine/test/dummy/config/secrets.yml +22 -0
  59. data/spec/examples/connection_adapter_examples.rb +5 -5
  60. data/spec/examples/generic_adapter_examples.rb +75 -37
  61. data/spec/examples/schema_adapter_examples.rb +19 -24
  62. data/spec/integration/query_caching_spec.rb +3 -3
  63. data/spec/integration/use_within_an_engine_spec.rb +28 -0
  64. data/spec/spec_helper.rb +1 -1
  65. data/spec/support/setup.rb +9 -9
  66. data/spec/{database_spec.rb → tenant_spec.rb} +20 -30
  67. data/spec/unit/config_spec.rb +2 -2
  68. data/spec/unit/elevators/domain_spec.rb +1 -1
  69. data/spec/unit/elevators/generic_spec.rb +2 -2
  70. data/spec/unit/elevators/host_hash_spec.rb +5 -5
  71. data/spec/unit/elevators/subdomain_spec.rb +2 -2
  72. data/spec/unit/migrator_spec.rb +7 -7
  73. metadata +104 -43
@@ -0,0 +1,39 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = 'public, max-age=3600'
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+
37
+ # Raises error for missing translations
38
+ # config.action_view.raise_on_missing_translations = true
39
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Rails.application.config.assets.version = '1.0'
5
+
6
+ # Precompile additional assets.
7
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,56 @@
1
+ Rails.application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: bb62b819b585a74e69c797f9d03d5a004d8fe82a8e7a7da6fa2f7923030713b7b087c12cc7a918e71073c38afb343f7223d22ba3f1b223b7e76dbf8d5b65fa2c
15
+
16
+ test:
17
+ secret_key_base: 67945d3b189c71dffef98de2bb7c14d6fb059679c115ca3cddf65c88babe130afe4d583560d0e308b017dd76ce305bef4159d876de9fd893952d9cbf269c8476
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  shared_examples_for "a connection based apartment adapter" do
4
4
  include Apartment::Spec::AdapterRequirements
5
5
 
6
- let(:default_tenant){ subject.process{ ActiveRecord::Base.connection.current_database } }
6
+ let(:default_tenant){ subject.switch{ ActiveRecord::Base.connection.current_database } }
7
7
 
8
8
  describe "#init" do
9
9
  it "should process model exclusions" do
@@ -20,15 +20,15 @@ shared_examples_for "a connection based apartment adapter" do
20
20
  it "should raise an error for unknown database" do
21
21
  expect {
22
22
  subject.drop 'unknown_database'
23
- }.to raise_error(Apartment::DatabaseNotFound)
23
+ }.to raise_error(Apartment::TenantNotFound)
24
24
  end
25
25
  end
26
26
 
27
- describe "#switch" do
27
+ describe "#switch!" do
28
28
  it "should raise an error if database is invalid" do
29
29
  expect {
30
- subject.switch 'unknown_database'
31
- }.to raise_error(Apartment::DatabaseNotFound)
30
+ subject.switch! 'unknown_database'
31
+ }.to raise_error(Apartment::TenantNotFound)
32
32
  end
33
33
  end
34
34
  end
@@ -19,7 +19,7 @@ shared_examples_for "a generic apartment adapter" do
19
19
  end
20
20
 
21
21
  it "should load schema.rb to new schema" do
22
- subject.process(db1) do
22
+ subject.switch(db1) do
23
23
  connection.tables.should include('companies')
24
24
  end
25
25
  end
@@ -31,13 +31,13 @@ shared_examples_for "a generic apartment adapter" do
31
31
 
32
32
  subject.create(db2) do
33
33
  @count = User.count
34
- subject.current_tenant.should == db2
34
+ subject.current.should == db2
35
35
  User.create
36
36
  end
37
37
 
38
- subject.current_tenant.should_not == db2
38
+ subject.current.should_not == db2
39
39
 
40
- subject.process(db2){ User.count.should == @count + 1 }
40
+ subject.switch(db2){ User.count.should == @count + 1 }
41
41
  end
42
42
  end
43
43
 
@@ -48,60 +48,98 @@ shared_examples_for "a generic apartment adapter" do
48
48
  end
49
49
  end
50
50
 
51
- describe "#process" do
52
- it "should connect" do
53
- subject.process(db1) do
54
- subject.current_tenant.should == db1
55
- end
51
+ describe "#switch!" do
52
+ it "should connect to new db" do
53
+ subject.switch!(db1)
54
+ subject.current.should == db1
56
55
  end
57
56
 
58
- it "should reset" do
59
- subject.process(db1)
60
- subject.current_tenant.should == default_tenant
57
+ it "should reset connection if database is nil" do
58
+ subject.switch!
59
+ subject.current.should == default_tenant
61
60
  end
62
61
 
63
- # We're often finding when using Apartment in tests, the `current_tenant` (ie the previously connect to db)
64
- # gets dropped, but process will try to return to that db in a test. We should just reset if it doesn't exist
65
- it "should not throw exception if current_tenant is no longer accessible" do
66
- subject.switch(db2)
62
+ it "should raise an error if database is invalid" do
63
+ expect {
64
+ subject.switch! 'unknown_database'
65
+ }.to raise_error(Apartment::ApartmentError)
66
+ end
67
+ end
68
+
69
+ describe "#switch" do
70
+ it "connects and resets the tenant" do
71
+ subject.switch(db1) do
72
+ subject.current.should == db1
73
+ end
74
+ subject.current.should == default_tenant
75
+ end
76
+
77
+ # We're often finding when using Apartment in tests, the `current` (ie the previously connect to db)
78
+ # gets dropped, but switch will try to return to that db in a test. We should just reset if it doesn't exist
79
+ it "should not throw exception if current is no longer accessible" do
80
+ subject.switch!(db2)
67
81
 
68
82
  expect {
69
- subject.process(db1){ subject.drop(db2) }
83
+ subject.switch(db1){ subject.drop(db2) }
70
84
  }.to_not raise_error
71
85
  end
72
- end
73
86
 
74
- describe "#reset" do
75
- it "should reset connection" do
87
+ it "warns if no block is given, but calls switch!" do
88
+ expect(Apartment::Deprecation).to receive(:warn)
89
+
76
90
  subject.switch(db1)
77
- subject.reset
78
- subject.current_tenant.should == default_tenant
91
+ subject.current.should == db1
79
92
  end
80
93
  end
81
94
 
82
- describe "#switch" do
83
- it "should connect to new db" do
84
- subject.switch(db1)
85
- subject.current_tenant.should == db1
86
- end
95
+ describe "#process" do
96
+ it "is deprecated" do
97
+ expect(Apartment::Deprecation).to receive(:warn)
87
98
 
88
- it "should reset connection if database is nil" do
89
- subject.switch
90
- subject.current_tenant.should == default_tenant
99
+ subject.process(db1) do
100
+ subject.current.should == db1
101
+ end
91
102
  end
103
+ end
92
104
 
93
- it "should raise an error if database is invalid" do
94
- expect {
95
- subject.switch 'unknown_database'
96
- }.to raise_error(Apartment::ApartmentError)
105
+ describe "#reset" do
106
+ it "should reset connection" do
107
+ subject.switch!(db1)
108
+ subject.reset
109
+ subject.current.should == default_tenant
97
110
  end
98
111
  end
99
112
 
100
- describe "#current_tenant" do
113
+ describe "#current" do
101
114
  it "should return the current db name" do
102
- subject.switch(db1)
103
- subject.current_tenant.should == db1
115
+ subject.switch!(db1)
104
116
  subject.current.should == db1
105
117
  end
106
118
  end
119
+
120
+ describe "#each" do
121
+ it "iterates over each tenant by default" do
122
+ result = []
123
+ Apartment.tenant_names = [db2, db1]
124
+
125
+ subject.each do |tenant|
126
+ result << tenant
127
+ expect(subject.current).to eq(tenant)
128
+ end
129
+
130
+ expect(result).to eq([db2, db1])
131
+ end
132
+
133
+ it "iterates over the given tenants" do
134
+ result = []
135
+ Apartment.tenant_names = [db2]
136
+
137
+ subject.each([db2]) do |tenant|
138
+ result << tenant
139
+ expect(subject.current).to eq(tenant)
140
+ end
141
+
142
+ expect(result).to eq([db2])
143
+ end
144
+ end
107
145
  end
@@ -67,7 +67,7 @@ shared_examples_for "a schema based apartment adapter" do
67
67
 
68
68
  connection.schema_search_path.should_not start_with %{"#{schema2}"}
69
69
 
70
- subject.process(schema2){ User.count.should == @count + 1 }
70
+ subject.switch(schema2){ User.count.should == @count + 1 }
71
71
  end
72
72
 
73
73
  context "numeric database names" do
@@ -88,7 +88,7 @@ shared_examples_for "a schema based apartment adapter" do
88
88
  it "should raise an error for unknown database" do
89
89
  expect {
90
90
  subject.drop "unknown_database"
91
- }.to raise_error(Apartment::SchemaNotFound)
91
+ }.to raise_error(Apartment::TenantNotFound)
92
92
  end
93
93
 
94
94
  context "numeric database names" do
@@ -106,29 +106,26 @@ shared_examples_for "a schema based apartment adapter" do
106
106
  end
107
107
  end
108
108
 
109
- describe "#process" do
110
- it "should connect" do
111
- subject.process(schema1) do
109
+ describe "#switch" do
110
+ it "connects and resets" do
111
+ subject.switch(schema1) do
112
112
  connection.schema_search_path.should start_with %{"#{schema1}"}
113
113
  end
114
- end
115
114
 
116
- it "should reset" do
117
- subject.process(schema1)
118
115
  connection.schema_search_path.should start_with %{"#{public_schema}"}
119
116
  end
120
117
  end
121
118
 
122
119
  describe "#reset" do
123
120
  it "should reset connection" do
124
- subject.switch(schema1)
121
+ subject.switch!(schema1)
125
122
  subject.reset
126
123
  connection.schema_search_path.should start_with %{"#{public_schema}"}
127
124
  end
128
125
 
129
126
  context "with default_schema", :default_schema => true do
130
127
  it "should reset to the default schema" do
131
- subject.switch(schema1)
128
+ subject.switch!(schema1)
132
129
  subject.reset
133
130
  connection.schema_search_path.should start_with %{"#{default_schema}"}
134
131
  end
@@ -136,7 +133,7 @@ shared_examples_for "a schema based apartment adapter" do
136
133
 
137
134
  context "persistent_schemas", :persistent_schemas => true do
138
135
  before do
139
- subject.switch(schema1)
136
+ subject.switch!(schema1)
140
137
  subject.reset
141
138
  end
142
139
 
@@ -153,21 +150,21 @@ shared_examples_for "a schema based apartment adapter" do
153
150
  end
154
151
  end
155
152
 
156
- describe "#switch" do
153
+ describe "#switch!" do
157
154
  it "should connect to new schema" do
158
- subject.switch(schema1)
155
+ subject.switch!(schema1)
159
156
  connection.schema_search_path.should start_with %{"#{schema1}"}
160
157
  end
161
158
 
162
159
  it "should reset connection if database is nil" do
163
- subject.switch
160
+ subject.switch!
164
161
  connection.schema_search_path.should == %{"#{public_schema}"}
165
162
  end
166
163
 
167
164
  it "should raise an error if schema is invalid" do
168
165
  expect {
169
- subject.switch 'unknown_schema'
170
- }.to raise_error(Apartment::SchemaNotFound)
166
+ subject.switch! 'unknown_schema'
167
+ }.to raise_error(Apartment::TenantNotFound)
171
168
  end
172
169
 
173
170
  context "numeric databases" do
@@ -176,7 +173,7 @@ shared_examples_for "a schema based apartment adapter" do
176
173
  it "should connect to them" do
177
174
  subject.create(db)
178
175
  expect {
179
- subject.switch(db)
176
+ subject.switch!(db)
180
177
  }.to_not raise_error
181
178
 
182
179
  connection.schema_search_path.should start_with %{"#{db.to_s}"}
@@ -187,7 +184,7 @@ shared_examples_for "a schema based apartment adapter" do
187
184
 
188
185
  describe "with default_schema specified", :default_schema => true do
189
186
  before do
190
- subject.switch(schema1)
187
+ subject.switch!(schema1)
191
188
  end
192
189
 
193
190
  it "should switch out the default schema rather than public" do
@@ -201,7 +198,7 @@ shared_examples_for "a schema based apartment adapter" do
201
198
 
202
199
  context "persistent_schemas", :persistent_schemas => true do
203
200
 
204
- before{ subject.switch(schema1) }
201
+ before{ subject.switch!(schema1) }
205
202
 
206
203
  it "maintains the persistent schemas in the schema_search_path" do
207
204
  connection.schema_search_path.should end_with persistent_schemas.map { |schema| %{"#{schema}"} }.join(', ')
@@ -213,17 +210,15 @@ shared_examples_for "a schema based apartment adapter" do
213
210
  end
214
211
  end
215
212
 
216
- describe "#current_tenant" do
213
+ describe "#current" do
217
214
  it "should return the current schema name" do
218
- subject.switch(schema1)
219
- subject.current_tenant.should == schema1
215
+ subject.switch!(schema1)
220
216
  subject.current.should == schema1
221
217
  end
222
218
 
223
219
  context "persistent_schemas", :persistent_schemas => true do
224
220
  it "should exlude persistent_schemas" do
225
- subject.switch(schema1)
226
- subject.current_tenant.should == schema1
221
+ subject.switch!(schema1)
227
222
  subject.current.should == schema1
228
223
  end
229
224
  end