apartment 0.17.0 → 0.17.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.
- data/HISTORY.md +5 -0
- data/README.md +4 -0
- data/lib/apartment/adapters/mysql2_adapter.rb +1 -0
- data/lib/apartment/version.rb +1 -1
- data/lib/generators/apartment/install/USAGE +5 -0
- data/lib/generators/apartment/install/install_generator.rb +10 -0
- data/lib/generators/apartment/install/templates/apartment.rb +35 -0
- data/spec/database_spec.rb +22 -1
- metadata +7 -4
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -231,3 +231,7 @@ All jobs *must* stored in the global (public) namespace, so add it to the list o
|
|
231
231
|
* Rake tasks (see the Rakefile) will help you setup your dbs necessary to run tests
|
232
232
|
* Please issue pull requests to the `development` branch. All development happens here, master is used for releases
|
233
233
|
* Ensure that your code is accompanied with tests. No code will be merged without tests
|
234
|
+
|
235
|
+
## License
|
236
|
+
|
237
|
+
Apartment is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
data/lib/apartment/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
##
|
2
|
+
# Apartment Configuration
|
3
|
+
Apartment.configure do |config|
|
4
|
+
|
5
|
+
# these models will not be multi-tenanted,
|
6
|
+
# but remain in the global (public) namespace
|
7
|
+
config.excluded_models = %w{
|
8
|
+
ActiveRecord::SessionStore::Session
|
9
|
+
}
|
10
|
+
|
11
|
+
# use postgres schemas?
|
12
|
+
config.use_postgres_schemas = true
|
13
|
+
|
14
|
+
# configure persistent schemas (E.g. hstore )
|
15
|
+
# config.persistent_schemas = %w{ hstore }
|
16
|
+
|
17
|
+
# add the Rails environment to database names?
|
18
|
+
# config.prepend_environment = true
|
19
|
+
# config.append_environment = true
|
20
|
+
|
21
|
+
# supply list of database names
|
22
|
+
config.database_names = lambda{ ToDo_Tenant_Or_User_Model.scoped.collect(&:database) }
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Elevator Configuration
|
28
|
+
|
29
|
+
# Rails.application.config.middleware.use 'Apartment::Elevators::Domain'
|
30
|
+
|
31
|
+
# Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'
|
32
|
+
|
33
|
+
Rails.application.config.middleware.use 'Apartment::Elevators::Generic', Proc.new { |request|
|
34
|
+
# TODO: supply generic implementation
|
35
|
+
}
|
data/spec/database_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Apartment::Database do
|
|
9
9
|
before do
|
10
10
|
ActiveRecord::Base.establish_connection config
|
11
11
|
Apartment::Test.load_schema # load the Rails schema in the public db schema
|
12
|
-
subject.stub(:config).and_return config # Use
|
12
|
+
subject.stub(:config).and_return config # Use mysql database config for this test
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#adapter" do
|
@@ -21,6 +21,27 @@ describe Apartment::Database do
|
|
21
21
|
subject.adapter
|
22
22
|
Apartment::Adapters::Mysql2Adapter.should be_a(Class)
|
23
23
|
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO this doesn't belong here, but there aren't integration tests currently for mysql
|
27
|
+
# where to put???
|
28
|
+
describe "#exception recovery", :type => :request do
|
29
|
+
let(:database1){ Apartment::Test.next_db }
|
30
|
+
|
31
|
+
before do
|
32
|
+
subject.reload!
|
33
|
+
subject.create database1
|
34
|
+
end
|
35
|
+
after{ subject.drop database1 }
|
36
|
+
|
37
|
+
it "should recover from incorrect database" do
|
38
|
+
session = Capybara::Session.new(:rack_test, Capybara.app)
|
39
|
+
session.visit("http://#{database1}.com")
|
40
|
+
expect {
|
41
|
+
session.visit("http://this-database-should-not-exist.com")
|
42
|
+
}.to raise_error
|
43
|
+
session.visit("http://#{database1}.com")
|
44
|
+
end
|
24
45
|
|
25
46
|
end
|
26
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apartment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -259,6 +259,9 @@ files:
|
|
259
259
|
- lib/apartment/sidekiq/client/database_middleware.rb
|
260
260
|
- lib/apartment/sidekiq/server/database_middleware.rb
|
261
261
|
- lib/apartment/version.rb
|
262
|
+
- lib/generators/apartment/install/USAGE
|
263
|
+
- lib/generators/apartment/install/install_generator.rb
|
264
|
+
- lib/generators/apartment/install/templates/apartment.rb
|
262
265
|
- lib/tasks/apartment.rake
|
263
266
|
- spec/adapters/mysql2_adapter_spec.rb
|
264
267
|
- spec/adapters/postgresql_adapter_spec.rb
|
@@ -336,7 +339,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
336
339
|
version: '0'
|
337
340
|
segments:
|
338
341
|
- 0
|
339
|
-
hash:
|
342
|
+
hash: -4170403971247658822
|
340
343
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
341
344
|
none: false
|
342
345
|
requirements:
|
@@ -345,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
348
|
version: '0'
|
346
349
|
segments:
|
347
350
|
- 0
|
348
|
-
hash:
|
351
|
+
hash: -4170403971247658822
|
349
352
|
requirements: []
|
350
353
|
rubyforge_project:
|
351
354
|
rubygems_version: 1.8.24
|