action_args 1.5.1 → 1.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1be64c562566fa50677fd49064390945ef09e08
4
- data.tar.gz: 579d02790193ebe0bb9bd3fc032ca29785b1f28c
3
+ metadata.gz: bc3c3e13a176e31e7bd8cd5fef3f81ad07ec90e1
4
+ data.tar.gz: 2a9c273f4ff29a1648f5c7668480d9d89a38edce
5
5
  SHA512:
6
- metadata.gz: dcbe4c44a809e0fde4684c288c56f00b5595ffad2a38b6afd0bf2e14820d8694c949bb00f3b0c37bc3e5c8fb4ae1b88c48625e20fedbf52536b3c98c913ce960
7
- data.tar.gz: 81d8cc112ced51eee850a17bd6f58441ecce23b7c8a976b0ab980d053a26b4cf85688b9096174e6ad34c4d7ac902d55e384bb06fec8a4f7582ef9498686fe05d
6
+ metadata.gz: 66054d421bd9685f970bbe57aeb2337013e2e46dbb062ac46aa2a702b5f20ecb910a0a26294f7f07ca502c1c82974ce045fcf9fa61bb00aa528fd21171b42752
7
+ data.tar.gz: 4c124ceb79d14182f86fad1fc6fb4b3cda4c3ef2dc75dab8f4d3ad8b974a253d097524eddaae879139f78defa0514d89c5e3eed0c58a5fef90d503d92b563245
@@ -39,7 +39,7 @@ module ActionArgs
39
39
  # permits declared model attributes in the params Hash
40
40
  # note that this method mutates the given params Hash
41
41
  def self.strengthen_params!(controller_class, method_parameters, params)
42
- target_model_name = (controller_class.instance_variable_get(:'@permitting_model_name') || controller_class.name.sub(/.+::/, '').sub(/Controller$/, '')).singularize.underscore.to_sym
42
+ target_model_name = (controller_class.instance_variable_get(:'@permitting_model_name') || controller_class.name.sub(/.+::/, '').sub(/Controller$/, '')).singularize.underscore.tr('/', '_').to_sym
43
43
  permitted_attributes = controller_class.instance_variable_get :'@permitted_attributes'
44
44
 
45
45
  method_parameters.each do |type, key|
@@ -1,3 +1,3 @@
1
1
  module ActionArgs
2
- VERSION = '1.5.1'.freeze
2
+ VERSION = '1.5.2'.freeze
3
3
  end
@@ -25,4 +25,10 @@ if Rails::VERSION::MAJOR >= 4
25
25
  end
26
26
  end
27
27
  end
28
+
29
+ describe Admin::AccountsController do
30
+ describe 'POST create' do
31
+ it { expect { post :create, :admin_account => {name: 'amatsuda'} }.to change(Admin::Account, :count).by(1) }
32
+ end
33
+ end
28
34
  end
data/spec/fake_app.rb CHANGED
@@ -22,6 +22,7 @@ ActionArgsTestApp::Application.routes.draw do
22
22
  resources :stores
23
23
 
24
24
  namespace :admin do
25
+ resources :accounts
25
26
  resources :books
26
27
  end
27
28
  end
@@ -33,6 +34,11 @@ class Book < ActiveRecord::Base
33
34
  end
34
35
  class Store < ActiveRecord::Base
35
36
  end
37
+ module Admin
38
+ def self.table_name_prefix() 'admin_' end
39
+ class Account < ActiveRecord::Base
40
+ end
41
+ end
36
42
 
37
43
  # mailers
38
44
  require "action_mailer/railtie"
@@ -123,6 +129,15 @@ if Rails::VERSION::MAJOR >= 4
123
129
  end
124
130
  end
125
131
  module Admin
132
+ class AccountsController < ::ApplicationController
133
+ permits :name, model_name: 'Admin::Account'
134
+
135
+ def create(admin_account)
136
+ @admin_account = Admin::Account.create! admin_account
137
+ render text: @admin_account.name
138
+ end
139
+ end
140
+
126
141
  class BooksController < ::ApplicationController
127
142
  permits :title
128
143
 
@@ -143,5 +158,6 @@ class CreateAllTables < ActiveRecord::Migration
143
158
  create_table(:authors) {|t| t.string :name}
144
159
  create_table(:books) {|t| t.string :title; t.integer :price}
145
160
  create_table(:stores) {|t| t.string :name; t.string :url}
161
+ create_table(:admin_accounts) {|t| t.string :name}
146
162
  end
147
163
  end
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: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler