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

Fixes #23163 - Fix breadcrumbs in template invocation details #355

Merged
merged 6 commits into from Jun 4, 2018

Conversation

adamruzicka
Copy link
Contributor

breadcrumbs1
breadcrumbs2

@@ -0,0 +1,46 @@
module Api

Choose a reason for hiding this comment

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

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

Copy link
Member

Choose a reason for hiding this comment

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

@houndci-bot neither @rubocop is happy about this

@adamruzicka
Copy link
Contributor Author

CC @sharvit could you take a look please?

N_('List template invocations belonging to job invocation')
param_group :search_and_pagination, ::Api::V2::BaseController
param :id, :identifier, :required => true
def template_invocations
Copy link
Member

Choose a reason for hiding this comment

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

why not calling it index, which is the standard name for method listing all the resources in rails?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it was moved from JobInvocationController?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it still an index when it is by default scoped by another resource? I would expect index to return all template invocations (with possible search), not only template invocations belonging to a certain job invocation


before_action :find_job_invocation, :only => %w{template_invocations}

api :GET, '/job_invocations/:id/template_invocations',
Copy link
Member

Choose a reason for hiding this comment

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

In nested resources, we would usually do :job_invocation_id instead of :id, as the :id usually refers to the resource of the controller itself (which is TemplateInvocation in this case`)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This leads to a slightly confusing situation where the API description states it is job_invocation_id, but in the controller it is accessible as params[:id]

module V2
class TemplateInvocationsController < ::Api::V2::BaseController
include ::Api::Version2
include ::Foreman::Renderer
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

Copy link
Member

@iNecas iNecas left a comment

Choose a reason for hiding this comment

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

Tested and works well. Tests are failing, probably due to missing permissions definition in

permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_category, :preview, :export],

Some requests inline

@iNecas
Copy link
Member

iNecas commented Jun 1, 2018

One thing I forgot to ask yesterday: could you cover it by some controller tests?

Copy link
Contributor

@sharvit sharvit left a comment

Choose a reason for hiding this comment

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

I think it looks good! Thanks @adamruzicka 👍
Just one small comment from my side...


<% breadcrumbs(:resource_url => template_invocations_api_job_invocation_path(@template_invocation.job_invocation_id),
:name_field => 'host_name',
:switcher_item_url => '/template_invocations/:id',
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -0,0 +1,31 @@
require 'test_plugin_helper'

Choose a reason for hiding this comment

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

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

@@ -0,0 +1,45 @@
# frozen_string_literal: true
module Api

Choose a reason for hiding this comment

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

Layout/EmptyLineAfterMagicComment: Add an empty line after magic comments.

@iNecas
Copy link
Member

iNecas commented Jun 4, 2018

Re-tested and works like a charm. Thanks @adamruzicka

@iNecas iNecas merged commit f0977d2 into theforeman:master Jun 4, 2018
@adamruzicka adamruzicka deleted the fix/breadcrumbs-23163 branch June 7, 2018 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants