mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
Merge pull request #13318 from dacook/fix-13315
Prevent error on inventory page when logged out
This commit is contained in:
@@ -7,7 +7,7 @@ module Admin
|
||||
include OpenFoodNetwork::SpreeApiKeyLoader
|
||||
include EnterprisesHelper
|
||||
|
||||
prepend_before_action :load_data
|
||||
prepend_before_action :load_data, if: :spree_current_user
|
||||
before_action :load_collection, only: [:bulk_update]
|
||||
before_action :load_spree_api_key, only: :index
|
||||
|
||||
|
||||
@@ -3,6 +3,30 @@
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Admin::VariantOverridesController, type: :controller do
|
||||
describe "index" do
|
||||
context "not logged in" do
|
||||
it "redirects to login" do
|
||||
get :index
|
||||
expect(response).to redirect_to(
|
||||
root_path(anchor: "/login", after_login: admin_inventory_path)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "where I manage the variant override hub" do
|
||||
let(:hub) { create(:distributor_enterprise) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:spree_current_user) { hub.owner }
|
||||
end
|
||||
|
||||
it "succeeds" do
|
||||
get :index
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "bulk_update" do
|
||||
context "json" do
|
||||
let(:format) { :json }
|
||||
|
||||
Reference in New Issue
Block a user