action_args 2.2.0 → 2.2.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/lib/action_args/abstract_controller.rb +2 -2
- data/lib/action_args/version.rb +1 -1
- data/test/controllers/strong_parameters_test.rb +9 -0
- data/test/fake_app.rb +18 -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: 7c0bf9da845c27c49c8afd92bc8a547a860a3957
|
4
|
+
data.tar.gz: 716be3db07ed295cc0d29ea6ae92a9ab29ec33cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bcf24728168e8731d4a9c2a00e1158a08efc0a4722e25e6852295a399a4a3c7b25c4733ee0f999d32d9a8732362fec8a3431c770df680573ba5ff51d2ec589e
|
7
|
+
data.tar.gz: 494a147fab6a90baf8a19e5af9f6450254a320dfac735879626f07259cea241b018a00fe650ecf09d7ea184cfa1872891c34dd4273930619596535706e40c35b
|
@@ -27,8 +27,8 @@ module ActionArgs
|
|
27
27
|
# end
|
28
28
|
# end
|
29
29
|
#
|
30
|
-
def permits(*attributes, model_name: nil)
|
31
|
-
@permitted_attributes, @permitting_model_name = attributes, model_name
|
30
|
+
def permits(*attributes, model_name: nil, **kw_attributes)
|
31
|
+
@permitted_attributes, @permitting_model_name = attributes << kw_attributes, model_name
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/action_args/version.rb
CHANGED
@@ -29,6 +29,15 @@ class StoresControllerTest < ActionController::TestCase
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
class MoviesControllerTest < ActionController::TestCase
|
33
|
+
test 'POST create' do
|
34
|
+
movie_count_was = Movie.count
|
35
|
+
post :create, params: {movie: {title: 'Dr. No', actors_attributes: [{name: 'Bernard Lee'}]}}
|
36
|
+
|
37
|
+
assert_equal 1, Movie.count - movie_count_was
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
32
41
|
# this controller doesn't permit price of new book do
|
33
42
|
class Admin::BooksControllerTest < ActionController::TestCase
|
34
43
|
test 'POST create' do
|
data/test/fake_app.rb
CHANGED
@@ -21,6 +21,7 @@ ActionArgsTestApp::Application.routes.draw do
|
|
21
21
|
resources :kw_books # 2.0+ only
|
22
22
|
resources :kw_keyreq_books # 2.1+ only
|
23
23
|
resources :stores
|
24
|
+
resources :movies
|
24
25
|
|
25
26
|
namespace :admin do
|
26
27
|
resources :accounts
|
@@ -35,6 +36,13 @@ class Book < ActiveRecord::Base
|
|
35
36
|
end
|
36
37
|
class Store < ActiveRecord::Base
|
37
38
|
end
|
39
|
+
class Movie < ActiveRecord::Base
|
40
|
+
has_many :actors
|
41
|
+
accepts_nested_attributes_for :actors
|
42
|
+
end
|
43
|
+
class Actor < ActiveRecord::Base
|
44
|
+
belongs_to :movie
|
45
|
+
end
|
38
46
|
module Admin
|
39
47
|
def self.table_name_prefix() 'admin_' end
|
40
48
|
class Account < ActiveRecord::Base
|
@@ -108,6 +116,14 @@ class BooksController < ApplicationController
|
|
108
116
|
raise '💣'
|
109
117
|
end
|
110
118
|
end
|
119
|
+
class MoviesController < ApplicationController
|
120
|
+
permits :title, actors_attributes: [:name]
|
121
|
+
|
122
|
+
def create(movie)
|
123
|
+
@movie = Movie.create! movie
|
124
|
+
render plain: @movie.title
|
125
|
+
end
|
126
|
+
end
|
111
127
|
class StoresController < ApplicationController
|
112
128
|
permits :name, :url
|
113
129
|
|
@@ -156,6 +172,8 @@ class CreateAllTables < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migrat
|
|
156
172
|
create_table(:books) {|t| t.string :title; t.integer :price}
|
157
173
|
create_table(:stores) {|t| t.string :name; t.string :url}
|
158
174
|
create_table(:admin_accounts) {|t| t.string :name}
|
175
|
+
create_table(:movies) {|t| t.string :title}
|
176
|
+
create_table(:actors) {|t| t.string :name; t.references :movie}
|
159
177
|
end
|
160
178
|
end
|
161
179
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_args
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.6.
|
113
|
+
rubygems_version: 2.6.9
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Controller action arguments parameterizer for Rails 4+ & Ruby 2.0+
|