Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Check before update attribute of basemodel #93

Merged
merged 1 commit into from May 3, 2017
Merged

Conversation

jameswnl
Copy link
Contributor

@jameswnl jameswnl commented May 2, 2017

This is to fix https://bugzilla.redhat.com/show_bug.cgi?id=1445995

When caller passes in attributes that client doesn't know, even though Tower succeed in the call, client is blown up.

@miq-bot add_labels wip, bug

send("#{method_name}=", value)
invoke_name = "#{override_raw_attributes[method_name] ? override_raw_attributes[method_name] : method_name}="
if respond_to?(invoke_name)
send(invoke_name, value)

Choose a reason for hiding this comment

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

Probably need a else or rescue here that logs a debug message saying it couldn't write to a specific attribute name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also added a spec test.

@@ -82,10 +82,11 @@ def self.create(*args)
def update_attributes!(attributes)
@api.patch(url, attributes.to_json)
attributes.each do |method_name, value|
if override_raw_attributes[method_name]
send("#{override_raw_attributes[method_name]}=", value)
invoke_name = "#{override_raw_attributes[method_name] ? override_raw_attributes[method_name] : method_name}="
Copy link
Contributor

Choose a reason for hiding this comment

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

override_raw_attributes[method_name] ? override_raw_attributes[method_name] : method_name
can be simplified to:
override_raw_attributes[method_name] || method_name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
done!

@miq-bot
Copy link
Collaborator

miq-bot commented May 3, 2017

Checked commit jameswnl@5f85374 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@jameswnl jameswnl changed the title [WIP] check before update attribute of basemodel Check before update attribute of basemodel May 3, 2017
@jameswnl
Copy link
Contributor Author

jameswnl commented May 3, 2017

@miq-bot remove_label wip

@bdunne bdunne merged commit 8bcb53b into ansible:master May 3, 2017
@jameswnl jameswnl deleted the attr branch July 11, 2017 14:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants