attr_initializable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/README.md +5 -1
  2. data/Rakefile +8 -3
  3. data/lib/attr_initializable/version.rb +2 -1
  4. data/lib/attr_initializable.rb +15 -6
  5. data/test/{dummy → dummy-rails3}/Rakefile +0 -0
  6. data/test/{dummy → dummy-rails3}/app/assets/javascripts/application.js +0 -0
  7. data/test/{dummy → dummy-rails3}/app/assets/stylesheets/application.css +0 -0
  8. data/test/{dummy → dummy-rails3}/app/controllers/application_controller.rb +0 -0
  9. data/test/{dummy → dummy-rails3}/app/helpers/application_helper.rb +0 -0
  10. data/test/{dummy → dummy-rails3}/app/models/manufacturer.rb +0 -0
  11. data/test/{dummy → dummy-rails3}/app/models/widget.rb +0 -0
  12. data/test/{dummy → dummy-rails3}/app/views/layouts/application.html.erb +0 -0
  13. data/test/{dummy → dummy-rails3}/config/application.rb +0 -0
  14. data/test/{dummy → dummy-rails3}/config/boot.rb +0 -0
  15. data/test/{dummy → dummy-rails3}/config/database.yml +0 -0
  16. data/test/{dummy → dummy-rails3}/config/environment.rb +0 -0
  17. data/test/{dummy → dummy-rails3}/config/environments/development.rb +0 -0
  18. data/test/{dummy → dummy-rails3}/config/environments/production.rb +0 -0
  19. data/test/{dummy → dummy-rails3}/config/environments/test.rb +0 -0
  20. data/test/{dummy → dummy-rails3}/config/initializers/backtrace_silencers.rb +0 -0
  21. data/test/{dummy → dummy-rails3}/config/initializers/inflections.rb +0 -0
  22. data/test/{dummy → dummy-rails3}/config/initializers/mime_types.rb +0 -0
  23. data/test/{dummy → dummy-rails3}/config/initializers/secret_token.rb +0 -0
  24. data/test/{dummy → dummy-rails3}/config/initializers/session_store.rb +0 -0
  25. data/test/{dummy → dummy-rails3}/config/initializers/wrap_parameters.rb +0 -0
  26. data/test/{dummy → dummy-rails3}/config/locales/en.yml +0 -0
  27. data/test/{dummy → dummy-rails3}/config/routes.rb +0 -0
  28. data/test/{dummy → dummy-rails3}/config.ru +0 -0
  29. data/test/{dummy → dummy-rails3}/db/migrate/20131027192625_create_manufacturers.rb +0 -0
  30. data/test/{dummy → dummy-rails3}/db/migrate/20131027192834_create_widgets.rb +0 -0
  31. data/test/{dummy → dummy-rails3}/db/schema.rb +0 -0
  32. data/test/{dummy → dummy-rails3}/db/test.sqlite3 +0 -0
  33. data/test/dummy-rails3/log/test.log +1169 -0
  34. data/test/{dummy → dummy-rails3}/public/404.html +0 -0
  35. data/test/{dummy → dummy-rails3}/public/422.html +0 -0
  36. data/test/{dummy → dummy-rails3}/public/500.html +0 -0
  37. data/test/{dummy → dummy-rails3}/public/favicon.ico +0 -0
  38. data/test/{dummy → dummy-rails3}/script/rails +0 -0
  39. data/test/dummy-rails4/Rakefile +6 -0
  40. data/test/dummy-rails4/app/assets/javascripts/application.js +16 -0
  41. data/test/dummy-rails4/app/assets/stylesheets/application.css +13 -0
  42. data/test/dummy-rails4/app/controllers/application_controller.rb +5 -0
  43. data/test/dummy-rails4/app/helpers/application_helper.rb +2 -0
  44. data/test/dummy-rails4/app/models/manufacturer.rb +3 -0
  45. data/test/dummy-rails4/app/models/widget.rb +7 -0
  46. data/test/dummy-rails4/app/views/layouts/application.html.erb +14 -0
  47. data/test/dummy-rails4/bin/bundle +3 -0
  48. data/test/dummy-rails4/bin/rails +4 -0
  49. data/test/dummy-rails4/bin/rake +4 -0
  50. data/test/dummy-rails4/config/application.rb +27 -0
  51. data/test/dummy-rails4/config/boot.rb +4 -0
  52. data/test/dummy-rails4/config/database.yml +25 -0
  53. data/test/dummy-rails4/config/environment.rb +5 -0
  54. data/test/dummy-rails4/config/environments/development.rb +29 -0
  55. data/test/dummy-rails4/config/environments/production.rb +80 -0
  56. data/test/dummy-rails4/config/environments/test.rb +36 -0
  57. data/test/dummy-rails4/config/initializers/backtrace_silencers.rb +7 -0
  58. data/test/dummy-rails4/config/initializers/filter_parameter_logging.rb +4 -0
  59. data/test/dummy-rails4/config/initializers/inflections.rb +16 -0
  60. data/test/dummy-rails4/config/initializers/mime_types.rb +5 -0
  61. data/test/dummy-rails4/config/initializers/secret_token.rb +12 -0
  62. data/test/dummy-rails4/config/initializers/session_store.rb +3 -0
  63. data/test/dummy-rails4/config/initializers/wrap_parameters.rb +14 -0
  64. data/test/dummy-rails4/config/locales/en.yml +23 -0
  65. data/test/dummy-rails4/config/routes.rb +56 -0
  66. data/test/dummy-rails4/config.ru +4 -0
  67. data/test/dummy-rails4/db/migrate/20131027192625_create_manufacturers.rb +9 -0
  68. data/test/dummy-rails4/db/migrate/20131027192834_create_widgets.rb +11 -0
  69. data/test/dummy-rails4/db/schema.rb +28 -0
  70. data/test/dummy-rails4/db/seeds.rb +7 -0
  71. data/test/{dummy/db/development.sqlite3 → dummy-rails4/db/test.sqlite3} +0 -0
  72. data/test/dummy-rails4/log/development.log +14 -0
  73. data/test/dummy-rails4/log/test.log +706 -0
  74. data/test/dummy-rails4/public/404.html +58 -0
  75. data/test/dummy-rails4/public/422.html +58 -0
  76. data/test/dummy-rails4/public/500.html +57 -0
  77. data/test/dummy-rails4/public/favicon.ico +0 -0
  78. data/test/dummy-rails4/public/robots.txt +5 -0
  79. data/test/test_helper.rb +12 -4
  80. data/test/test_utils.rb +27 -0
  81. metadata +154 -94
  82. data/test/dummy/README.rdoc +0 -261
  83. data/test/dummy/log/development.log +0 -28
  84. data/test/dummy/log/test.log +0 -690
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # attr_initializable [![Install gem](https://badge.fury.io/rb/attr_initializable.png)](https://rubygems.org/gems/attr_initializable) [![Build status](https://travis-ci.org/rcook/attr_initializable.png)](https://travis-ci.org/rcook/attr_initializable)
1
+ # `attr_initializable`
2
+
3
+ [![Install gem](https://badge.fury.io/rb/attr_initializable.png)](https://rubygems.org/gems/attr_initializable)
4
+ [![Build status](https://travis-ci.org/rcook/attr_initializable.png)](https://travis-ci.org/rcook/attr_initializable)
5
+ [![Coverage status](https://coveralls.io/repos/rcook/attr_initializable/badge.png?branch=master)](https://coveralls.io/r/rcook/attr_initializable)
2
6
 
3
7
  Rails plugin that provides `attr_initializable` helper to declare read-only attributes that can be mass-assigned at model creation time
4
8
 
data/Rakefile CHANGED
@@ -12,6 +12,10 @@ rescue LoadError
12
12
  RDoc::Task = Rake::RDocTask
13
13
  end
14
14
 
15
+ require File.expand_path('../test/test_utils', __FILE__)
16
+
17
+ puts "Testing against Rails #{TestUtils.rails_version} with dummy application in #{TestUtils.dummy_app_dir}"
18
+
15
19
  RDoc::Task.new(:rdoc) do |rdoc|
16
20
  rdoc.rdoc_dir = 'rdoc'
17
21
  rdoc.title = 'AttrInitializable'
@@ -20,9 +24,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
24
  rdoc.rdoc_files.include('lib/**/*.rb')
21
25
  end
22
26
 
23
-
24
-
25
-
26
27
  Bundler::GemHelper.install_tasks
27
28
 
28
29
  require 'rake/testtask'
@@ -34,5 +35,9 @@ Rake::TestTask.new(:test) do |t|
34
35
  t.verbose = false
35
36
  end
36
37
 
38
+ task :test_db_reset do |t|
39
+ sh "cd test/#{TestUtils.dummy_app_dir}/ && RAILS_ENV=test bundle exec rake db:reset"
40
+ end
37
41
 
38
42
  task :default => :test
43
+
@@ -1,3 +1,4 @@
1
1
  module AttrInitializable
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
4
+
@@ -3,6 +3,16 @@ module AttrInitializable
3
3
 
4
4
  module ClassMethods
5
5
  def attr_initializable(attributes, options = {})
6
+ unless respond_to?(:protected_attributes)
7
+ raise RuntimeError.new('`attr_initializable` relies on `attr_accessible`. ' \
8
+ 'Please add `protected_attributes` to your Gemfile to use `attr_initializable`.')
9
+ end
10
+
11
+ unless Rails.configuration.active_record.mass_assignment_sanitizer == :strict
12
+ logger.warn "WARNING: Running with strict mass assignment sanitizer is recommended.\n" \
13
+ "Please add config.active_record.mass_assignment_sanitizer = :strict to config/application.rb.\n"
14
+ end
15
+
6
16
  role = options.delete(:as) || :default
7
17
  initializable_attributes[role] ||= []
8
18
  initializable_attributes[role] += Array(attributes)
@@ -14,12 +24,11 @@ module AttrInitializable
14
24
  end
15
25
 
16
26
  included do
17
- end
18
-
19
- def mass_assignment_authorizer(role = :default)
20
- accessible_attributes = super
21
- accessible_attributes += Array(self.class.initializable_attributes[role]) unless persisted?
22
- accessible_attributes
27
+ def mass_assignment_authorizer(role = :default)
28
+ authorizer = super
29
+ authorizer += Array(self.class.initializable_attributes[role]) unless persisted?
30
+ authorizer
31
+ end
23
32
  end
24
33
  end
25
34
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes