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 +4 -4
- data/lib/rename_params/params.rb +1 -1
- data/lib/rename_params/version.rb +1 -1
- data/spec/macros/rename_spec.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b0c87289877054fdb0060e0cf54eea6c2336469
|
4
|
+
data.tar.gz: f0c404e489c7b6a005aaad5fe53772afc9d64982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c614188817e1f6d4fc0de57687839248f5638dd5d335a796e0c251b6f73dee60b33f98557b8b599a9987413a6d88599d15455c8bc62294b2f91bb969405af4
|
7
|
+
data.tar.gz: 9bae578175c0b31724de2b7f8d81bc7d906dd93ae9d20c11472db26dcc85159ac40cb74f648724a50ca2e0543258b1e49da171be352e7aac5dafe494c7331325
|
data/lib/rename_params/params.rb
CHANGED
data/spec/macros/rename_spec.rb
CHANGED
@@ -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
|