acts_as 0.4.1 → 0.5.1
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 +4 -4
- data/Gemfile +1 -0
- data/lib/acts_as/version.rb +1 -1
- data/lib/acts_as.rb +4 -2
- data/spec/acts_as_spec.rb +19 -0
- data/spec/spec_helper.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89ee132f5f8cffab67d1198b7945c2928fa959b6
|
4
|
+
data.tar.gz: e0ef62b4129e0cb33d704b38ae67b513d185c02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc2de54feadd3e34651bce9a7bbe1c32bbb66fa67d5546f2fb8cfd6deac2a7d45ba2733c55418ce3eff0be4a61248731cfab2a5168708b560f8e38412d400a4
|
7
|
+
data.tar.gz: e8b230d0042246afc72bda29b4a8771d685533607e70e94e92a0b089b131fa4486c229f5de21fef904ec86923d8804459a05778c9f28283878702b142d8528ab
|
data/Gemfile
CHANGED
data/lib/acts_as/version.rb
CHANGED
data/lib/acts_as.rb
CHANGED
@@ -103,8 +103,10 @@ module ActsAs
|
|
103
103
|
|
104
104
|
build_prefix_methods(one_association, prefix)
|
105
105
|
|
106
|
-
|
107
|
-
|
106
|
+
unless defined?(ActiveModel::ForbiddenAttributesProtection) && included_modules.include?(ActiveModel::ForbiddenAttributesProtection)
|
107
|
+
attr_accessible *association_fields
|
108
|
+
attr_accessible *prefix.map { |field| "#{one_association}_#{field}" }
|
109
|
+
end
|
108
110
|
|
109
111
|
delegate(*(association_fields + association_fields.map { |field| "#{field}=" }), to: one_association)
|
110
112
|
|
data/spec/acts_as_spec.rb
CHANGED
@@ -30,6 +30,11 @@ class Rebel < User
|
|
30
30
|
acts_as :clan, prefix: %w( name ), with: %w( delegate_at_will )
|
31
31
|
end
|
32
32
|
|
33
|
+
class RebelWithStrongParams < User
|
34
|
+
include ActiveModel::ForbiddenAttributesProtection
|
35
|
+
acts_as :clan, prefix: %w( name ), with: %w( delegate_at_will )
|
36
|
+
end
|
37
|
+
|
33
38
|
class Imperial < User
|
34
39
|
acts_as :profile, class_name: 'ImperialProfile'
|
35
40
|
end
|
@@ -115,6 +120,20 @@ describe ActsAs do
|
|
115
120
|
specify { rebel.should_not be_cool }
|
116
121
|
end
|
117
122
|
|
123
|
+
describe 'making things attr_accessible' do
|
124
|
+
context 'when strong_parameters is not being used' do
|
125
|
+
it 'automatically makes attrs accessible' do
|
126
|
+
Rebel.accessible_attributes.should include('clan_name')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when strong_parameters is being used' do
|
131
|
+
it 'does not use the attr_accessible api' do
|
132
|
+
RebelWithStrongParams.accessible_attributes.should be_empty
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
118
137
|
describe '#previous_changes' do
|
119
138
|
it 'should account for acted models' do
|
120
139
|
rebel.strength = 12
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winfred
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.1.11
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: delegate an entire 1:1 association worth of active record field-related helpers
|