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

Fix expand of custom_actions when they are nil #305

Merged
merged 1 commit into from
Jan 29, 2018

Conversation

jntullo
Copy link

@jntullo jntullo commented Jan 29, 2018

When a resource has no custom_actions but is requested to have them expanded (ie /api/services?expand=resources&attributes=custom_actions), it is failing because we attempt to add custom action hrefs to a nil value.

{
    "error": {
        "kind": "internal_server_error",
        "message": "can't dup NilClass",
        "klass": "TypeError"
    }
}

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1539741

Copy link
Member

@chrisarcand chrisarcand left a comment

Choose a reason for hiding this comment

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

Looks good, one tiny change.

@@ -77,6 +77,15 @@ def expect_result_to_have_custom_actions_hash
expect_result_to_have_keys(%w(id href actions))
expect(response.parsed_body["actions"].select { |a| a["method"] == "post" }.pluck("name")).to match_array(%w(edit add_resource remove_resource remove_all_resources add_provider_vms))
end

it "allows expanding of custom actions" do
FactoryGirl.create(:service)
Copy link
Member

Choose a reason for hiding this comment

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

Move as a memoized helper after line 70 (let(:service)....), this is test setup that can be reused in this block and kept out of the spec itself.

@miq-bot
Copy link
Member

miq-bot commented Jan 29, 2018

Checked commit jntullo@5054ff2 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@gtanzillo gtanzillo added this to the Sprint 78 Ending Jan 29, 2018 milestone Jan 29, 2018
@gtanzillo gtanzillo merged commit cb4331a into ManageIQ:master Jan 29, 2018
simaishi pushed a commit that referenced this pull request Jan 29, 2018
Fix expand of custom_actions when they are nil
(cherry picked from commit cb4331a)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1539943
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 843c340ed9afb1034cf16f6ca518b85dc93d3163
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Mon Jan 29 15:42:06 2018 -0500

    Merge pull request #305 from jntullo/bz_1539741
    
    Fix expand of custom_actions when they are nil
    (cherry picked from commit cb4331a4df0a28e710282e660d33b1ce8163d964)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1539943

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