tenancy 1.0.1 → 1.0.2

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: 0ef48b93df821bf2413626e56eb09d5f2d361c57
4
- data.tar.gz: 6f306b0e6aed689b63dcb7e443f0902954b58bb2
3
+ metadata.gz: 47bf5750d6e22eda26e832b59751cb976ab8faf8
4
+ data.tar.gz: ddaf27685a4125e8dcdbe06448cfd4dcedb37924
5
5
  SHA512:
6
- metadata.gz: 48e903000a84dcae9fb7ab6e168d006decd9ecc5beb40719800f660a7454d6dfaf610a02efc5568b3c64449f11097aa3f034749a9826e12f20f3a81802b988d0
7
- data.tar.gz: b14758e30137dbd75adf79d532098ac922a390d433a446039988863350e60810fbb4f9d8f9f426f356cd860e1c17f0e22be636323e12f836568238c901f06141
6
+ metadata.gz: d1cf8a9ab76c12625a0dd0fe941b2ddfbfcd6c477908b57104742b2b2e72a41b508bd45fe8d95c6e26aea12627c60ea544cefec5d4c8c1b01062890a2a165ecc
7
+ data.tar.gz: db30925f250aad165be8a4ce08c200feb12412fd53773eea2f90b1bc4ca114f4e95219ede884ba0c69f202466bc39e1f678db45ec16bcbcb96593957c4ba3032
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --colour
2
- --profile
1
+ --colour
@@ -1 +1 @@
1
- ruby-2.1.1
1
+ ruby-2.1.5
@@ -2,19 +2,24 @@ services: mongodb
2
2
  language: ruby
3
3
  script: "bundle exec rake spec"
4
4
  rvm:
5
- - 1.9.3
6
5
  - 2.0.0
7
6
  - 2.1.0
8
- - 2.1.1
7
+ - 2.2.0
9
8
  env:
10
9
  - CODECLIMATE_REPO_TOKEN=891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e
11
10
  gemfile:
12
11
  - gemfiles/active_record_32.gemfile
13
12
  - gemfiles/active_record_40.gemfile
13
+ - gemfiles/active_record_41.gemfile
14
+ - gemfiles/active_record_42.gemfile
14
15
  - gemfiles/mongoid_3.gemfile
15
16
  - gemfiles/mongoid_4.gemfile
16
17
  notifications:
17
18
  email: false
19
+ matrix:
20
+ exclude:
21
+ - rvm: 2.2.0
22
+ gemfile: gemfiles/active_record_32.gemfile
18
23
  addons:
19
- code_climate:
20
- repo_token: 891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e
24
+ code_climate:
25
+ repo_token: 891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e
data/Gemfile CHANGED
@@ -1,16 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "codeclimate-test-reporter", group: :test, require: nil
4
- gem "coveralls", require: false
5
- gem "activerecord", "~> 4.0.2", :require => "active_record"
6
- gem "mongoid", "~> 4.0.0.beta1"
7
- gem "rspec"
8
- gem "mongoid-rspec"
9
- gem "database_cleaner"
10
- gem "shoulda-matchers"
11
- gem "pry"
12
- gem "sqlite3"
13
- gem "rake"
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'activerecord', '~> 4.0.13', require: 'active_record'
6
+ gem 'mongoid', '~> 4.0.1'
7
+ gem 'rspec', '~> 3.2.0'
8
+ gem 'mongoid-rspec', '~> 2.1.0'
9
+ gem 'guard-rspec', '>= 4.5.0'
10
+ gem 'database_cleaner', '= 1.3.0'
11
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
12
+ gem 'sqlite3', '~> 1.3.10'
13
+ gem 'pry'
14
+ gem 'rake'
14
15
 
15
16
  # Specify your gem's dependencies in tenancy.gemspec
16
17
  gemspec
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec feature)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), the you will want to move the Guardfile
18
+ ## to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
76
+ end
77
+ end
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ end
10
10
  task :default => "spec:all"
11
11
 
12
12
  namespace :spec do
13
- %w(active_record_41 active_record_40 active_record_32 mongoid_4 mongoid_3).each do |gemfile|
13
+ %w(active_record_42 active_record_41 active_record_40 active_record_32 mongoid_4 mongoid_3).each do |gemfile|
14
14
  desc "Run Tests against #{gemfile}"
15
15
  task gemfile do
16
16
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
@@ -20,7 +20,7 @@ namespace :spec do
20
20
 
21
21
  desc "Run Tests against active_record versions"
22
22
  task :all do
23
- %w(active_record_41 active_record_40 active_record_32 mongoid_4 mongoid_3).each do |gemfile|
23
+ %w(active_record_42 active_record_41 active_record_40 active_record_32 mongoid_4 mongoid_3).each do |gemfile|
24
24
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
25
25
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rspec"
26
26
  end
@@ -1,13 +1,13 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 3.2.16", :require => "active_record"
4
- gem "coveralls", require: false
5
- gem "codeclimate-test-reporter", group: :test, require: nil
6
- gem "rspec"
7
- gem "database_cleaner"
8
- gem "shoulda-matchers"
9
- gem "pry"
10
- gem "sqlite3"
11
- gem "rake"
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'activerecord', '~> 3.2.21', require: 'active_record'
6
+ gem 'rspec', '~> 3.2.0'
7
+ gem 'database_cleaner', '= 1.3.0'
8
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
9
+ gem 'sqlite3', '~> 1.3.10'
10
+ gem 'pry'
11
+ gem 'rake'
12
12
 
13
- gemspec :path => "../"
13
+ gemspec :path => '../'
@@ -1,13 +1,13 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 4.0.2", :require => "active_record"
4
- gem "coveralls", require: false
5
- gem "codeclimate-test-reporter", group: :test, require: nil
6
- gem "rspec"
7
- gem "database_cleaner"
8
- gem "shoulda-matchers"
9
- gem "pry"
10
- gem "sqlite3"
11
- gem "rake"
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'activerecord', '~> 4.0.13', require: 'active_record'
6
+ gem 'rspec', '~> 3.2.0'
7
+ gem 'database_cleaner', '= 1.3.0'
8
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
9
+ gem 'sqlite3', '~> 1.3.10'
10
+ gem 'pry'
11
+ gem 'rake'
12
12
 
13
- gemspec :path => "../"
13
+ gemspec :path => '../'
@@ -1,13 +1,13 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 4.1.0.rc2", :require => "active_record"
4
- gem "coveralls", require: false
5
- gem "codeclimate-test-reporter", group: :test, require: nil
6
- gem "rspec"
7
- gem "database_cleaner"
8
- gem "shoulda-matchers"
9
- gem "pry"
10
- gem "sqlite3"
11
- gem "rake"
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'activerecord', '~> 4.1.9', require: 'active_record'
6
+ gem 'rspec', '~> 3.2.0'
7
+ gem 'database_cleaner', '= 1.3.0'
8
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
9
+ gem 'sqlite3', '~> 1.3.10'
10
+ gem 'pry'
11
+ gem 'rake'
12
12
 
13
- gemspec :path => "../"
13
+ gemspec :path => '../'
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'activerecord', '~> 4.2.0', require: 'active_record'
6
+ gem 'rspec', '~> 3.2.0'
7
+ gem 'database_cleaner', '= 1.3.0'
8
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
9
+ gem 'sqlite3', '~> 1.3.10'
10
+ gem 'pry'
11
+ gem 'rake'
12
+
13
+ gemspec :path => '../'
@@ -1,12 +1,14 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "mongoid", "~> 3.1.6"
4
- gem "coveralls", require: false
5
- gem "codeclimate-test-reporter", group: :test, require: nil
6
- gem "rspec"
7
- gem "database_cleaner"
8
- gem "mongoid-rspec"
9
- gem "pry"
10
- gem "rake"
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'mongoid', '~> 3.1.6'
6
+ gem 'rspec', '~> 3.2.0'
7
+ gem 'mongoid-rspec', '~> 1.13.0'
8
+ gem 'database_cleaner', '= 1.3.0'
9
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
10
+ gem 'sqlite3', '~> 1.3.10'
11
+ gem 'pry'
12
+ gem 'rake'
11
13
 
12
- gemspec :path => "../"
14
+ gemspec :path => '../'
@@ -1,12 +1,14 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "mongoid", ">= 4.0.0.beta2"
4
- gem "coveralls", require: false
5
- gem "codeclimate-test-reporter", group: :test, require: nil
6
- gem "rspec"
7
- gem "database_cleaner"
8
- gem "mongoid-rspec"
9
- gem "pry"
10
- gem "rake"
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+ gem 'coveralls', require: false
5
+ gem 'mongoid', '~> 4.0.1'
6
+ gem 'rspec', '~> 3.2.0'
7
+ gem 'mongoid-rspec', '~> 2.1.0'
8
+ gem 'database_cleaner', '= 1.3.0'
9
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
10
+ gem 'sqlite3', '~> 1.3.10'
11
+ gem 'pry'
12
+ gem 'rake'
11
13
 
12
- gemspec :path => "../"
14
+ gemspec path: '../'
@@ -9,7 +9,7 @@ module Tenancy
9
9
  end
10
10
 
11
11
  def tenant_scope(*resources)
12
- tenancy_scoping.tenant_scope(resources)
12
+ tenancy_scoping.tenant_scope(resources.compact)
13
13
  end
14
14
 
15
15
  def validates_uniqueness_in_scope(fields, args={})
@@ -27,19 +27,28 @@ module Tenancy
27
27
  end
28
28
 
29
29
  def tenant_scope(tenant_names)
30
- scope = default_scoped
31
- tenants.each do |tenant|
32
- next if tenant_names.include?(tenant.name.to_sym)
30
+ if ::ActiveRecord::VERSION::MAJOR == 4 && ::ActiveRecord::VERSION::MINOR >= 1
31
+ foreign_keys = if tenant_names.blank?
32
+ tenants.map(&:foreign_key)
33
+ else
34
+ tenants.reject { |tenant| tenant_names.include?(tenant.name) }.map(&:foreign_key)
35
+ end
36
+ klass.unscope(where: foreign_keys)
37
+ else
38
+ scope = default_scoped
39
+ tenants.each do |tenant|
40
+ next if tenant_names.include?(tenant.name.to_sym)
33
41
 
34
- tenant_scope_sql = klass.where(nil).table[tenant.foreign_key].eq(tenant.klass.current_id).to_sql
35
- scope.where_values.delete_if { |query| query.to_sql == tenant_scope_sql }
36
- end
42
+ tenant_scope_sql = klass.where(nil).table[tenant.foreign_key].eq(tenant.klass.current_id).to_sql
43
+ scope.where_values.delete_if { |query| query.to_sql == tenant_scope_sql }
44
+ end
37
45
 
38
- scope
46
+ scope
47
+ end
39
48
  end
40
49
 
41
50
  def default_scoped
42
- if ::ActiveRecord::VERSION::MAJOR >= 4 && ::ActiveRecord::VERSION::MINOR >= 1
51
+ if ::ActiveRecord::VERSION::MAJOR == 4 && ::ActiveRecord::VERSION::MINOR >= 1
43
52
  klass.where(nil).default_scoped
44
53
  else
45
54
  klass.where(nil).with_default_scope
@@ -1,3 +1,3 @@
1
1
  module Tenancy
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -9,39 +9,39 @@ if defined?(ActiveRecord)
9
9
  it "set current with instance" do
10
10
  Portal.current = camyp
11
11
 
12
- Portal.current.should == camyp
13
- RequestStore.store[:"Portal.current"].should == camyp
12
+ expect(Portal.current).to eq(camyp)
13
+ expect(RequestStore.store[:"Portal.current"]).to eq(camyp)
14
14
  end
15
15
 
16
16
  it "set current with id" do
17
17
  Portal.current = panpage.id
18
18
 
19
- Portal.current.should == panpage
20
- RequestStore.store[:"Portal.current"].should == panpage
19
+ expect(Portal.current).to eq(panpage)
20
+ expect(RequestStore.store[:"Portal.current"]).to eq(panpage)
21
21
  end
22
22
 
23
23
  it "set current with nil" do
24
24
  Portal.current = panpage
25
25
  Portal.current = nil
26
26
 
27
- Portal.current.should == nil
28
- RequestStore.store[:"Portal.current"].should == nil
27
+ expect(Portal.current).to eq(nil)
28
+ expect(RequestStore.store[:"Portal.current"]).to eq(nil)
29
29
  end
30
30
 
31
31
  it "#current_id" do
32
32
  Portal.current = yoolk
33
33
 
34
- Portal.current_id.should == yoolk.id
34
+ expect(Portal.current_id).to eq(yoolk.id)
35
35
  end
36
36
 
37
37
  it "#with_scope with block" do
38
- Portal.current.should == nil
38
+ expect(Portal.current).to eq(nil)
39
39
 
40
40
  Portal.with_tenant(yoolk) do
41
- Portal.current.should == yoolk
41
+ expect(Portal.current).to eq(yoolk)
42
42
  end
43
43
 
44
- Portal.current.should == nil
44
+ expect(Portal.current).to eq(nil)
45
45
  end
46
46
 
47
47
  it "#with_scope without block" do
@@ -59,39 +59,39 @@ if defined?(Mongoid)
59
59
  it "set current with instance" do
60
60
  Mongo::Portal.current = camyp
61
61
 
62
- Mongo::Portal.current.should == camyp
63
- RequestStore.store[:"Mongo::Portal.current"].should == camyp
62
+ expect(Mongo::Portal.current).to eq(camyp)
63
+ expect(RequestStore.store[:"Mongo::Portal.current"]).to eq(camyp)
64
64
  end
65
65
 
66
66
  it "set current with id" do
67
67
  Mongo::Portal.current = panpage.id
68
68
 
69
- Mongo::Portal.current.should == panpage
70
- RequestStore.store[:"Mongo::Portal.current"].should == panpage
69
+ expect(Mongo::Portal.current).to eq(panpage)
70
+ expect(RequestStore.store[:"Mongo::Portal.current"]).to eq(panpage)
71
71
  end
72
72
 
73
73
  it "set current with nil" do
74
74
  Mongo::Portal.current = panpage
75
75
  Mongo::Portal.current = nil
76
76
 
77
- Mongo::Portal.current.should == nil
78
- RequestStore.store[:"Mongo::Portal.current"].should == nil
77
+ expect(Mongo::Portal.current).to eq(nil)
78
+ expect(RequestStore.store[:"Mongo::Portal.current"]).to eq(nil)
79
79
  end
80
80
 
81
81
  it "#current_id" do
82
82
  Mongo::Portal.current = yoolk
83
83
 
84
- Mongo::Portal.current_id.should == yoolk.id
84
+ expect(Mongo::Portal.current_id).to eq(yoolk.id)
85
85
  end
86
86
 
87
87
  it "#with_scope with block" do
88
- Mongo::Portal.current.should == nil
88
+ expect(Mongo::Portal.current).to eq(nil)
89
89
 
90
90
  Mongo::Portal.with_tenant(yoolk) do
91
- Mongo::Portal.current.should == yoolk
91
+ expect(Mongo::Portal.current).to eq(yoolk)
92
92
  end
93
93
 
94
- Mongo::Portal.current.should == nil
94
+ expect(Mongo::Portal.current).to eq(nil)
95
95
  end
96
96
 
97
97
  it "#with_scope without block" do
@@ -16,7 +16,11 @@ if defined?(ActiveRecord)
16
16
  it "have default_scope with :portal_id field" do
17
17
  Portal.current = camyp
18
18
 
19
- expect(Listing.where(nil).to_sql).to eq(Listing.where(portal_id: Portal.current_id).to_sql)
19
+ if ::ActiveRecord::VERSION::MAJOR == 4 && ::ActiveRecord::VERSION::MINOR >= 1
20
+ expect(Listing.where(nil).to_sql).to eq(Listing.rewhere(portal_id: Portal.current_id).to_sql)
21
+ else
22
+ expect(Listing.where(nil).to_sql).to eq(Listing.where(portal_id: Portal.current_id).to_sql)
23
+ end
20
24
  end
21
25
 
22
26
  it "doesn't have default_scope when it doesn't have current portal" do
@@ -41,7 +45,11 @@ if defined?(ActiveRecord)
41
45
  Portal.current = camyp
42
46
  Listing.current = listing
43
47
 
44
- Communication.where(nil).to_sql.should == Communication.where(portal_id: Portal.current_id, listing_id: Listing.current_id).to_sql
48
+ if ::ActiveRecord::VERSION::MAJOR == 4 && ::ActiveRecord::VERSION::MINOR >= 1
49
+ expect(Communication.where(nil).to_sql).to eq(Communication.rewhere(portal_id: Portal.current_id, listing_id: Listing.current_id).to_sql)
50
+ else
51
+ expect(Communication.where(nil).to_sql).to eq(Communication.where(portal_id: Portal.current_id, listing_id: Listing.current_id).to_sql)
52
+ end
45
53
  end
46
54
 
47
55
  it "doesn't have default_scope when it doesn't have current portal and listing" do
@@ -109,14 +117,14 @@ if defined?(ActiveRecord)
109
117
  Listing.current = listing
110
118
 
111
119
  expect(Communication.tenant_scope(:portal).to_sql).not_to include(%{"communications"."listing_id" = #{Listing.current_id}})
112
- expect(Communication.tenant_scope(:portal).to_sql).to eq(%{SELECT "communications".* FROM "communications" WHERE "communications"."is_active" = 't' AND "communications"."portal_id" = #{Portal.current_id}})
120
+ expect(Communication.tenant_scope(:portal).to_sql.squeeze(' ')).to eq(%{SELECT "communications".* FROM "communications" WHERE "communications"."is_active" = 't' AND "communications"."portal_id" = #{Portal.current_id}})
113
121
  end
114
122
 
115
123
  it "scopes only :current_listing" do
116
124
  Listing.current = listing
117
125
 
118
126
  expect(Communication.tenant_scope(:listing).to_sql).not_to include(%{"communications"."portal_id" = #{Portal.current_id}})
119
- expect(Communication.tenant_scope(:listing).to_sql).to eq(%{SELECT "communications".* FROM "communications" WHERE "communications"."is_active" = 't' AND "communications"."listing_id" = #{Listing.current_id}})
127
+ expect(Communication.tenant_scope(:listing).to_sql.squeeze(' ')).to eq(%{SELECT "communications".* FROM "communications" WHERE "communications"."is_active" = 't' AND "communications"."listing_id" = #{Listing.current_id}})
120
128
  end
121
129
 
122
130
  it "scopes only :current_listing and :current_portal" do
@@ -128,7 +136,7 @@ if defined?(ActiveRecord)
128
136
  it "scopes nothing" do
129
137
  Listing.current = listing
130
138
 
131
- expect(Communication.tenant_scope(nil).to_sql).to eq(%{SELECT "communications".* FROM "communications" WHERE "communications"."is_active" = 't'})
139
+ expect(Communication.tenant_scope(nil).to_sql.squeeze(' ')).to eq(%{SELECT "communications".* FROM "communications" WHERE "communications"."is_active" = 't'})
132
140
  end
133
141
  end
134
142
  end
@@ -1,6 +1,6 @@
1
- require "simplecov"
2
- require "coveralls"
3
- require "codeclimate-test-reporter"
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ require 'codeclimate-test-reporter'
4
4
 
5
5
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
6
  Coveralls::SimpleCov::Formatter,
@@ -9,33 +9,31 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9
9
  ]
10
10
 
11
11
  SimpleCov.start do
12
- add_filter "/spec/"
12
+ add_filter '/spec/'
13
13
  end
14
14
 
15
- require "pry"
16
- require "database_cleaner"
17
- require "logger"
18
- require "tenancy"
19
- require 'minitest/autorun'
15
+ require 'pry'
16
+ require 'database_cleaner'
17
+ require 'logger'
18
+ require 'tenancy'
20
19
 
21
20
  # active_record
22
- if Gem.loaded_specs["activerecord"]
23
- load File.dirname(__FILE__) + "/support/active_record/schema.rb"
24
- load File.dirname(__FILE__) + "/support/active_record/models.rb"
25
- require "shoulda-matchers"
21
+ if Gem.loaded_specs['activerecord']
22
+ load File.dirname(__FILE__) + '/support/active_record/schema.rb'
23
+ load File.dirname(__FILE__) + '/support/active_record/models.rb'
24
+ require 'shoulda-matchers'
26
25
  end
27
26
 
28
27
  # mongoid
29
- if Gem.loaded_specs["mongoid"]
30
- load File.dirname(__FILE__) + "/support/mongoid/connection.rb"
31
- load File.dirname(__FILE__) + "/support/mongoid/models.rb"
32
- require "mongoid-rspec"
28
+ if Gem.loaded_specs['mongoid']
29
+ load File.dirname(__FILE__) + '/support/mongoid/connection.rb'
30
+ load File.dirname(__FILE__) + '/support/mongoid/models.rb'
31
+ require 'mongoid-rspec'
33
32
  end
34
33
 
35
34
  RSpec.configure do |config|
36
35
  config.filter_run focus: true
37
36
  config.run_all_when_everything_filtered = true
38
- config.treat_symbols_as_metadata_keys_with_true_values = true
39
37
 
40
38
  config.before(:suite) do
41
39
  DatabaseCleaner.strategy = :truncation
@@ -1,37 +1,37 @@
1
- require "active_record"
1
+ require 'active_record'
2
2
 
3
- ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "spec/test.sqlite3")
3
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'spec/test.sqlite3')
4
4
  ActiveRecord::Migration.verbose = false
5
5
 
6
6
  ActiveRecord::Schema.define do
7
7
  self.verbose = false
8
8
 
9
- create_table :portals, :force => true do |t|
9
+ create_table :portals, force: true do |t|
10
10
  t.string :domain_name
11
- t.timestamps
11
+ t.timestamps null: false
12
12
  end
13
13
 
14
- create_table :listings, :force => true do |t|
14
+ create_table :listings, force: true do |t|
15
15
  t.string :name
16
16
  t.references :portal
17
17
  t.boolean :is_active
18
- t.timestamps
18
+ t.timestamps null: false
19
19
  end
20
20
 
21
- create_table :communications, :force => true do |t|
21
+ create_table :communications, force: true do |t|
22
22
  t.string :label
23
23
  t.string :value
24
24
  t.references :listing
25
25
  t.references :portal
26
26
  t.boolean :is_active
27
- t.timestamps
27
+ t.timestamps null: false
28
28
  end
29
29
 
30
- create_table :extra_communications, :force => true do |t|
30
+ create_table :extra_communications, force: true do |t|
31
31
  t.string :label
32
32
  t.string :value
33
33
  t.references :listing
34
34
  t.references :portal
35
- t.timestamps
35
+ t.timestamps null: false
36
36
  end
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenancy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chamnap Chhorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-06 00:00:00.000000000 Z
11
+ date: 2016-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -53,12 +53,14 @@ files:
53
53
  - ".travis.yml"
54
54
  - CHANGELOG.md
55
55
  - Gemfile
56
+ - Guardfile
56
57
  - LICENSE.txt
57
58
  - README.md
58
59
  - Rakefile
59
60
  - gemfiles/active_record_32.gemfile
60
61
  - gemfiles/active_record_40.gemfile
61
62
  - gemfiles/active_record_41.gemfile
63
+ - gemfiles/active_record_42.gemfile
62
64
  - gemfiles/mongoid_3.gemfile
63
65
  - gemfiles/mongoid_4.gemfile
64
66
  - lib/tenancy.rb
@@ -101,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
103
  version: 1.8.11
102
104
  requirements: []
103
105
  rubyforge_project:
104
- rubygems_version: 2.2.2
106
+ rubygems_version: 2.4.8
105
107
  signing_key:
106
108
  specification_version: 4
107
109
  summary: A simple multitenancy with activerecord/mongoid through scoping