-
Notifications
You must be signed in to change notification settings - Fork 897
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 allowed tags for a request workflow #13379
[api] expose allowed tags for a request workflow #13379
Conversation
@imtayadeway Can you please review this when you get a chance? Thanks! |
/cc @chriskacerguis |
In general I'm ok with this, short of the rubocop warning above. Just curious, could you get that information today without this PR via:
Thanks. |
@abellotti Interesting! However, that did not work. I got this --
|
@abellotti As far as the rubocop warning goes, I think we could ignore it. virtual_column :reason, :type => :string, :uses => :miq_approvals
virtual_column :v_approved_by, :type => :string, :uses => :miq_approvals
virtual_column :v_approved_by_email, :type => :string, :uses => {:miq_approvals => :stamper}
virtual_column :stamped_on, :type => :datetime, :uses => :miq_approvals Maybe I could move this newly added virtual column on top with the others that have |
@AparnaKarve thanks for checking. This LGTM!! @imtayadeway thoughts/input ? |
@@ -236,6 +237,10 @@ def v_approved_by_email | |||
emails.join(", ") | |||
end | |||
|
|||
def v_allowed_tags |
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.
I think you could do this in one line:
delegate :allowed_tags, :to => :workflow, :prefix => :v
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.
Yeah, that would work 👍 . Thanks.
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.
yay!
@@ -248,6 +248,31 @@ | |||
expect(response.parsed_body).to match(expected) | |||
expect(response).to have_http_status(:ok) | |||
end | |||
|
|||
it "exposes allowed_tags in the request resources" do |
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.
I'm a bit divided over this test, although it is written perfectly well! I'm just thinking that since we should have ample coverage that the API can deliver virtual attributes, is it needed? Perhaps a model test would suffice?
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.
So what you're saying is, instead of writing a test on the API side we should write it only on the model side? ...which kinda makes sense in this situation.
Although the only reason I added a virtual_column was because I have this requirement to access it via the API. Without this requirement in the picture, the model does not need any changes.
How about we include both tests?
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.
I'm leaning towards only making the model test. @abellotti any thoughts here?
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.
Both good, though my preference is on the API side since that is the intended usage and it tests both model and the API exposing it.
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.
@abellotti @imtayadeway I have added tests in both places -- model and API.
If having both specs seems redundant, I can get rid of this commit d041b96, which is the model spec.
Checked commits AparnaKarve/manageiq@21d9103~...d041b96 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/models/miq_request.rb
|
👍 |
Created a
virtual_column
forallowed_tags
which is required in order to populate thetags
tree in the Request Workflow in SUIapi/requests/<id>?attributes=v_allowed_tags
https://www.pivotaltracker.com/n/projects/1914499/stories/137139937