rename_params 1.1.0 → 1.1.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: b90214f110951409c498a774e7a3e4b59fab5c36
4
- data.tar.gz: a9eac70722c932f4d4c6d233340575ff2afe5108
3
+ metadata.gz: 3b0c87289877054fdb0060e0cf54eea6c2336469
4
+ data.tar.gz: f0c404e489c7b6a005aaad5fe53772afc9d64982
5
5
  SHA512:
6
- metadata.gz: 6dd0a4c6daf1cd74783714857ff26a7cbafbf84924896682373b6c6a848017223d6158cc584d6ea825465438ee0459a393d542d987d1e2db7a9c2ce2a1bb9eb8
7
- data.tar.gz: 749be24287ffa76428ebab7a9f46175015d6b10b827b8af25a25a2142214a7f181ebd86d408c9dbca4c723bf97adfe47a66463da3718bed7e9ce4ffe1ba0f1b2
6
+ metadata.gz: 38c614188817e1f6d4fc0de57687839248f5638dd5d335a796e0c251b6f73dee60b33f98557b8b599a9987413a6d88599d15455c8bc62294b2f91bb969405af4
7
+ data.tar.gz: 9bae578175c0b31724de2b7f8d81bc7d906dd93ae9d20c11472db26dcc85159ac40cb74f648724a50ca2e0543258b1e49da171be352e7aac5dafe494c7331325
@@ -14,7 +14,7 @@ module RenameParams
14
14
 
15
15
  if converter && has_key?(key, namespace)
16
16
  new_value = converter.convert(get(key, namespace))
17
- set(key, new_value)
17
+ set(key, new_value, namespace)
18
18
  end
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  module RenameParams
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
@@ -97,6 +97,21 @@ describe RenameParams::Macros::Rename, type: :controller do
97
97
  end
98
98
  end
99
99
  end
100
+
101
+ context 'if param is nested' do
102
+ controller(ActionController::Base) do
103
+ rename :admin, to: :role, namespace: :user, convert: { true: ['admin'], false: [] }
104
+
105
+ def index
106
+ head :ok
107
+ end
108
+ end
109
+
110
+ it 'renames admin to role and converts value' do
111
+ get :index, { user: { admin: 'true' } }
112
+ expect(controller.params).to eq default_params.merge({ 'user' => { 'role' => ['admin'] } })
113
+ end
114
+ end
100
115
  end
101
116
 
102
117
  describe 'when nested params' do
@@ -295,5 +310,20 @@ describe RenameParams::Macros::Rename, type: :controller do
295
310
  end
296
311
  end
297
312
  end
313
+
314
+ context 'and converting values' do
315
+ controller(ActionController::Base) do
316
+ rename :admin, to: :role, namespace: :user, convert: { true: ['admin'], false: [] }, move_to: :root
317
+
318
+ def index
319
+ head :ok
320
+ end
321
+ end
322
+
323
+ it 'renames admin to role and converts value' do
324
+ get :index, { user: { admin: 'true' } }
325
+ expect(controller.params).to eq('controller' => 'anonymous', 'action' => 'index', 'user' => {}, 'role' => ['admin'])
326
+ end
327
+ end
298
328
  end
299
329
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rename_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Casiraghi