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

Don't include unneeded helpers in tests #3974

Merged
merged 4 commits into from
Apr 16, 2020
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented Apr 15, 2020

Background

We're getting some exceptions when taking screenshots of a failing test in the Rails 5.1 branch because the method image_path from ActionView::Helpers::AssetUrlHelper has the same name as a method used to save the screenshot.

Besides, we were including all ActionView helpers in places were only the dom_id method is used, and in other places where no helper methods were used at all. So we can just invoke ActionView::RecordIdentifier.dom_id directly.

Objectives

  • Avoid exceptions when saving screenshots of a failing test
  • Remove unused shared examples

These tests aren't used since commit 4db5409.
@javierm javierm self-assigned this Apr 15, 2020
@javierm javierm added this to Reviewing in Consul Democracy via automation Apr 15, 2020
@javierm javierm added the Specs label Apr 15, 2020
@javierm javierm moved this from Reviewing to Doing in Consul Democracy Apr 15, 2020
@javierm javierm moved this from Doing to Reviewing in Consul Democracy Apr 15, 2020
@javierm javierm marked this pull request as ready for review April 15, 2020 22:48
@javierm javierm changed the title Don't include ActionView helpers in tests Don't include unneeded helpers in tests Apr 16, 2020
Including them might lead to conflicts since two methods might have the
same name. For example, we're getting some exceptions when taking
screenshots of a failing test, because the method `image_path` from
`ActionView::Helpers::AssetUrlHelper` has the same name as a method used
to save the screenshot.

Besides, we were including all helpers in places were only the `dom_id`
method is used, and in other places where no helper methods were used at
all. So we can just invoke `ActionView::RecordIdentifier.dom_id`
directly.
We were converting megabytes to bytes with the `megabytes` method and
then adding a `bytes_to_megabytes` method to convert it back to bytes,
which is the same as not doing anything at all :).
Since we're only doing the convertion from bytes to megabytes in one
place, IMHO adding an extra method makes the code harder to read.

This way we don't have do include the DocumentsHelper in the specs
anymore, reducing the risk of possible method naming collisions.
@javierm javierm merged commit cd8c74c into master Apr 16, 2020
Consul Democracy automation moved this from Reviewing to Release 1.2.0 Apr 16, 2020
@javierm javierm deleted the action_view_in_specs branch April 16, 2020 10:35
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.

None yet

1 participant