protector 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/AR_3.2.gemfile.lock +1 -1
- data/gemfiles/AR_4.gemfile.lock +1 -1
- data/gemfiles/Sequel.gemfile.lock +1 -1
- data/lib/protector/adapters/active_record/relation.rb +6 -0
- data/lib/protector/version.rb +1 -1
- data/spec/lib/adapters/active_record_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e15f3c1ee4395642576ca756587e32adc363b461
|
4
|
+
data.tar.gz: f18f5e9a33d866c903e7f8be1db3425daa97ad67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61613c761e8e2193ed7d87521e1469af9fb9997f7bf0dc52f247302f179df8bbeee6f2eef3d636447d0cc250b706b819af88b2493e02e1c56b85f0a831e92eeb
|
7
|
+
data.tar.gz: 18fd32ceb5907097d297a61f73db4a2b0aa5fe306d606cd735e6796ac49fec7852758912a6745d5052e4e69f8ef864b6405c3fb9a907f78e6f81b31adac4a450
|
data/gemfiles/AR_4.gemfile.lock
CHANGED
@@ -9,6 +9,7 @@ module Protector
|
|
9
9
|
include Protector::DSL::Base
|
10
10
|
|
11
11
|
alias_method_chain :exec_queries, :protector
|
12
|
+
alias_method_chain :new, :protector
|
12
13
|
|
13
14
|
# AR 3.2 workaround. Come on, guys... SQL parsing :(
|
14
15
|
unless method_defined?(:references_values)
|
@@ -73,6 +74,11 @@ module Protector
|
|
73
74
|
merge(protector_meta.relation).unrestrict!.exists? *args
|
74
75
|
end
|
75
76
|
|
77
|
+
def new_with_protector(*args)
|
78
|
+
return new_without_protector unless protector_subject?
|
79
|
+
new_without_protector.restrict!(protector_subject)
|
80
|
+
end
|
81
|
+
|
76
82
|
# Patches current relation to fulfill restriction and call real `exec_queries`
|
77
83
|
#
|
78
84
|
# Patching includes:
|
data/lib/protector/version.rb
CHANGED
@@ -89,6 +89,7 @@ if defined?(ActiveRecord)
|
|
89
89
|
it "forwards subject" do
|
90
90
|
Dummy.restrict!('!').where(number: 999).first.protector_subject.should == '!'
|
91
91
|
Dummy.restrict!('!').where(number: 999).to_a.first.protector_subject.should == '!'
|
92
|
+
Dummy.restrict!('!').new.protector_subject.should == '!'
|
92
93
|
end
|
93
94
|
|
94
95
|
context "with open relation" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|