Disable api auth as there is no Spree api key set

Although Spree::Api::Config[:requires_authentication] is set to false by
default for some unknown reason if not done explicitly Spree still
returns it as false.

This amends the change done in a87c89c83d,
which introduced the bug. As there is no Spree api key set the auth
fails when getting taxons.
This commit is contained in:
Pau Perez
2017-12-01 19:32:37 +11:00
parent a313c99370
commit c646eb3939
2 changed files with 7 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ require 'spree/core/calculated_adjustments_decorator'
require "#{Rails.root}/app/models/spree/payment_method_decorator"
require "#{Rails.root}/app/models/spree/gateway_decorator"
Spree::Api::Config[:requires_authentication] = true
Spree::Api::Config[:requires_authentication] = false
Spree.config do |config|
config.shipping_instructions = true

View File

@@ -15,8 +15,7 @@ module Spree
let(:attributes) { [:id, :name, :supplier, :price, :on_hand, :available_on, :permalink_live] }
before do
stub_authentication!
Spree.user_class.stub :find_by_spree_api_key => current_api_user
allow(controller).to receive(:spree_current_user) { current_api_user }
end
context "as a normal user" do
@@ -109,14 +108,11 @@ module Spree
end
describe '#clone' do
before do
spree_post :clone, product_id: product1.id, format: :json
end
context 'as a normal user' do
sign_in_as_user!
it 'denies access' do
spree_post :clone, product_id: product1.id, format: :json
assert_unauthorized!
end
end
@@ -125,10 +121,12 @@ module Spree
sign_in_as_enterprise_user! [:supplier]
it 'responds with a successful response' do
spree_post :clone, product_id: product1.id, format: :json
expect(response.status).to eq(201)
end
it 'clones the product' do
spree_post :clone, product_id: product1.id, format: :json
expect(json_response['name']).to eq("COPY OF #{product1.name}")
end
end
@@ -137,10 +135,12 @@ module Spree
sign_in_as_admin!
it 'responds with a successful response' do
spree_post :clone, product_id: product1.id, format: :json
expect(response.status).to eq(201)
end
it 'clones the product' do
spree_post :clone, product_id: product1.id, format: :json
expect(json_response['name']).to eq("COPY OF #{product1.name}")
end
end