-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGES: - All methods can now be called without ! (param, params, default, etc...) - `array` and `group` are not identical anymore. `array` will accepts an array of values, while `group` will accept a single hash. - Removed to_defaults, replacing it with apply_defaults!
- Loading branch information
Showing
11 changed files
with
299 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
# Changelog | ||
All notable changes to this project made by Monade Team are documented in this file. For info refer to [email protected] | ||
|
||
## [2.0.0-BETA] - 2023-09-27 | ||
### Added | ||
- `transformer` option to param, that allows to transform the value received from a parameter before assigning it to the sanitized hash. | ||
- `default` now works also with nested structures. | ||
|
||
### Changed | ||
- [BREAKING] All methods can now be called without ! (param, params, default, etc...) | ||
- [BREAKING] `array` and `group` are not identical anymore. `array` will accepts an array of values, while `group` will accept a single hash. | ||
- [BREAKING] internal, removed to_defaults, replacing it with apply_defaults! | ||
|
||
### Fixed | ||
- Missing params in nested structures are now reported correctly | ||
|
||
|
||
## [1.0.0] - 2022-05-28 | ||
### Added | ||
- First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
# rubocop:disable Metrics/BlockLength | ||
describe PersonParamsSanitizer, type: :controller do | ||
let(:params) do | ||
ActionController::Parameters.new(params_hash) | ||
|
@@ -15,8 +16,7 @@ | |
current_user_id: 2, | ||
first_name: 'John', | ||
last_name: 'Doe', | ||
# TODO: Implement transformers | ||
# email: '[email protected]', | ||
email: '[email protected]', | ||
role: 'some_role', | ||
unwanted: 'hello', | ||
an_object_filtered: { name: 'value' }, | ||
|
@@ -38,13 +38,12 @@ | |
end | ||
|
||
it 'keeps only allowed params' do | ||
expect(sanitized).to eq( | ||
expect(sanitized.to_unsafe_h).to eq( | ||
{ | ||
'current_user_id' => 2, | ||
'first_name' => 'John', | ||
'last_name' => 'Doe', | ||
# TODO: Implement transformers | ||
# 'email' => '[email protected]', | ||
'email' => '[email protected]', | ||
'some_default' => 1, | ||
'an_array_unfiltered' => [1, 2, 3, 4, 5] | ||
} | ||
|
@@ -56,7 +55,10 @@ | |
{} | ||
end | ||
it 'raises an error' do | ||
expect { sanitized }.to raise_error(ActionController::ParameterMissing) | ||
expect { sanitized }.to raise_error( | ||
ActionController::ParameterMissing, | ||
'param is missing or the value is empty: current_user_id' | ||
) | ||
end | ||
end | ||
|
||
|
@@ -78,3 +80,4 @@ | |
end | ||
end | ||
end | ||
# rubocop:enable Metrics/BlockLength |
Oops, something went wrong.