Merge branch 'master' into 3-0-stable-Apr28

This commit is contained in:
Luis Ramos
2020-04-28 13:40:19 +01:00
631 changed files with 15133 additions and 10891 deletions

View File

@@ -92,29 +92,5 @@ module Api
end
end
end
context "as a non-authenticated user" do
let!(:hub) {
create(:distributor_enterprise, with_payment_and_shipping: true, name: 'Shopfront Test Hub')
}
let!(:producer) { create(:supplier_enterprise, name: 'Shopfront Test Producer') }
let!(:category) { create(:taxon, name: 'Fruit') }
let!(:product) { create(:product, supplier: producer, primary_taxon: category ) }
let!(:relationship) { create(:enterprise_relationship, parent: hub, child: producer) }
before do
allow(controller).to receive(:spree_current_user) { nil }
end
describe "fetching shopfronts data" do
it "returns data for an enterprise" do
spree_get :shopfront, id: producer.id, format: :json
expect(json_response['name']).to eq 'Shopfront Test Producer'
expect(json_response['hubs'][0]['name']).to eq 'Shopfront Test Hub'
expect(json_response['supplied_taxons'][0]['name']).to eq 'Fruit'
end
end
end
end
end

View File

@@ -0,0 +1,46 @@
# frozen_string_literal: true
require 'spec_helper'
module Api
describe ShopsController, type: :controller do
include AuthenticationWorkflow
render_views
context "as a non-authenticated user" do
let!(:hub) {
create(:distributor_enterprise, with_payment_and_shipping: true, name: 'Shopfront Test Hub')
}
let!(:producer) { create(:supplier_enterprise, name: 'Shopfront Test Producer') }
let!(:category) { create(:taxon, name: 'Fruit') }
let!(:product) { create(:product, supplier: producer, primary_taxon: category ) }
let!(:relationship) { create(:enterprise_relationship, parent: hub, child: producer) }
let!(:closed_hub1) { create(:distributor_enterprise) }
let!(:closed_hub2) { create(:distributor_enterprise) }
before do
allow(controller).to receive(:spree_current_user) { nil }
end
describe "#show" do
it "returns shopfront data for an enterprise" do
spree_get :show, id: producer.id
expect(json_response['name']).to eq 'Shopfront Test Producer'
expect(json_response['hubs'][0]['name']).to eq 'Shopfront Test Hub'
expect(json_response['supplied_taxons'][0]['name']).to eq 'Fruit'
end
end
describe "#closed_shops" do
it "returns data for all closed shops" do
spree_get :closed_shops, nil
expect(json_response).not_to match hub.name
expect(json_response[0]['id']).to eq closed_hub1.id
expect(json_response[1]['id']).to eq closed_hub2.id
end
end
end
end
end