Skip to content
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

create the resource action after save for custom buttons #821

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/custom_buttons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def create_resource(_type, _id, data)
custom_button = CustomButton.new(data.except("resource_action", "options"))
custom_button.userid = User.current_user.userid
custom_button.options = data["options"].deep_symbolize_keys if data["options"]
custom_button.create_resource_action!(data["resource_action"].deep_symbolize_keys) if data.key?("resource_action")
custom_button.save!
custom_button.create_resource_action!(data["resource_action"].deep_symbolize_keys) if data.key?("resource_action")
Copy link
Member

@abellotti abellotti Apr 30, 2020

Choose a reason for hiding this comment

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

just curious, can the create_resource_action! method somehow fail, and we end up with a created Object, but never used/returned ? do we need a transaction for the above two so the request is atomic ? @jrafanie thoughts ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really think so. resource action create 1) has no validations and 2) are artifacts that link dialogs, resources, and automate, there's not much of a vector for failure

Copy link
Member

Choose a reason for hiding this comment

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

yeah, probably similar to this one: ManageIQ/manageiq#20013

@d-m-u can you review if this is required and do a followup PR? This is great to fix the issue on rails 5.2

Copy link
Member

Choose a reason for hiding this comment

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

We cross our streams at the same time and didn't use a mutex

custom_button
end
rescue => err
Expand Down