sudo_attributes 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/Gemfile.lock +74 -2
- data/README.textile +4 -0
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/lib/sudo_attributes.rb +5 -0
- data/spec/sudo_attributes_spec.rb +13 -0
- data/sudo_attributes.gemspec +8 -5
- metadata +29 -13
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,96 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.3)
|
6
|
+
actionpack (= 3.0.3)
|
7
|
+
mail (~> 2.2.9)
|
8
|
+
actionpack (3.0.3)
|
9
|
+
activemodel (= 3.0.3)
|
10
|
+
activesupport (= 3.0.3)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.6)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.3)
|
19
|
+
activesupport (= 3.0.3)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.3)
|
23
|
+
activemodel (= 3.0.3)
|
24
|
+
activesupport (= 3.0.3)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.3)
|
28
|
+
activemodel (= 3.0.3)
|
29
|
+
activesupport (= 3.0.3)
|
30
|
+
activesupport (3.0.3)
|
31
|
+
arel (2.0.6)
|
32
|
+
builder (2.1.2)
|
33
|
+
diff-lcs (1.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
4
36
|
gemcutter (0.6.1)
|
5
37
|
git (1.2.5)
|
38
|
+
i18n (0.5.0)
|
6
39
|
jeweler (1.4.0)
|
7
40
|
gemcutter (>= 0.1.0)
|
8
41
|
git (>= 1.2.5)
|
9
42
|
rubyforge (>= 2.0.0)
|
10
43
|
json_pure (1.4.6)
|
44
|
+
mail (2.2.14)
|
45
|
+
activesupport (>= 2.3.6)
|
46
|
+
i18n (>= 0.4.0)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.16)
|
50
|
+
polyglot (0.3.1)
|
51
|
+
rack (1.2.1)
|
52
|
+
rack-mount (0.6.13)
|
53
|
+
rack (>= 1.0.0)
|
54
|
+
rack-test (0.5.7)
|
55
|
+
rack (>= 1.0)
|
56
|
+
rails (3.0.3)
|
57
|
+
actionmailer (= 3.0.3)
|
58
|
+
actionpack (= 3.0.3)
|
59
|
+
activerecord (= 3.0.3)
|
60
|
+
activeresource (= 3.0.3)
|
61
|
+
activesupport (= 3.0.3)
|
62
|
+
bundler (~> 1.0)
|
63
|
+
railties (= 3.0.3)
|
64
|
+
railties (3.0.3)
|
65
|
+
actionpack (= 3.0.3)
|
66
|
+
activesupport (= 3.0.3)
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (~> 0.14.4)
|
11
69
|
rake (0.8.7)
|
12
|
-
rspec (
|
70
|
+
rspec (2.0.1)
|
71
|
+
rspec-core (~> 2.0.1)
|
72
|
+
rspec-expectations (~> 2.0.1)
|
73
|
+
rspec-mocks (~> 2.0.1)
|
74
|
+
rspec-core (2.0.1)
|
75
|
+
rspec-expectations (2.0.1)
|
76
|
+
diff-lcs (>= 1.1.2)
|
77
|
+
rspec-mocks (2.0.1)
|
78
|
+
rspec-core (~> 2.0.1)
|
79
|
+
rspec-expectations (~> 2.0.1)
|
13
80
|
rubyforge (2.0.4)
|
14
81
|
json_pure (>= 1.1.7)
|
15
82
|
sqlite3-ruby (1.3.1)
|
83
|
+
thor (0.14.6)
|
84
|
+
treetop (1.4.9)
|
85
|
+
polyglot (>= 0.3.1)
|
86
|
+
tzinfo (0.3.23)
|
16
87
|
|
17
88
|
PLATFORMS
|
18
89
|
ruby
|
19
90
|
|
20
91
|
DEPENDENCIES
|
21
92
|
jeweler (= 1.4.0)
|
93
|
+
rails (~> 3.0.0)
|
22
94
|
rake
|
23
|
-
rspec (~>
|
95
|
+
rspec (~> 2.0.0)
|
24
96
|
sqlite3-ruby
|
data/README.textile
CHANGED
@@ -24,6 +24,9 @@ It's as easy as adding one method call to your models like so:
|
|
24
24
|
class User < ActiveRecord::Base
|
25
25
|
sudo_attr_protected :admin
|
26
26
|
end
|
27
|
+
|
28
|
+
user = User.find(params[:id])
|
29
|
+
user.sudo_update_attributes(params[:user])
|
27
30
|
</pre>
|
28
31
|
|
29
32
|
h2. Class Methods
|
@@ -51,6 +54,7 @@ h2. Instance Methods
|
|
51
54
|
The following instance method is available to any ActiveRecord model that calls @has_sudo_attributes@
|
52
55
|
|
53
56
|
* @sudo_update_attributes@ - Uses identical syntax to @update_attributes@, but overrides protected attributes.
|
57
|
+
* @sudo_update_attributes!@ - Same as sudo_update_attributes, but raises ActiveRecord errors. Same as @update_attributes!@
|
54
58
|
|
55
59
|
h2. Examples
|
56
60
|
|
data/Rakefile
CHANGED
@@ -10,7 +10,8 @@ begin
|
|
10
10
|
gem.email = "github@lette.us"
|
11
11
|
gem.homepage = "http://github.com/beerlington/sudo_attributes"
|
12
12
|
gem.authors = ["Peter Brown"]
|
13
|
-
gem.add_development_dependency "rspec", "
|
13
|
+
gem.add_development_dependency "rspec", "~> 2.0.0"
|
14
|
+
gem.add_development_dependency "rails", "~> 3.0.0"
|
14
15
|
gem.add_development_dependency "sqlite3-ruby"
|
15
16
|
gem.add_dependency "rails", ">= 2.3.0"
|
16
17
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/sudo_attributes.rb
CHANGED
@@ -32,6 +32,19 @@ describe "Cat" do
|
|
32
32
|
@cat.name.should == "Smiles"
|
33
33
|
end
|
34
34
|
|
35
|
+
it "should not raise an error with sudo_update_attributes" do
|
36
|
+
lambda { @cat.sudo_update_attributes(:color => "") }.should_not raise_error(ActiveRecord::RecordInvalid)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should set the name with sudo_update_attributes!" do
|
40
|
+
@cat.sudo_update_attributes!(:name => "Smiles")
|
41
|
+
@cat.name.should == "Smiles"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should raise an error with sudo_update_attributes!" do
|
45
|
+
lambda { @cat.sudo_update_attributes!(:color => "") }.should raise_error(ActiveRecord::RecordInvalid)
|
46
|
+
end
|
47
|
+
|
35
48
|
it "should have a color" do
|
36
49
|
@cat.color.should == @attributes[:color]
|
37
50
|
end
|
data/sudo_attributes.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sudo_attributes}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Peter Brown"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-12}
|
13
13
|
s.description = %q{Adds 'sudo' methods to update protected ActiveRecord attributes with mass assignment}
|
14
14
|
s.email = %q{github@lette.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,16 +47,19 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.specification_version = 3
|
48
48
|
|
49
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_development_dependency(%q<rspec>, ["
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
|
51
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.0"])
|
51
52
|
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
52
53
|
s.add_runtime_dependency(%q<rails>, [">= 2.3.0"])
|
53
54
|
else
|
54
|
-
s.add_dependency(%q<rspec>, ["
|
55
|
+
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
56
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
55
57
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
56
58
|
s.add_dependency(%q<rails>, [">= 2.3.0"])
|
57
59
|
end
|
58
60
|
else
|
59
|
-
s.add_dependency(%q<rspec>, ["
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
62
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
60
63
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
61
64
|
s.add_dependency(%q<rails>, [">= 2.3.0"])
|
62
65
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sudo_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Peter Brown
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-12 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,20 +24,36 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 15
|
30
30
|
segments:
|
31
|
-
- 1
|
32
31
|
- 2
|
33
|
-
-
|
34
|
-
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 2.0.0
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: rails
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 7
|
46
|
+
segments:
|
47
|
+
- 3
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 3.0.0
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: sqlite3-ruby
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
59
|
- - ">="
|
@@ -47,11 +63,11 @@ dependencies:
|
|
47
63
|
- 0
|
48
64
|
version: "0"
|
49
65
|
type: :development
|
50
|
-
version_requirements: *
|
66
|
+
version_requirements: *id003
|
51
67
|
- !ruby/object:Gem::Dependency
|
52
68
|
name: rails
|
53
69
|
prerelease: false
|
54
|
-
requirement: &
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
55
71
|
none: false
|
56
72
|
requirements:
|
57
73
|
- - ">="
|
@@ -63,7 +79,7 @@ dependencies:
|
|
63
79
|
- 0
|
64
80
|
version: 2.3.0
|
65
81
|
type: :runtime
|
66
|
-
version_requirements: *
|
82
|
+
version_requirements: *id004
|
67
83
|
description: Adds 'sudo' methods to update protected ActiveRecord attributes with mass assignment
|
68
84
|
email: github@lette.us
|
69
85
|
executables: []
|