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 ambassador dashboard exception #843

Merged
merged 3 commits into from
Jun 5, 2019
Merged

Conversation

jmromer
Copy link
Contributor

@jmromer jmromer commented Jun 4, 2019

Fixes a UninferrableDecoratorError / NoMethodError exception that occurs when accessing the organized ambassador dashboard as a super admin who is not in the ambassador organization.

Fixes #842
https://app.honeybadger.io/projects/35931/faults/50329990#notice-comments

@jmromer jmromer self-assigned this Jun 4, 2019
@jmromer jmromer requested a review from sethherr June 4, 2019 19:23
expect(response).to render_template(:show)
end
end

describe "resources" do
it "renders the ambassador resources" do
get "#{base_url}/resources"
get resources_organization_ambassador_dashboard_path(organization)
Copy link
Member

Choose a reason for hiding this comment

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

Why switch to routes instead of explicit paths?

Copy link
Member

Choose a reason for hiding this comment

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

The benefits I see to using explicit paths is that it adds one extra bit of test coverage.

I can see an argument for using paths instead, in that we generally use them in the code.

Copy link
Contributor Author

@jmromer jmromer Jun 5, 2019

Choose a reason for hiding this comment

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

  1. In the preexisting tests, for consistency with the new tests
  2. In the new tests, because url helpers provide a layer of indirection so that we're not propagating knowledge of the routes throughout the app. (Suppose, for example, we want to refactor underscores to dashes in routes for the sake of SEO.)

I'm not sure I see where the added test coverage would come from, but I'll go ahead ship and iterate since this is a bug fix. Happy to standardize on something and refactor for uniformity.

Copy link
Member

@sethherr sethherr Jun 5, 2019

Choose a reason for hiding this comment

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

The "extra test coverage" is a little bit of a stretch, because I'm not sure that it actually is useful test coverage (like shoulda matchers) - but by writing out the route as a URL string, we get routing specs.

There are two routing specs in Bike Index, both for complicated routing parameters, both were used as unit tests when I was verifying things worked as expected; if we switched fully over to request specs and wrote out URLs, these tests wouldn't be necessary.

Merging this was definitely the right choice. I'm adding additional explanation to the request spec migration issue #845

Copy link
Member

@sethherr sethherr 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 to me.

I'm going to make a plea for not using draper, but that can be dealt with separately

@jmromer jmromer merged commit c3abae8 into master Jun 5, 2019
@jmromer jmromer deleted the fix-ambassador-dashboard branch June 5, 2019 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ambassador Decorator bug
2 participants