acts_as 0.4.1 → 0.5.1

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: 3397b4833d35ad1b25dc61eca74ce2e5f195be35
4
- data.tar.gz: 666e31cb4d083c4dcbeca68248f0634e103cdb71
3
+ metadata.gz: 89ee132f5f8cffab67d1198b7945c2928fa959b6
4
+ data.tar.gz: e0ef62b4129e0cb33d704b38ae67b513d185c02f
5
5
  SHA512:
6
- metadata.gz: abfabc7cc32d04053b13b586de0e681de2c778038b9828d6f22e2ab07fc419e7efd4f9781596a2e3b5ec0ce3362d526b32ae2f008d0a535570c52350c17dbc8e
7
- data.tar.gz: 8747b446a37e5e96a17bc69696114ddfc6502266c370f4cde47860bed133819d3ac5b4102c7497431ff200a8ad167b5c04cea6543bb5165dc811f1b68cd5afa4
6
+ metadata.gz: 3dc2de54feadd3e34651bce9a7bbe1c32bbb66fa67d5546f2fb8cfd6deac2a7d45ba2733c55418ce3eff0be4a61248731cfab2a5168708b560f8e38412d400a4
7
+ data.tar.gz: e8b230d0042246afc72bda29b4a8771d685533607e70e94e92a0b089b131fa4486c229f5de21fef904ec86923d8804459a05778c9f28283878702b142d8528ab
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ group :test do
10
10
  gem 'pry'
11
11
  gem 'rspec'
12
12
  gem 'sqlite3'
13
+ gem 'strong_parameters'
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAs
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.1"
3
3
  end
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
- attr_accessible *association_fields
107
- attr_accessible *prefix.map { |field| "#{one_association}_#{field}" }
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
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'pry'
4
+ require 'strong_parameters'
4
5
 
5
6
  require 'acts_as'
6
7
 
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.1
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: 2013-07-09 00:00:00.000000000 Z
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.0.0
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