apartment 0.23.2 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +12 -1
  3. data/README.md +16 -13
  4. data/Rakefile +6 -1
  5. data/TODO.md +9 -14
  6. data/lib/apartment.rb +17 -3
  7. data/lib/apartment/adapters/abstract_adapter.rb +53 -44
  8. data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +9 -9
  9. data/lib/apartment/adapters/mysql2_adapter.rb +15 -15
  10. data/lib/apartment/adapters/postgresql_adapter.rb +26 -18
  11. data/lib/apartment/adapters/sqlite3_adapter.rb +13 -13
  12. data/lib/apartment/database.rb +2 -2
  13. data/lib/apartment/elevators/host_hash.rb +3 -3
  14. data/lib/apartment/elevators/subdomain.rb +2 -3
  15. data/lib/apartment/migrator.rb +3 -3
  16. data/lib/apartment/railtie.rb +2 -1
  17. data/lib/apartment/tasks/enhancements.rb +26 -0
  18. data/lib/apartment/version.rb +1 -1
  19. data/lib/generators/apartment/install/templates/apartment.rb +13 -8
  20. data/lib/tasks/apartment.rake +34 -38
  21. data/spec/adapters/jdbc_mysql_adapter_spec.rb +2 -4
  22. data/spec/adapters/jdbc_postgresql_adapter_spec.rb +6 -6
  23. data/spec/adapters/mysql2_adapter_spec.rb +5 -5
  24. data/spec/adapters/postgresql_adapter_spec.rb +6 -6
  25. data/spec/adapters/sqlite3_adapter_spec.rb +2 -2
  26. data/spec/database_spec.rb +2 -2
  27. data/spec/dummy/config/initializers/apartment.rb +2 -2
  28. data/spec/examples/connection_adapter_examples.rb +2 -2
  29. data/spec/examples/generic_adapter_examples.rb +15 -15
  30. data/spec/examples/schema_adapter_examples.rb +6 -6
  31. data/spec/integration/apartment_rake_integration_spec.rb +4 -4
  32. data/spec/integration/query_caching_spec.rb +2 -2
  33. data/spec/support/requirements.rb +2 -5
  34. data/spec/tasks/apartment_rake_spec.rb +8 -9
  35. data/spec/unit/config_spec.rb +17 -10
  36. data/spec/unit/elevators/subdomain_spec.rb +26 -6
  37. metadata +3 -2
@@ -6,14 +6,34 @@ describe Apartment::Elevators::Subdomain do
6
6
  subject(:elevator){ described_class.new(Proc.new{}) }
7
7
 
8
8
  describe "#parse_tenant_name" do
9
- it "should parse subdomain" do
10
- request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.com')
11
- elevator.parse_tenant_name(request).should == 'foo'
9
+ context "assuming tld_length of 1" do
10
+ it "should parse subdomain" do
11
+ request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.com')
12
+ elevator.parse_tenant_name(request).should == 'foo'
13
+ end
14
+
15
+ it "should return nil when no subdomain" do
16
+ request = ActionDispatch::Request.new('HTTP_HOST' => 'bar.com')
17
+ elevator.parse_tenant_name(request).should be_nil
18
+ end
12
19
  end
13
20
 
14
- it "should return nil when no subdomain" do
15
- request = ActionDispatch::Request.new('HTTP_HOST' => 'bar.com')
16
- elevator.parse_tenant_name(request).should be_nil
21
+ context "assuming tld_length of 2" do
22
+ before do
23
+ Apartment.configure do |config|
24
+ config.tld_length = 2
25
+ end
26
+ end
27
+
28
+ it "should parse subdomain in the third level domain" do
29
+ request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.co.uk')
30
+ elevator.parse_tenant_name(request).should == "foo"
31
+ end
32
+
33
+ it "should return nil when no subdomain in the third level domain" do
34
+ request = ActionDispatch::Request.new('HTTP_HOST' => 'bar.co.uk')
35
+ elevator.parse_tenant_name(request).should be_nil
36
+ end
17
37
  end
18
38
  end
19
39
 
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.23.2
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-09 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -195,6 +195,7 @@ files:
195
195
  - lib/apartment/migrator.rb
196
196
  - lib/apartment/railtie.rb
197
197
  - lib/apartment/reloader.rb
198
+ - lib/apartment/tasks/enhancements.rb
198
199
  - lib/apartment/version.rb
199
200
  - lib/generators/apartment/install/USAGE
200
201
  - lib/generators/apartment/install/install_generator.rb