protector 0.6.3 → 0.6.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06ef70fc6fb353ebf794e6386d1f071f5561bf01
|
4
|
+
data.tar.gz: e566043d18cb952d1eff71144afaa1f50d7b2657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89d14e47526fbbe0b59f63467188db88ac0d7a02729370da0ff07a4938cd43c47d7fee7639cbd429f09a9020f5a93af5ac50d700414c178feb80f93197918fe8
|
7
|
+
data.tar.gz: 2e82a2ce1327e8f5573d7321ac481a2054850ddce6d5fde687362cda6525da3b31317cf23423ffea86d5116c1dff981e15c335d371086eedff033857276af679
|
@@ -37,6 +37,10 @@ module Protector
|
|
37
37
|
@klass.protector_meta.evaluate(subject)
|
38
38
|
end
|
39
39
|
|
40
|
+
def protector_relation
|
41
|
+
protector_meta.relation ? merge(protector_meta.relation) : clone
|
42
|
+
end
|
43
|
+
|
40
44
|
# @note Unscoped relation drops properties and therefore should be re-restricted
|
41
45
|
def unscoped
|
42
46
|
return super unless protector_subject?
|
@@ -66,13 +70,13 @@ module Protector
|
|
66
70
|
# Merges current relation with restriction and calls real `calculate`
|
67
71
|
def calculate(*args)
|
68
72
|
return super unless protector_subject?
|
69
|
-
|
73
|
+
protector_relation.unrestrict!.calculate *args
|
70
74
|
end
|
71
75
|
|
72
76
|
# Merges current relation with restriction and calls real `exists?`
|
73
77
|
def exists?(*args)
|
74
78
|
return super unless protector_subject?
|
75
|
-
|
79
|
+
protector_relation.unrestrict!.exists? *args
|
76
80
|
end
|
77
81
|
|
78
82
|
# Forwards protection subject to the new instance
|
@@ -117,7 +121,7 @@ module Protector
|
|
117
121
|
return exec_queries_without_protector unless protector_subject?
|
118
122
|
|
119
123
|
subject = protector_subject
|
120
|
-
relation =
|
124
|
+
relation = protector_relation.unrestrict!
|
121
125
|
relation = protector_substitute_includes(subject, relation)
|
122
126
|
|
123
127
|
# Preserve associations from internal loading. We are going to handle that
|
data/lib/protector/version.rb
CHANGED
@@ -16,8 +16,6 @@ if defined?(ActiveRecord)
|
|
16
16
|
scope{ where('1=0') }
|
17
17
|
elsif x == '+'
|
18
18
|
scope{ where(klass.table_name => {number: 999}) }
|
19
|
-
elsif !Protector.config.paranoid && Protector::Adapters::ActiveRecord.modern?
|
20
|
-
scope { all }
|
21
19
|
end
|
22
20
|
|
23
21
|
can :view, :dummy_id unless x == '-'
|
@@ -123,6 +121,7 @@ if defined?(ActiveRecord)
|
|
123
121
|
|
124
122
|
context "with open relation" do
|
125
123
|
context "adequate", paranoid: false do
|
124
|
+
|
126
125
|
it "checks existence" do
|
127
126
|
Dummy.any?.should == true
|
128
127
|
Dummy.restrict!('!').any?.should == true
|
@@ -130,7 +129,9 @@ if defined?(ActiveRecord)
|
|
130
129
|
|
131
130
|
it "counts" do
|
132
131
|
Dummy.count.should == 4
|
133
|
-
Dummy.restrict!('!')
|
132
|
+
dummy = Dummy.restrict!('!')
|
133
|
+
dummy.count.should == 4
|
134
|
+
dummy.protector_subject?.should == true
|
134
135
|
end
|
135
136
|
|
136
137
|
it "fetches" do
|
@@ -149,7 +150,9 @@ if defined?(ActiveRecord)
|
|
149
150
|
|
150
151
|
it "counts" do
|
151
152
|
Dummy.count.should == 4
|
152
|
-
Dummy.restrict!('!')
|
153
|
+
dummy = Dummy.restrict!('!')
|
154
|
+
dummy.count.should == 0
|
155
|
+
dummy.protector_subject?.should == true
|
153
156
|
end
|
154
157
|
|
155
158
|
it "fetches" do
|
@@ -169,7 +172,9 @@ if defined?(ActiveRecord)
|
|
169
172
|
|
170
173
|
it "counts" do
|
171
174
|
Dummy.count.should == 4
|
172
|
-
Dummy.restrict!('-')
|
175
|
+
dummy = Dummy.restrict!('-')
|
176
|
+
dummy.count.should == 0
|
177
|
+
dummy.protector_subject?.should == true
|
173
178
|
end
|
174
179
|
|
175
180
|
it "fetches" do
|
@@ -193,7 +198,9 @@ if defined?(ActiveRecord)
|
|
193
198
|
|
194
199
|
it "counts" do
|
195
200
|
Dummy.count.should == 4
|
196
|
-
Dummy.restrict!('+')
|
201
|
+
dummy = Dummy.restrict!('+')
|
202
|
+
dummy.count.should == 2
|
203
|
+
dummy.protector_subject?.should == true
|
197
204
|
end
|
198
205
|
|
199
206
|
it "fetches" do
|