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

[api] expose Request Workflow class name #13441

Merged
merged 4 commits into from
Jan 12, 2017

Conversation

AparnaKarve
Copy link
Contributor

@AparnaKarve AparnaKarve commented Jan 11, 2017

Created a virtual_column for the workflow object's class name which is required in order to populate the Catalog tab in the Request Workflow in SUI.

api/requests/<id>?attributes=v_workflow_class

https://www.pivotaltracker.com/n/projects/1914499/stories/137409675

@AparnaKarve
Copy link
Contributor Author

AparnaKarve commented Jan 11, 2017

@imtayadeway I've consolidated all attribute related specs under one spec in ec1872b9fc839ba2c2a2490e3569dab55fe7348d.
Please review and suggest changes.

/cc @abellotti @chriskacerguis

@AparnaKarve
Copy link
Contributor Author

@miq-bot add_label wip

@AparnaKarve AparnaKarve changed the title [api] expose Request Workflow class name [WIP] [api] expose Request Workflow class name Jan 11, 2017
@miq-bot miq-bot added the wip label Jan 11, 2017
@AparnaKarve AparnaKarve force-pushed the api_expose_wf_class branch 2 times, most recently from 6490fb4 to 6b21ab1 Compare January 11, 2017 18:10
@chessbyte chessbyte added the api label Jan 12, 2017
expect(response.parsed_body).to match(expected)
expect(response.parsed_body).to match(expected_workflow)
expect(response.parsed_body).to match(expected_tags)
expect(response.parsed_body).to match(expected_class)
Copy link
Member

Choose a reason for hiding this comment

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

Might be better to have a single expect() for all the above since we're retesting id anyways, might something like:

expected_response = a_hash_including(....)

expect(response.parsed_body).to match(expected_response)

virtual_column :request_type_display, :type => :string
virtual_column :resource_type, :type => :string
virtual_column :state, :type => :string

delegate :allowed_tags, :to => :workflow, :prefix => :v
delegate :class, :to => :workflow, :prefix => :v
Copy link
Member

Choose a reason for hiding this comment

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

feels odd, too close to class, I know it has the v_ prefix, but I wonder if this should be named differently, maybe workflow_class ?

virtual_column :request_type_display, :type => :string
virtual_column :resource_type, :type => :string
virtual_column :state, :type => :string

delegate :allowed_tags, :to => :workflow, :prefix => :v
delegate :class, :to => :workflow, :prefix => :v
Copy link
Contributor

Choose a reason for hiding this comment

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

This could lead to some surprising behavior because it's overriding MiqRequest's built-in class method - would klass be OK for this?

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've changed the virtual_column name to v_workflow_class Does that work?


expected = a_hash_including("id" => request.id, "v_allowed_tags" => [a_hash_including("children")])
expected_workflow = a_hash_including("id" => request.id, "workflow" => a_hash_including("values"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem quite right, as you're checking the same attribute "id" in each expectation. Perhaps something like:

expected = {
  "id" => request.id,
  "workflow" => a_hash_including("values"),
  "v_allowed_tags" => [a_hash_including("children")],
  "v_class" => {"etc" => "etc"}
}
expected(response.parsed_body).to include(expected)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I took care of that. Thanks.

Copy link
Contributor

@imtayadeway imtayadeway left a comment

Choose a reason for hiding this comment

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

@AparnaKarve changes look good, if you can just fix the rubocop issue I think this is GTG 🍰

@miq-bot
Copy link
Member

miq-bot commented Jan 12, 2017

Checked commits AparnaKarve/manageiq@b6d57bd~...af354f5 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 0 offenses detected
Everything looks good. 🏆

@AparnaKarve AparnaKarve changed the title [WIP] [api] expose Request Workflow class name [api] expose Request Workflow class name Jan 12, 2017
@AparnaKarve
Copy link
Contributor Author

@miq-bot remove_label wip

@imtayadeway Thanks!
@abellotti GTG?

@miq-bot miq-bot removed the wip label Jan 12, 2017
@abellotti
Copy link
Member

👍 Thanks Aparna.

@abellotti abellotti merged commit 1d2698f into ManageIQ:master Jan 12, 2017
@abellotti abellotti added this to the Sprint 52 Ending Jan 16, 2017 milestone Jan 12, 2017
@AparnaKarve AparnaKarve deleted the api_expose_wf_class branch January 12, 2017 19:52
@kbrock kbrock mentioned this pull request Jul 15, 2024
1 task
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