Skip to content
This repository
Browse code

Merge pull request #61 from grosser/rails30

support and test rails 3.0
  • Loading branch information...
commit 3996cf86a1a4b5b3ac2ef3f56e219042b30fe21e 2 parents 8cd920b + 3e03b9c
Rafael Mendonça França rafaelfranca authored
1  .travis.yml
@@ -6,6 +6,7 @@ rvm:
6 6 - 1.9.3
7 7
8 8 gemfile:
  9 + - test/gemfiles/Gemfile.rails-3.0.x
9 10 - test/gemfiles/Gemfile.rails-3.1.x
10 11 - test/gemfiles/Gemfile.rails-3.2.x
11 12
8 Gemfile.lock
@@ -2,9 +2,9 @@ PATH
2 2 remote: .
3 3 specs:
4 4 strong_parameters (0.1.6.dev)
5   - actionpack (~> 3.1)
6   - activemodel (~> 3.1)
7   - railties (~> 3.1)
  5 + actionpack (~> 3.0)
  6 + activemodel (~> 3.0)
  7 + railties (~> 3.0)
8 8
9 9 GEM
10 10 remote: http://rubygems.org/
@@ -34,7 +34,7 @@ GEM
34 34 metaclass (0.0.1)
35 35 mocha (0.12.0)
36 36 metaclass (~> 0.0.1)
37   - multi_json (1.3.6)
  37 + multi_json (1.3.7)
38 38 rack (1.4.1)
39 39 rack-cache (1.2)
40 40 rack (>= 0.4)
4 README.rdoc
Source Rendered
@@ -52,8 +52,8 @@ If you want to now disable the default whitelisting that occurs in later version
52 52
53 53 config.active_record.whitelist_attributes = false
54 54
55   -This will allow you to remove / not have to use +attr_accessible+ and do mass assignment inside your code and tests.
  55 +This will allow you to remove / not have to use +attr_accessible+ and do mass assignment inside your code and tests.
56 56
57 57 == Compatibility
58 58
59   -This plugin is only fully compatible with Rails versions 3.1 and 3.2 but not 4.0+, as it is part of Rails Core in 4.0.
  59 +This plugin is only fully compatible with Rails versions 3.0, 3.1 and 3.2 but not 4.0+, as it is part of Rails Core in 4.0.
3  lib/action_controller/parameters.rb
@@ -83,7 +83,8 @@ def slice(*keys)
83 83 end
84 84
85 85 def dup
86   - super.tap do |duplicate|
  86 + self.class.new(self).tap do |duplicate|
  87 + duplicate.default = default
87 88 duplicate.instance_variable_set :@permitted, @permitted
88 89 end
89 90 end
3  lib/active_model/forbidden_attributes_protection.rb
@@ -3,7 +3,8 @@ class ForbiddenAttributes < StandardError
3 3 end
4 4
5 5 module ForbiddenAttributesProtection
6   - def sanitize_for_mass_assignment(new_attributes, options = {})
  6 + def sanitize_for_mass_assignment(*options)
  7 + new_attributes = options.first
7 8 if !new_attributes.respond_to?(:permitted?) || new_attributes.permitted?
8 9 super
9 10 else
7 lib/generators/rails/strong_parameters_controller_generator.rb
... ... @@ -1,3 +1,4 @@
  1 +require 'rails/version'
1 2 require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
2 3
3 4 module Rails
@@ -5,6 +6,12 @@ module Generators
5 6 class StrongParametersControllerGenerator < ScaffoldControllerGenerator
6 7 argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7 8 source_root File.expand_path("../templates", __FILE__)
  9 +
  10 + if ::Rails::VERSION::STRING < '3.1'
  11 + def module_namespacing
  12 + yield if block_given?
  13 + end
  14 + end
8 15 end
9 16 end
10 17 end
6 strong_parameters.gemspec
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14 14 s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
15 15 s.test_files = Dir["test/**/*"]
16 16
17   - s.add_dependency "actionpack", "~> 3.1"
18   - s.add_dependency "activemodel", "~> 3.1"
19   - s.add_dependency "railties", "~> 3.1"
  17 + s.add_dependency "actionpack", "~> 3.0"
  18 + s.add_dependency "activemodel", "~> 3.0"
  19 + s.add_dependency "railties", "~> 3.0"
20 20
21 21 s.add_development_dependency "rake"
22 22 s.add_development_dependency "mocha", "~> 0.12.0"
6 test/gemfiles/Gemfile.rails-3.0.x
... ... @@ -0,0 +1,6 @@
  1 +source :rubygems
  2 +gemspec :path => "./../.."
  3 +
  4 +gem "actionpack", "~> 3.0.0"
  5 +gem "railties", "~> 3.0.0"
  6 +gem "activemodel", "~> 3.0.0"
62 test/gemfiles/Gemfile.rails-3.0.x.lock
... ... @@ -0,0 +1,62 @@
  1 +PATH
  2 + remote: /Users/mgrosser/code/tools/strong_parameters
  3 + specs:
  4 + strong_parameters (0.1.6.dev)
  5 + actionpack (~> 3.0)
  6 + activemodel (~> 3.0)
  7 + railties (~> 3.0)
  8 +
  9 +GEM
  10 + remote: http://rubygems.org/
  11 + specs:
  12 + abstract (1.0.0)
  13 + actionpack (3.0.17)
  14 + activemodel (= 3.0.17)
  15 + activesupport (= 3.0.17)
  16 + builder (~> 2.1.2)
  17 + erubis (~> 2.6.6)
  18 + i18n (~> 0.5.0)
  19 + rack (~> 1.2.5)
  20 + rack-mount (~> 0.6.14)
  21 + rack-test (~> 0.5.7)
  22 + tzinfo (~> 0.3.23)
  23 + activemodel (3.0.17)
  24 + activesupport (= 3.0.17)
  25 + builder (~> 2.1.2)
  26 + i18n (~> 0.5.0)
  27 + activesupport (3.0.17)
  28 + builder (2.1.2)
  29 + erubis (2.6.6)
  30 + abstract (>= 1.0.0)
  31 + i18n (0.5.0)
  32 + json (1.7.5)
  33 + metaclass (0.0.1)
  34 + mocha (0.12.7)
  35 + metaclass (~> 0.0.1)
  36 + rack (1.2.5)
  37 + rack-mount (0.6.14)
  38 + rack (>= 1.0.0)
  39 + rack-test (0.5.7)
  40 + rack (>= 1.0)
  41 + railties (3.0.17)
  42 + actionpack (= 3.0.17)
  43 + activesupport (= 3.0.17)
  44 + rake (>= 0.8.7)
  45 + rdoc (~> 3.4)
  46 + thor (~> 0.14.4)
  47 + rake (10.0.1)
  48 + rdoc (3.12)
  49 + json (~> 1.4)
  50 + thor (0.14.6)
  51 + tzinfo (0.3.35)
  52 +
  53 +PLATFORMS
  54 + ruby
  55 +
  56 +DEPENDENCIES
  57 + actionpack (~> 3.0.0)
  58 + activemodel (~> 3.0.0)
  59 + mocha (~> 0.12.0)
  60 + railties (~> 3.0.0)
  61 + rake
  62 + strong_parameters!

0 comments on commit 3996cf8

Please sign in to comment.
Something went wrong with that request. Please try again.