-
Notifications
You must be signed in to change notification settings - Fork 359
find_records_with_rbac raises exception if ids contains nil #3131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
find_records_with_rbac raises exception if ids contains nil #3131
Conversation
@miq-bot assign @romanblanco |
@@ -123,6 +123,7 @@ def find_record_with_rbac(klass, id, options = {}) | |||
# either sets flash or raises exception | |||
# | |||
def find_records_with_rbac(klass, ids, options = {}) | |||
raise(_("Can't access records with nil id")) if ids.include?(nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.wrap(nil).include?(nil)
# false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
60ab347
to
5cafa74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PanSpagetka Could you add some tests to test both find_records_with_rbac
and find_record_with_rbac
, checking that if you send a nil
the exception is raised?
265a427
to
decc9cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks @PanSpagetka 👍
@PanSpagetka: travis seems related. But restarting anyway. |
@PanSpagetka : please, fix the specs. |
decc9cc
to
9ac47f7
Compare
9eb9dbc
to
f8699f3
Compare
f8699f3
to
43e629b
Compare
…ord::RecordNotFound
…ler specs accoding to find_records_with_rbac changes
43e629b
to
20d6907
Compare
Checked commits PanSpagetka/manageiq-ui-classic@ccca932~...20d6907 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@martinpovolny ready to merge. |
@miq-bot assign @martinpovolny |
Change
find_records_with_rbac(klass, ids, options = {})
method behavior if ids contains nil. Now when you call this method with ids contains nil or empty array, it just returns nil or empty array.After this change
find_records_with_rbac(klass, ids, options = {})
will raise exception if ids contains nil value. Because when you want to access record with nil id something is probably wrong and this method shouldn't hide it.Works analogically for
find_record_with_rbac
which usesfind_records_with_rbac