Skip to content

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

Merged
merged 8 commits into from
Jan 5, 2018

Conversation

PanSpagetka
Copy link
Contributor

@PanSpagetka PanSpagetka commented Dec 21, 2017

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 uses find_records_with_rbac

@PanSpagetka
Copy link
Contributor Author

@miq-bot add_label gaprindashvili/no
@miq-bot add_label refactoring

@romanblanco
Copy link
Member

@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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PanSpagetka PanSpagetka force-pushed the change-find-rbac-for-nil branch 2 times, most recently from 60ab347 to 5cafa74 Compare December 21, 2017 15:12
Copy link
Member

@romanblanco romanblanco left a 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 👍

Copy link
Member

@romanblanco romanblanco left a 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?

@PanSpagetka PanSpagetka force-pushed the change-find-rbac-for-nil branch from 265a427 to decc9cc Compare December 21, 2017 15:34
Copy link
Member

@romanblanco romanblanco left a 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 👍

@martinpovolny
Copy link
Member

@PanSpagetka: travis seems related. But restarting anyway.

@martinpovolny
Copy link
Member

@PanSpagetka : please, fix the specs.

@PanSpagetka PanSpagetka force-pushed the change-find-rbac-for-nil branch from decc9cc to 9ac47f7 Compare January 2, 2018 14:01
@PanSpagetka PanSpagetka force-pushed the change-find-rbac-for-nil branch 3 times, most recently from 9eb9dbc to f8699f3 Compare January 3, 2018 12:05
@PanSpagetka PanSpagetka closed this Jan 3, 2018
@PanSpagetka PanSpagetka reopened this Jan 3, 2018
@PanSpagetka PanSpagetka force-pushed the change-find-rbac-for-nil branch from f8699f3 to 43e629b Compare January 3, 2018 13:51
@PanSpagetka PanSpagetka force-pushed the change-find-rbac-for-nil branch from 43e629b to 20d6907 Compare January 4, 2018 13:22
@miq-bot
Copy link
Member

miq-bot commented Jan 4, 2018

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
8 files checked, 0 offenses detected
Everything looks fine. 🍪

@romanblanco
Copy link
Member

@martinpovolny ready to merge.

@romanblanco
Copy link
Member

@miq-bot assign @martinpovolny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants