activerecord-multi-tenant 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea9a26a7764b461bb053cb77385d032b68bec003
4
- data.tar.gz: eb41e371832c04765affa48b9e484a604f35cef8
3
+ metadata.gz: 016f85503236d02b8e0c0c91d48d1b1ea1be8090
4
+ data.tar.gz: 98d861ee98e2453899c43ca479d40e0d3c072ad9
5
5
  SHA512:
6
- metadata.gz: 31f075981d9b3f2bddc22648942c18425ecd8a30f78a4fb8535ece940c86461e7804f2c39f68b8fd01070e417234b8d54694de8fb803930ab8acbddd0952dcb3
7
- data.tar.gz: c4e6b9305116e24a783db3efa200b952154976224411738a357bfbf6c084ea623f94382ae4f0d6bce8d1b194cde89733a5106401074ae6c2d55a7b4be9c5cf62
6
+ metadata.gz: c543e92bfaa83071358e43ee2fef050c0cd4692ef5a64b4e7a6fe5011a697e103e7e5b82b54314a937ea7f47a6fa6fda2516fac34419a4b42d609ce429642454
7
+ data.tar.gz: cb09591190ce05fc3737f71716b6d9850d4613b23baaa9f1967905413be8d32941de64be30c23b466f41f8c2bb9c033d5e1e3ff91c2571068de4aa9cabc97a5a
data/.travis.yml CHANGED
@@ -14,7 +14,9 @@ gemfile:
14
14
  - gemfiles/rails_4.2.gemfile
15
15
  - gemfiles/rails_5.0.gemfile
16
16
  - gemfiles/rails_5.1.gemfile
17
+ - gemfiles/rails_5.2.gemfile
17
18
  - gemfiles/active_record_5.1.gemfile
19
+ - gemfiles/active_record_5.2.gemfile
18
20
 
19
21
  matrix:
20
22
  fast_finish: true
@@ -29,7 +31,6 @@ services:
29
31
 
30
32
  before_install:
31
33
  - docker-compose up -d
32
- - sleep 5 # wait for postgres to become available
33
34
 
34
35
  script:
35
36
  - bundle exec rake spec
data/Appraisals CHANGED
@@ -18,6 +18,14 @@ appraise 'rails-5.1' do
18
18
  gem 'rails', '5.1.0'
19
19
  end
20
20
 
21
+ appraise 'rails-5.2' do
22
+ gem 'rails', '5.2.0'
23
+ end
24
+
21
25
  appraise 'active-record-5.1' do
22
26
  gem 'activerecord', '5.1.0'
23
27
  end
28
+
29
+ appraise 'active-record-5.2' do
30
+ gem 'activerecord', '5.2.0'
31
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0 2018-06-22
4
+
5
+ * ActiveRecord 5.2 support [Nathan Stitt](https://github.com/nathanstitt) & [osyo-manga](https://github.com/osyo-manga)
6
+
7
+
3
8
  ## 0.8.1 2017-10-06
4
9
 
5
10
  * Cast attribute name to a string to avoid double applying tenant clause [Ben Olive](https://github.com/sionide21)
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -57,22 +57,20 @@ GEM
57
57
  connection_pool (2.2.1)
58
58
  diff-lcs (1.2.5)
59
59
  erubis (2.7.0)
60
- globalid (0.4.0)
60
+ globalid (0.4.1)
61
61
  activesupport (>= 4.2.0)
62
62
  i18n (0.7.0)
63
63
  loofah (2.0.3)
64
64
  nokogiri (>= 1.5.9)
65
- mail (2.6.6)
66
- mime-types (>= 1.16, < 4)
65
+ mail (2.7.0)
66
+ mini_mime (>= 0.1.1)
67
67
  method_source (0.8.2)
68
- mime-types (3.1)
69
- mime-types-data (~> 3.2015)
70
- mime-types-data (3.2016.0521)
71
- mini_portile2 (2.1.0)
68
+ mini_mime (1.0.0)
69
+ mini_portile2 (2.3.0)
72
70
  minitest (5.10.1)
73
71
  nio4r (1.2.1)
74
- nokogiri (1.7.0)
75
- mini_portile2 (~> 2.1.0)
72
+ nokogiri (1.8.2)
73
+ mini_portile2 (~> 2.3.0)
76
74
  pg (0.19.0)
77
75
  pry (0.10.4)
78
76
  coderay (~> 1.1.0)
@@ -81,8 +79,8 @@ GEM
81
79
  pry-byebug (3.4.2)
82
80
  byebug (~> 9.0)
83
81
  pry (~> 0.10)
84
- rack (2.0.1)
85
- rack-protection (1.5.3)
82
+ rack (2.0.4)
83
+ rack-protection (2.0.1)
86
84
  rack
87
85
  rack-test (0.6.3)
88
86
  rack (>= 1.0)
@@ -111,7 +109,8 @@ GEM
111
109
  thor (>= 0.18.1, < 2.0)
112
110
  rake (12.0.0)
113
111
  redis (3.3.3)
114
- request_store (1.3.2)
112
+ request_store (1.4.1)
113
+ rack (>= 1.4)
115
114
  rspec (3.5.0)
116
115
  rspec-core (~> 3.5.0)
117
116
  rspec-expectations (~> 3.5.0)
@@ -142,7 +141,7 @@ GEM
142
141
  sprockets (3.7.1)
143
142
  concurrent-ruby (~> 1.0)
144
143
  rack (> 1, < 3)
145
- sprockets-rails (3.2.0)
144
+ sprockets-rails (3.2.1)
146
145
  actionpack (>= 4.0)
147
146
  activesupport (>= 4.0)
148
147
  sprockets (>= 3.0.0)
@@ -152,7 +151,7 @@ GEM
152
151
  thread_safe (~> 0.1)
153
152
  websocket-driver (0.6.5)
154
153
  websocket-extensions (>= 0.1.0)
155
- websocket-extensions (0.1.2)
154
+ websocket-extensions (0.1.3)
156
155
 
157
156
  PLATFORMS
158
157
  ruby
@@ -170,4 +169,4 @@ DEPENDENCIES
170
169
  thor
171
170
 
172
171
  BUNDLED WITH
173
- 1.15.3
172
+ 1.16.1
data/README.md CHANGED
@@ -37,7 +37,6 @@ end
37
37
  class Site < ActiveRecord::Base
38
38
  multi_tenant :customer
39
39
  has_many :page_views
40
- belongs_to :customer
41
40
 
42
41
  # ...
43
42
  end
@@ -101,4 +100,4 @@ This gem was initially based on [acts_as_tenant](https://github.com/ErwinM/acts_
101
100
  ## License
102
101
 
103
102
  Licensed under the MIT license<br>
104
- Copyright (c) 2017, Citus Data Inc.
103
+ Copyright (c) 2018, Citus Data Inc.
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.license = 'MIT'
17
17
 
18
18
  s.add_runtime_dependency('request_store', '>= 1.0.5')
19
- s.add_dependency('rails','>= 3.1')
19
+ s.add_dependency('rails','>= 4.0')
20
20
 
21
21
  s.add_development_dependency 'rspec', '>= 3.0'
22
22
  s.add_development_dependency 'rspec-rails'
data/docker-compose.yml CHANGED
@@ -2,20 +2,20 @@ version: '2.1'
2
2
 
3
3
  services:
4
4
  master:
5
- image: 'citusdata/citus:7.0.1'
6
- ports: ['5600:5432']
5
+ container_name: "${COMPOSE_PROJECT_NAME:-citus}_master"
6
+ image: 'citusdata/citus:7.4.1'
7
+ ports: ["5600:5432"]
7
8
  labels: ['com.citusdata.role=Master']
8
- volumes: ['/var/run/postgresql']
9
9
  worker1:
10
- image: 'citusdata/citus:7.0.1'
10
+ image: 'citusdata/citus:7.4.1'
11
11
  labels: ['com.citusdata.role=Worker']
12
12
  depends_on: { manager: { condition: service_healthy } }
13
13
  worker2:
14
- image: 'citusdata/citus:7.0.1'
14
+ image: 'citusdata/citus:7.4.1'
15
15
  labels: ['com.citusdata.role=Worker']
16
16
  depends_on: { manager: { condition: service_healthy } }
17
17
  manager:
18
18
  container_name: "${COMPOSE_PROJECT_NAME:-citus}_manager"
19
- image: 'citusdata/membership-manager:0.1.0'
19
+ image: 'citusdata/membership-manager:0.2.0'
20
20
  volumes: ['/var/run/docker.sock:/var/run/docker.sock']
21
21
  depends_on: { master: { condition: service_healthy } }
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -57,20 +57,18 @@ GEM
57
57
  connection_pool (2.2.1)
58
58
  diff-lcs (1.3)
59
59
  erubi (1.6.0)
60
- globalid (0.4.0)
60
+ globalid (0.4.1)
61
61
  activesupport (>= 4.2.0)
62
62
  i18n (0.8.1)
63
63
  loofah (2.0.3)
64
64
  nokogiri (>= 1.5.9)
65
- mail (2.6.6)
66
- mime-types (>= 1.16, < 4)
65
+ mail (2.7.0)
66
+ mini_mime (>= 0.1.1)
67
67
  method_source (0.8.2)
68
- mime-types (3.1)
69
- mime-types-data (~> 3.2015)
70
- mime-types-data (3.2016.0521)
68
+ mini_mime (1.0.0)
71
69
  mini_portile2 (2.1.0)
72
70
  minitest (5.10.1)
73
- nio4r (2.1.0)
71
+ nio4r (2.3.0)
74
72
  nokogiri (1.7.1)
75
73
  mini_portile2 (~> 2.1.0)
76
74
  pg (0.20.0)
@@ -81,7 +79,7 @@ GEM
81
79
  pry-byebug (3.4.2)
82
80
  byebug (~> 9.0)
83
81
  pry (~> 0.10)
84
- rack (2.0.1)
82
+ rack (2.0.5)
85
83
  rack-protection (1.5.3)
86
84
  rack
87
85
  rack-test (0.6.3)
@@ -111,7 +109,8 @@ GEM
111
109
  thor (>= 0.18.1, < 2.0)
112
110
  rake (12.0.0)
113
111
  redis (3.3.3)
114
- request_store (1.3.2)
112
+ request_store (1.4.1)
113
+ rack (>= 1.4)
115
114
  rspec (3.6.0)
116
115
  rspec-core (~> 3.6.0)
117
116
  rspec-expectations (~> 3.6.0)
@@ -142,7 +141,7 @@ GEM
142
141
  sprockets (3.7.1)
143
142
  concurrent-ruby (~> 1.0)
144
143
  rack (> 1, < 3)
145
- sprockets-rails (3.2.0)
144
+ sprockets-rails (3.2.1)
146
145
  actionpack (>= 4.0)
147
146
  activesupport (>= 4.0)
148
147
  sprockets (>= 3.0.0)
@@ -152,7 +151,7 @@ GEM
152
151
  thread_safe (~> 0.1)
153
152
  websocket-driver (0.6.5)
154
153
  websocket-extensions (>= 0.1.0)
155
- websocket-extensions (0.1.2)
154
+ websocket-extensions (0.1.3)
156
155
 
157
156
  PLATFORMS
158
157
  ruby
@@ -171,4 +170,4 @@ DEPENDENCIES
171
170
  thor
172
171
 
173
172
  BUNDLED WITH
174
- 1.15.3
173
+ 1.16.1
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "activerecord", "5.2.0"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,182 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
+ request_store (>= 1.0.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (5.2.0)
12
+ actionpack (= 5.2.0)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.0)
16
+ actionpack (= 5.2.0)
17
+ actionview (= 5.2.0)
18
+ activejob (= 5.2.0)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.2.0)
22
+ actionview (= 5.2.0)
23
+ activesupport (= 5.2.0)
24
+ rack (~> 2.0)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.2.0)
29
+ activesupport (= 5.2.0)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (5.2.0)
35
+ activesupport (= 5.2.0)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.2.0)
38
+ activesupport (= 5.2.0)
39
+ activerecord (5.2.0)
40
+ activemodel (= 5.2.0)
41
+ activesupport (= 5.2.0)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.0)
44
+ actionpack (= 5.2.0)
45
+ activerecord (= 5.2.0)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.0)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (>= 0.7, < 2)
50
+ minitest (~> 5.1)
51
+ tzinfo (~> 1.1)
52
+ appraisal (2.2.0)
53
+ bundler
54
+ rake
55
+ thor (>= 0.14.0)
56
+ arel (9.0.0)
57
+ builder (3.2.3)
58
+ byebug (10.0.2)
59
+ coderay (1.1.2)
60
+ concurrent-ruby (1.0.5)
61
+ connection_pool (2.2.2)
62
+ crass (1.0.4)
63
+ diff-lcs (1.3)
64
+ erubi (1.7.1)
65
+ globalid (0.4.1)
66
+ activesupport (>= 4.2.0)
67
+ i18n (1.0.1)
68
+ concurrent-ruby (~> 1.0)
69
+ loofah (2.2.2)
70
+ crass (~> 1.0.2)
71
+ nokogiri (>= 1.5.9)
72
+ mail (2.7.0)
73
+ mini_mime (>= 0.1.1)
74
+ marcel (0.3.2)
75
+ mimemagic (~> 0.3.2)
76
+ method_source (0.9.0)
77
+ mimemagic (0.3.2)
78
+ mini_mime (1.0.0)
79
+ mini_portile2 (2.3.0)
80
+ minitest (5.11.3)
81
+ nio4r (2.3.1)
82
+ nokogiri (1.8.2)
83
+ mini_portile2 (~> 2.3.0)
84
+ pg (1.0.0)
85
+ pry (0.11.3)
86
+ coderay (~> 1.1.0)
87
+ method_source (~> 0.9.0)
88
+ pry-byebug (3.6.0)
89
+ byebug (~> 10.0)
90
+ pry (~> 0.10)
91
+ rack (2.0.5)
92
+ rack-protection (2.0.3)
93
+ rack
94
+ rack-test (1.0.0)
95
+ rack (>= 1.0, < 3)
96
+ rails (5.2.0)
97
+ actioncable (= 5.2.0)
98
+ actionmailer (= 5.2.0)
99
+ actionpack (= 5.2.0)
100
+ actionview (= 5.2.0)
101
+ activejob (= 5.2.0)
102
+ activemodel (= 5.2.0)
103
+ activerecord (= 5.2.0)
104
+ activestorage (= 5.2.0)
105
+ activesupport (= 5.2.0)
106
+ bundler (>= 1.3.0)
107
+ railties (= 5.2.0)
108
+ sprockets-rails (>= 2.0.0)
109
+ rails-dom-testing (2.0.3)
110
+ activesupport (>= 4.2.0)
111
+ nokogiri (>= 1.6)
112
+ rails-html-sanitizer (1.0.4)
113
+ loofah (~> 2.2, >= 2.2.2)
114
+ railties (5.2.0)
115
+ actionpack (= 5.2.0)
116
+ activesupport (= 5.2.0)
117
+ method_source
118
+ rake (>= 0.8.7)
119
+ thor (>= 0.18.1, < 2.0)
120
+ rake (12.3.1)
121
+ redis (4.0.1)
122
+ request_store (1.4.1)
123
+ rack (>= 1.4)
124
+ rspec (3.7.0)
125
+ rspec-core (~> 3.7.0)
126
+ rspec-expectations (~> 3.7.0)
127
+ rspec-mocks (~> 3.7.0)
128
+ rspec-core (3.7.1)
129
+ rspec-support (~> 3.7.0)
130
+ rspec-expectations (3.7.0)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.7.0)
133
+ rspec-mocks (3.7.0)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.7.0)
136
+ rspec-rails (3.7.2)
137
+ actionpack (>= 3.0)
138
+ activesupport (>= 3.0)
139
+ railties (>= 3.0)
140
+ rspec-core (~> 3.7.0)
141
+ rspec-expectations (~> 3.7.0)
142
+ rspec-mocks (~> 3.7.0)
143
+ rspec-support (~> 3.7.0)
144
+ rspec-support (3.7.1)
145
+ sidekiq (5.1.3)
146
+ concurrent-ruby (~> 1.0)
147
+ connection_pool (~> 2.2, >= 2.2.0)
148
+ rack-protection (>= 1.5.0)
149
+ redis (>= 3.3.5, < 5)
150
+ sprockets (3.7.2)
151
+ concurrent-ruby (~> 1.0)
152
+ rack (> 1, < 3)
153
+ sprockets-rails (3.2.1)
154
+ actionpack (>= 4.0)
155
+ activesupport (>= 4.0)
156
+ sprockets (>= 3.0.0)
157
+ thor (0.20.0)
158
+ thread_safe (0.3.6)
159
+ tzinfo (1.2.5)
160
+ thread_safe (~> 0.1)
161
+ websocket-driver (0.7.0)
162
+ websocket-extensions (>= 0.1.0)
163
+ websocket-extensions (0.1.3)
164
+
165
+ PLATFORMS
166
+ ruby
167
+
168
+ DEPENDENCIES
169
+ activerecord (= 5.2.0)
170
+ activerecord-multi-tenant!
171
+ appraisal
172
+ pg
173
+ pry
174
+ pry-byebug
175
+ rake
176
+ rspec (>= 3.0)
177
+ rspec-rails
178
+ sidekiq
179
+ thor
180
+
181
+ BUNDLED WITH
182
+ 1.16.1
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -81,7 +81,8 @@ GEM
81
81
  thor (>= 0.18.1, < 2.0)
82
82
  rake (12.0.0)
83
83
  redis (3.3.3)
84
- request_store (1.3.2)
84
+ request_store (1.4.1)
85
+ rack (>= 1.4)
85
86
  rspec (3.5.0)
86
87
  rspec-core (~> 3.5.0)
87
88
  rspec-expectations (~> 3.5.0)
@@ -137,4 +138,4 @@ DEPENDENCIES
137
138
  thor
138
139
 
139
140
  BUNDLED WITH
140
- 1.15.3
141
+ 1.16.1
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -85,7 +85,8 @@ GEM
85
85
  thor (>= 0.18.1, < 2.0)
86
86
  rake (12.0.0)
87
87
  redis (3.3.3)
88
- request_store (1.3.2)
88
+ request_store (1.4.1)
89
+ rack (>= 1.4)
89
90
  rspec (3.5.0)
90
91
  rspec-core (~> 3.5.0)
91
92
  rspec-expectations (~> 3.5.0)
@@ -142,4 +143,4 @@ DEPENDENCIES
142
143
  thor
143
144
 
144
145
  BUNDLED WITH
145
- 1.15.3
146
+ 1.16.1
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -108,7 +108,8 @@ GEM
108
108
  thor (>= 0.18.1, < 2.0)
109
109
  rake (12.0.0)
110
110
  redis (3.3.3)
111
- request_store (1.3.2)
111
+ request_store (1.4.1)
112
+ rack (>= 1.4)
112
113
  rspec (3.5.0)
113
114
  rspec-core (~> 3.5.0)
114
115
  rspec-expectations (~> 3.5.0)
@@ -165,4 +166,4 @@ DEPENDENCIES
165
166
  thor
166
167
 
167
168
  BUNDLED WITH
168
- 1.15.3
169
+ 1.16.1
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -111,7 +111,8 @@ GEM
111
111
  thor (>= 0.18.1, < 2.0)
112
112
  rake (12.0.0)
113
113
  redis (3.3.3)
114
- request_store (1.3.2)
114
+ request_store (1.4.1)
115
+ rack (>= 1.4)
115
116
  rspec (3.5.0)
116
117
  rspec-core (~> 3.5.0)
117
118
  rspec-expectations (~> 3.5.0)
@@ -171,4 +172,4 @@ DEPENDENCIES
171
172
  thor
172
173
 
173
174
  BUNDLED WITH
174
- 1.15.3
175
+ 1.16.1
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-multi-tenant (0.8.1)
5
- rails (>= 3.1)
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
6
  request_store (>= 1.0.5)
7
7
 
8
8
  GEM
@@ -111,7 +111,8 @@ GEM
111
111
  thor (>= 0.18.1, < 2.0)
112
112
  rake (12.0.0)
113
113
  redis (3.3.3)
114
- request_store (1.3.2)
114
+ request_store (1.4.1)
115
+ rack (>= 1.4)
115
116
  rspec (3.6.0)
116
117
  rspec-core (~> 3.6.0)
117
118
  rspec-expectations (~> 3.6.0)
@@ -171,4 +172,4 @@ DEPENDENCIES
171
172
  thor
172
173
 
173
174
  BUNDLED WITH
174
- 1.15.3
175
+ 1.16.1
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "5.2.0"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,182 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ activerecord-multi-tenant (0.9.0)
5
+ rails (>= 4.0)
6
+ request_store (>= 1.0.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (5.2.0)
12
+ actionpack (= 5.2.0)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.0)
16
+ actionpack (= 5.2.0)
17
+ actionview (= 5.2.0)
18
+ activejob (= 5.2.0)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.2.0)
22
+ actionview (= 5.2.0)
23
+ activesupport (= 5.2.0)
24
+ rack (~> 2.0)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.2.0)
29
+ activesupport (= 5.2.0)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (5.2.0)
35
+ activesupport (= 5.2.0)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.2.0)
38
+ activesupport (= 5.2.0)
39
+ activerecord (5.2.0)
40
+ activemodel (= 5.2.0)
41
+ activesupport (= 5.2.0)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.0)
44
+ actionpack (= 5.2.0)
45
+ activerecord (= 5.2.0)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.0)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (>= 0.7, < 2)
50
+ minitest (~> 5.1)
51
+ tzinfo (~> 1.1)
52
+ appraisal (2.2.0)
53
+ bundler
54
+ rake
55
+ thor (>= 0.14.0)
56
+ arel (9.0.0)
57
+ builder (3.2.3)
58
+ byebug (10.0.2)
59
+ coderay (1.1.2)
60
+ concurrent-ruby (1.0.5)
61
+ connection_pool (2.2.1)
62
+ crass (1.0.4)
63
+ diff-lcs (1.3)
64
+ erubi (1.7.1)
65
+ globalid (0.4.1)
66
+ activesupport (>= 4.2.0)
67
+ i18n (1.0.0)
68
+ concurrent-ruby (~> 1.0)
69
+ loofah (2.2.2)
70
+ crass (~> 1.0.2)
71
+ nokogiri (>= 1.5.9)
72
+ mail (2.7.0)
73
+ mini_mime (>= 0.1.1)
74
+ marcel (0.3.2)
75
+ mimemagic (~> 0.3.2)
76
+ method_source (0.9.0)
77
+ mimemagic (0.3.2)
78
+ mini_mime (1.0.0)
79
+ mini_portile2 (2.3.0)
80
+ minitest (5.11.3)
81
+ nio4r (2.3.0)
82
+ nokogiri (1.8.2)
83
+ mini_portile2 (~> 2.3.0)
84
+ pg (1.0.0)
85
+ pry (0.11.3)
86
+ coderay (~> 1.1.0)
87
+ method_source (~> 0.9.0)
88
+ pry-byebug (3.6.0)
89
+ byebug (~> 10.0)
90
+ pry (~> 0.10)
91
+ rack (2.0.5)
92
+ rack-protection (2.0.1)
93
+ rack
94
+ rack-test (1.0.0)
95
+ rack (>= 1.0, < 3)
96
+ rails (5.2.0)
97
+ actioncable (= 5.2.0)
98
+ actionmailer (= 5.2.0)
99
+ actionpack (= 5.2.0)
100
+ actionview (= 5.2.0)
101
+ activejob (= 5.2.0)
102
+ activemodel (= 5.2.0)
103
+ activerecord (= 5.2.0)
104
+ activestorage (= 5.2.0)
105
+ activesupport (= 5.2.0)
106
+ bundler (>= 1.3.0)
107
+ railties (= 5.2.0)
108
+ sprockets-rails (>= 2.0.0)
109
+ rails-dom-testing (2.0.3)
110
+ activesupport (>= 4.2.0)
111
+ nokogiri (>= 1.6)
112
+ rails-html-sanitizer (1.0.4)
113
+ loofah (~> 2.2, >= 2.2.2)
114
+ railties (5.2.0)
115
+ actionpack (= 5.2.0)
116
+ activesupport (= 5.2.0)
117
+ method_source
118
+ rake (>= 0.8.7)
119
+ thor (>= 0.18.1, < 2.0)
120
+ rake (12.3.1)
121
+ redis (4.0.1)
122
+ request_store (1.4.1)
123
+ rack (>= 1.4)
124
+ rspec (3.7.0)
125
+ rspec-core (~> 3.7.0)
126
+ rspec-expectations (~> 3.7.0)
127
+ rspec-mocks (~> 3.7.0)
128
+ rspec-core (3.7.1)
129
+ rspec-support (~> 3.7.0)
130
+ rspec-expectations (3.7.0)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.7.0)
133
+ rspec-mocks (3.7.0)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.7.0)
136
+ rspec-rails (3.7.2)
137
+ actionpack (>= 3.0)
138
+ activesupport (>= 3.0)
139
+ railties (>= 3.0)
140
+ rspec-core (~> 3.7.0)
141
+ rspec-expectations (~> 3.7.0)
142
+ rspec-mocks (~> 3.7.0)
143
+ rspec-support (~> 3.7.0)
144
+ rspec-support (3.7.1)
145
+ sidekiq (5.1.3)
146
+ concurrent-ruby (~> 1.0)
147
+ connection_pool (~> 2.2, >= 2.2.0)
148
+ rack-protection (>= 1.5.0)
149
+ redis (>= 3.3.5, < 5)
150
+ sprockets (3.7.1)
151
+ concurrent-ruby (~> 1.0)
152
+ rack (> 1, < 3)
153
+ sprockets-rails (3.2.1)
154
+ actionpack (>= 4.0)
155
+ activesupport (>= 4.0)
156
+ sprockets (>= 3.0.0)
157
+ thor (0.20.0)
158
+ thread_safe (0.3.6)
159
+ tzinfo (1.2.5)
160
+ thread_safe (~> 0.1)
161
+ websocket-driver (0.7.0)
162
+ websocket-extensions (>= 0.1.0)
163
+ websocket-extensions (0.1.3)
164
+
165
+ PLATFORMS
166
+ ruby
167
+
168
+ DEPENDENCIES
169
+ activerecord-multi-tenant!
170
+ appraisal
171
+ pg
172
+ pry
173
+ pry-byebug
174
+ rails (= 5.2.0)
175
+ rake
176
+ rspec (>= 3.0)
177
+ rspec-rails
178
+ sidekiq
179
+ thor
180
+
181
+ BUNDLED WITH
182
+ 1.16.1
@@ -5,6 +5,11 @@ module MultiTenant
5
5
  execute "SELECT create_distributed_table($$#{table_name}$$, $$#{partition_key}$$)"
6
6
  end
7
7
 
8
+ def create_reference_table(table_name)
9
+ return unless citus_version.present?
10
+ execute "SELECT create_reference_table($$#{table_name}$$)"
11
+ end
12
+
8
13
  def execute_on_all_nodes(sql)
9
14
  execute sql
10
15
 
@@ -29,6 +29,7 @@ module MultiTenant
29
29
  @@multi_tenant_models[table_name.to_s] = model_klass
30
30
  end
31
31
  def self.multi_tenant_model_for_table(table_name)
32
+ @@multi_tenant_models ||= {}
32
33
  @@multi_tenant_models[table_name.to_s]
33
34
  end
34
35
 
@@ -189,7 +189,7 @@ module MultiTenant
189
189
  def join_to_update(update, *args)
190
190
  update = super(update, *args)
191
191
  model = MultiTenant.multi_tenant_model_for_table(update.ast.relation.table_name)
192
- if model.present?
192
+ if model.present? && !MultiTenant.with_write_only_mode_enabled?
193
193
  update.where(MultiTenant::TenantEnforcementClause.new(model.arel_table[model.partition_key]))
194
194
  end
195
195
  update
@@ -198,11 +198,29 @@ module MultiTenant
198
198
  def join_to_delete(delete, *args)
199
199
  delete = super(delete, *args)
200
200
  model = MultiTenant.multi_tenant_model_for_table(delete.ast.left.table_name)
201
- if model.present?
201
+ if model.present? && !MultiTenant.with_write_only_mode_enabled?
202
202
  delete.where(MultiTenant::TenantEnforcementClause.new(model.arel_table[model.partition_key]))
203
203
  end
204
204
  delete
205
205
  end
206
+
207
+ if ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 2
208
+ def update(arel, name = nil, binds = [])
209
+ model = MultiTenant.multi_tenant_model_for_table(arel.ast.relation.table_name)
210
+ if model.present? && !MultiTenant.with_write_only_mode_enabled?
211
+ arel.where(MultiTenant::TenantEnforcementClause.new(model.arel_table[model.partition_key]))
212
+ end
213
+ super(arel, name, binds)
214
+ end
215
+
216
+ def delete(arel, name = nil, binds = [])
217
+ model = MultiTenant.multi_tenant_model_for_table(arel.ast.left.table_name)
218
+ if model.present? && !MultiTenant.with_write_only_mode_enabled?
219
+ arel.where(MultiTenant::TenantEnforcementClause.new(model.arel_table[model.partition_key]))
220
+ end
221
+ super(arel, name, binds)
222
+ end
223
+ end
206
224
  end
207
225
  end
208
226
 
@@ -215,8 +233,8 @@ require 'active_record/relation'
215
233
  module ActiveRecord
216
234
  module QueryMethods
217
235
  alias :build_arel_orig :build_arel
218
- def build_arel
219
- arel = build_arel_orig
236
+ def build_arel(*args)
237
+ arel = build_arel_orig(*args)
220
238
 
221
239
  if MultiTenant.current_tenant_id && !MultiTenant.with_write_only_mode_enabled?
222
240
  visitor = MultiTenant::ArelTenantVisitor.new(arel)
@@ -1,3 +1,3 @@
1
1
  module MultiTenant
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -14,19 +14,48 @@ describe "Query Rewriter" do
14
14
  end
15
15
  }.to change { project.reload.name }.from("Project 1").to("New Name")
16
16
  end
17
+
18
+ it "update the record" do
19
+ expect {
20
+ MultiTenant.with(account) do
21
+ project.update(name: "New Name")
22
+ end
23
+ }.to change { project.reload.name }.from("Project 1").to("New Name")
24
+ end
17
25
  end
18
26
 
19
27
  context "when bulk deleting" do
20
28
  let!(:account) { Account.create!(name: "Test Account") }
21
- let!(:project) { Project.create(name: "Project 1", account: account) }
22
- let!(:manager) { Manager.create(name: "Manager", project: project, account: account) }
29
+ let!(:project1) { Project.create(name: "Project 1", account: account) }
30
+ let!(:project2) { Project.create(name: "Project 2", account: account) }
31
+ let!(:project3) { Project.create(name: "Project 3", account: account) }
32
+ let!(:manager1) { Manager.create(name: "Manager 1", project: project1, account: account) }
33
+ let!(:manager2) { Manager.create(name: "Manager 2", project: project2, account: account) }
23
34
 
24
- it "deletes the records" do
35
+ it "delete_all the records" do
25
36
  expect {
26
37
  MultiTenant.with(account) do
27
38
  Project.joins(:manager).delete_all
28
39
  end
29
- }.to change { Project.count }.from(1).to(0)
40
+ }.to change { Project.count }.from(3).to(1)
41
+ end
42
+
43
+ it "delete the record" do
44
+ expect {
45
+ MultiTenant.with(account) do
46
+ project1.delete
47
+ Project.delete(project2.id)
48
+ end
49
+ }.to change { Project.count }.from(3).to(1)
50
+ end
51
+
52
+ it "destroy the record" do
53
+ expect {
54
+ MultiTenant.with(account) do
55
+ project1.destroy
56
+ Project.destroy(project2.id)
57
+ end
58
+ }.to change { Project.count }.from(3).to(1)
30
59
  end
31
60
  end
32
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-multi-tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Citus Data
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-07 00:00:00.000000000 Z
11
+ date: 2018-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: request_store
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.1'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.1'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -168,6 +168,8 @@ files:
168
168
  - docker-compose.yml
169
169
  - gemfiles/active_record_5.1.gemfile
170
170
  - gemfiles/active_record_5.1.gemfile.lock
171
+ - gemfiles/active_record_5.2.gemfile
172
+ - gemfiles/active_record_5.2.gemfile.lock
171
173
  - gemfiles/rails_4.0.gemfile
172
174
  - gemfiles/rails_4.0.gemfile.lock
173
175
  - gemfiles/rails_4.1.gemfile
@@ -178,6 +180,8 @@ files:
178
180
  - gemfiles/rails_5.0.gemfile.lock
179
181
  - gemfiles/rails_5.1.gemfile
180
182
  - gemfiles/rails_5.1.gemfile.lock
183
+ - gemfiles/rails_5.2.gemfile
184
+ - gemfiles/rails_5.2.gemfile.lock
181
185
  - lib/activerecord-multi-tenant.rb
182
186
  - lib/activerecord-multi-tenant/controller_extensions.rb
183
187
  - lib/activerecord-multi-tenant/copy_from_client.rb