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

Return correct href for collections on Index #150

Merged
merged 1 commit into from
Oct 30, 2017
Merged

Return correct href for collections on Index #150

merged 1 commit into from
Oct 30, 2017

Conversation

jntullo
Copy link

@jntullo jntullo commented Oct 30, 2017

Fixes issues where the API prefix isn't passed back in the API index for collections

@miq-bot add_label bug
@miq-bot assign @abellotti


get api_entrypoint_url

response.parsed_body["collections"].each do |collection|
Copy link
Contributor

@imtayadeway imtayadeway Oct 30, 2017

Choose a reason for hiding this comment

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

WDYT of doing something like this for the verification here:

      collection_names = Api::ApiConfig.collections.to_h.select { |_, v| v.options.include?(:collection) }.keys
      hrefs = collection_names.collect { |name| url_for(:controller => name, :action => "index") }
      expected = {
        "collections" => a_collection_containing_exactly(
          *hrefs.collect { |href| a_hash_including("href" => href) }
        )
      }
      expect(response.parsed_body).to include(expected)

Aithough there's a bit more going on there, I like it because:

  1. It verifies against an external source of truth (if for instance there were no collections in your response, you'd still pass)
  2. It looks for an exact match on the href
  3. It's a single expectation, which will give you one failure and a diff in the event of a regression

@abellotti abellotti added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 30, 2017
@miq-bot
Copy link
Member

miq-bot commented Oct 30, 2017

Checked commit jntullo@ce89f6e with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@abellotti
Copy link
Member

Thanks @jntullo for fixing this.

@abellotti abellotti merged commit 3df2829 into ManageIQ:master Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants