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

Inventory page shows snail when not logged in #4249

Open
mkllnk opened this issue Sep 9, 2019 · 7 comments
Open

Inventory page shows snail when not logged in #4249

mkllnk opened this issue Sep 9, 2019 · 7 comments
Labels
bug-s4 The bug is annoying, but doesn't prevent from using the platform. Not so many users are impacted. bugsnag tech debt

Comments

@mkllnk
Copy link
Member

mkllnk commented Sep 9, 2019

Description

When visiting the inventory page from a link or a bookmark without logging in before, the application crashes and shows the snail.

Expected Behavior

Redirect to the login page.

Actual Behaviour

Server error display.

Steps to Reproduce

  1. Open a private window.
  2. Go to /admin/inventory

Context

There may be more pages like this.

Severity

bug-s4: it's annoying, but you can use it

Your Environment

  • Version used: v2.4.1

Bugsnag

NoMethodError in admin/variant_overrides#index
undefined method `has_spree_role?' for nil:NilClass

View on Bugsnag

Stacktrace

app/models/enterprise.rb:180 - block in <class:Enterprise>
lib/open_food_network/permissions.rb:192 - managed_enterprises
lib/open_food_network/permissions.rb:29 - variant_override_hubs
app/controllers/admin/variant_overrides_controller.rb:46 - load_data

View full stacktrace

Created by Maikel via Bugsnag

@mkllnk mkllnk added the bugsnag label Sep 9, 2019
@mkllnk mkllnk changed the title NoMethodError in admin/variant_overrides#index Inventory page shows snail when not logged in Sep 9, 2019
@mkllnk mkllnk added the bug-s4 The bug is annoying, but doesn't prevent from using the platform. Not so many users are impacted. label Sep 9, 2019
@agustinariq
Copy link
Contributor

Hello! Can I work on this issue?

@RachL
Copy link
Contributor

RachL commented Oct 7, 2019

@agustinariq of course, you are very welcome to! However it might be something a bit difficult to tackle for a first issue. Don't hesitate to join us on Slack if you have any question!

@agustinariq
Copy link
Contributor

@RachL Great! What I've done so far is to create a method in the ApplicationController to redirect unauthenticated users to the login page and then call it in a before_filter in the problematic controller.

What do you think?

@RachL
Copy link
Contributor

RachL commented Oct 8, 2019

@agustinariq Thanks! I'm afraid I would be able to help you as I'm not a dev :) But maybe one of our @openfoodfoundation/developers can help you.

@luisramos0
Copy link
Contributor

hi @augnustin
I assume this is your attempt: agustinariq@003dc47

I think this will solve the problem, but I think we need to understand the problem.

I think this problem is only occurring in non spree controllers that inherit from /admin/resource_controller
Pages under spree/admin/ that inherit from spree/admin/resource_controller (overridden in OFN) do not have this problem, for example the URL admin/products works perfectly.

Anyway, I think the solution should be added to
Spree::Admin::BaseController.class_eval

@mkllnk
Copy link
Member Author

mkllnk commented Oct 8, 2019

Hi @augnustin!

Another really good strategy to make sure that it works is to first write a test that fails in the same way as described here in the issue. Then you apply your fix and see if it works. In this case, a controller spec would be good.

@mkllnk
Copy link
Member Author

mkllnk commented Jun 14, 2022

This issue has been linked to an error in Bugsnag
NoMethodError in admin/variant_overrides#index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s4 The bug is annoying, but doesn't prevent from using the platform. Not so many users are impacted. bugsnag tech debt
Projects
Status: All the things
Development

No branches or pull requests

4 participants