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

Change to resolve error when url is 'nil' #11

Closed
wants to merge 1 commit into from

Conversation

dmvt
Copy link
Contributor

@dmvt dmvt commented Feb 12, 2018

When running tests with RSpec & Capybara we (Punchpass) were encountering the following error:

Failures:

  1) Customer signs in via the company sign in page having a customer account with the company with an instance param is taken to the member instance details page
     Failure/Error: - breadcrumb_trail crumb_length: 60 do |name, url, styles|
     
     ActionView::Template::Error:
       arguments passed to url_for can't be handled. Please require routes or provide your own implementation
     # /Users/dan/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/actionview-4.2.8/lib/action_view/helpers/url_helper.rb:38:in `url_for'
     # /Users/dan/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/loaf-0.6.0/lib/loaf/view_extensions.rb:55:in `block in breadcrumb_trail'
     # /Users/dan/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/loaf-0.6.0/lib/loaf/view_extensions.rb:53:in `each'
     # /Users/dan/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/loaf-0.6.0/lib/loaf/view_extensions.rb:53:in `breadcrumb_trail'
     # ./app/views/layouts/member_area.html.slim:50:in `_app_views_layouts_member_area_html_slim__403637215859839844_70256255168280'

After a bit of digging, I found the cause to be a nil value in the url for our last breadcrumb. Interestingly, the error didn't trip in development or production, just testing. Adding the nil check allowed our tests to pass gracefully.

@coveralls
Copy link

coveralls commented Feb 12, 2018

Coverage Status

Coverage remained the same at 97.03% when pulling 36bbffb on dmvt:master into c7f7468 on piotrmurach:master.

5 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.03% when pulling 36bbffb on dmvt:master into c7f7468 on piotrmurach:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.03% when pulling 36bbffb on dmvt:master into c7f7468 on piotrmurach:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.03% when pulling 36bbffb on dmvt:master into c7f7468 on piotrmurach:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.03% when pulling 36bbffb on dmvt:master into c7f7468 on piotrmurach:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.03% when pulling 36bbffb on dmvt:master into c7f7468 on piotrmurach:master.

@dmvt
Copy link
Contributor Author

dmvt commented Feb 12, 2018

Another potential solution to this would be to check for nil in the url at the breadcrumb creation time and present an error. If you'd like me to redo this using that approach, I'm happy to.

@piotrmurach
Copy link
Owner

Hi Dan,

Thanks for using the library!

I don't fully agree with your reasoning. If I understand correctly, you have an issue running your tests as one of the crumbs has nil value for url param. I don't believe this library should be checking for such cases. Firstly, creating or having breadcrumbs with nil links is an application level erroneous condition and that's where I believe it should be fixed. What if a breadcrumb is created without any name, should the library check for that as well? Most importantly, your solution decides that nil value should be substituted for some other string value which may lead to other bugs. Having said that, I would be happy to raise an error during crumb initialization to ensure consistent data.

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.

None yet

3 participants