mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update specs
This commit is contained in:
@@ -35,12 +35,6 @@ describe ProductComponent, type: :component do
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
it "joins the categories' name" do
|
||||
expect(page.find('.category')).to have_content(
|
||||
/random 1, random 2/, exact: true, normalize_ws: true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on_hand' do
|
||||
|
||||
@@ -43,9 +43,8 @@ module Reporting
|
||||
allow(variant).to receive_message_chain(:product, :name).and_return("Product Name")
|
||||
allow(variant).to receive_message_chain(:product, :properties)
|
||||
.and_return [double(name: "property1"), double(name: "property2")]
|
||||
allow(variant).to receive_message_chain(:product,
|
||||
:taxons).and_return [double(name: "taxon1"),
|
||||
double(name: "taxon2")]
|
||||
allow(variant).to receive_message_chain(:product, :primary_taxon).
|
||||
and_return double(name: "taxon1")
|
||||
allow(variant).to receive_message_chain(:product, :group_buy_unit_size).and_return(21)
|
||||
allow(subject).to receive(:query_result).and_return [variant]
|
||||
|
||||
@@ -54,7 +53,7 @@ module Reporting
|
||||
"A city",
|
||||
"Product Name",
|
||||
"property1, property2",
|
||||
"taxon1, taxon2",
|
||||
"taxon1",
|
||||
"Variant Name",
|
||||
100,
|
||||
21,
|
||||
|
||||
@@ -6,7 +6,6 @@ describe Spree::Core::ProductDuplicator do
|
||||
let(:product) do
|
||||
double 'Product',
|
||||
name: "foo",
|
||||
taxons: [],
|
||||
product_properties: [property],
|
||||
variants: [variant],
|
||||
image: image
|
||||
@@ -68,7 +67,6 @@ describe Spree::Core::ProductDuplicator do
|
||||
it "can duplicate a product" do
|
||||
duplicator = Spree::Core::ProductDuplicator.new(product)
|
||||
expect(new_product).to receive(:name=).with("COPY OF foo")
|
||||
expect(new_product).to receive(:taxons=).with([])
|
||||
expect(new_product).to receive(:sku=).with("")
|
||||
expect(new_product).to receive(:product_properties=).with([new_property])
|
||||
expect(new_product).to receive(:created_at=).with(nil)
|
||||
|
||||
@@ -703,16 +703,6 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
describe "taxons" do
|
||||
let(:taxon1) { create(:taxon) }
|
||||
let(:taxon2) { create(:taxon) }
|
||||
let(:product) { create(:simple_product) }
|
||||
|
||||
it "returns the first taxon as the primary taxon" do
|
||||
expect(product.taxons).to eq([product.primary_taxon])
|
||||
end
|
||||
end
|
||||
|
||||
describe "deletion" do
|
||||
let(:p) { create(:simple_product) }
|
||||
let(:v) { create(:variant, product: p) }
|
||||
|
||||
@@ -40,12 +40,7 @@ module Spree
|
||||
describe "touches" do
|
||||
let!(:taxon1) { create(:taxon) }
|
||||
let!(:taxon2) { create(:taxon) }
|
||||
let!(:taxon3) { create(:taxon) }
|
||||
let!(:product) { create(:simple_product, primary_taxon: taxon1, taxons: [taxon1, taxon2]) }
|
||||
|
||||
it "is touched when a taxon is applied to a product" do
|
||||
expect{ product.taxons << taxon3 }.to change { taxon3.reload.updated_at }
|
||||
end
|
||||
let!(:product) { create(:simple_product, primary_taxon: taxon1) }
|
||||
|
||||
it "is touched when assignment of primary_taxon on a product changes" do
|
||||
expect do
|
||||
|
||||
@@ -12,10 +12,10 @@ describe Api::EnterpriseShopfrontSerializer do
|
||||
let!(:taxon1) { create(:taxon, name: 'Meat') }
|
||||
let!(:taxon2) { create(:taxon, name: 'Veg') }
|
||||
let!(:product) {
|
||||
create(:product, supplier: producer, primary_taxon: taxon1, taxons: [taxon1, taxon2] )
|
||||
create(:product, supplier: producer, primary_taxon: taxon1 )
|
||||
}
|
||||
let!(:product2) {
|
||||
create(:product, supplier: producer_hidden, primary_taxon: taxon1, taxons: [taxon1, taxon2] )
|
||||
create(:product, supplier: producer_hidden, primary_taxon: taxon2 )
|
||||
}
|
||||
|
||||
let(:close_time) { 2.days.from_now }
|
||||
@@ -67,6 +67,5 @@ describe Api::EnterpriseShopfrontSerializer do
|
||||
it "serializes taxons" do
|
||||
expect(serializer.serializable_hash[:taxons]).to be_a ActiveModel::ArraySerializer
|
||||
expect(serializer.serializable_hash[:taxons].to_json).to match 'Meat'
|
||||
expect(serializer.serializable_hash[:taxons].to_json).to match 'Veg'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ describe Api::ProductSerializer do
|
||||
it "serializes various attributes" do
|
||||
expect(serializer.serializable_hash.keys).to eq [
|
||||
:id, :name, :meta_keywords, :group_buy, :notes, :description, :description_html,
|
||||
:properties_with_values, :variants, :primary_taxon, :taxons, :image, :supplier
|
||||
:properties_with_values, :variants, :primary_taxon, :image, :supplier
|
||||
]
|
||||
end
|
||||
|
||||
@@ -37,8 +37,4 @@ describe Api::ProductSerializer do
|
||||
|
||||
expect(serializer.serializable_hash[:properties_with_values]).to include product_property
|
||||
end
|
||||
|
||||
it "serializes taxons" do
|
||||
expect(serializer.serializable_hash[:taxons]).to eq [id: taxon.id]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -402,8 +402,6 @@ describe '
|
||||
before do
|
||||
product1.set_property 'Organic', 'NASAA 12345'
|
||||
product2.set_property 'Organic', 'NASAA 12345'
|
||||
product1.taxons = [taxon]
|
||||
product2.taxons = [taxon]
|
||||
variant1.on_hand = 10
|
||||
variant1.update!(sku: "sku1")
|
||||
variant2.on_hand = 20
|
||||
|
||||
@@ -11,7 +11,7 @@ describe "Darkswarm data caching", caching: true do
|
||||
create(:distributor_enterprise, with_payment_and_shipping: true, is_primary_producer: true)
|
||||
}
|
||||
let!(:product) {
|
||||
create(:simple_product, supplier: producer, primary_taxon: taxon, taxons: [taxon],
|
||||
create(:simple_product, supplier: producer, primary_taxon: taxon,
|
||||
properties: [property])
|
||||
}
|
||||
let!(:order_cycle) {
|
||||
|
||||
@@ -53,7 +53,7 @@ describe "Shops caching", caching: true do
|
||||
let!(:property) { create(:property, presentation: "Cached Property") }
|
||||
let!(:property2) { create(:property, presentation: "New Property") }
|
||||
let!(:product) {
|
||||
create(:product, taxons: [taxon], primary_taxon: taxon, properties: [property])
|
||||
create(:product, primary_taxon: taxon, properties: [property])
|
||||
}
|
||||
let(:exchange) { order_cycle.exchanges.to_enterprises(distributor).outgoing.first }
|
||||
|
||||
@@ -92,7 +92,6 @@ describe "Shops caching", caching: true do
|
||||
expect(page).to have_content taxon.name
|
||||
expect(page).to have_content property.presentation
|
||||
|
||||
product.taxons << taxon2
|
||||
product.update_attribute(:primary_taxon, taxon2)
|
||||
product.update_attribute(:properties, [property2])
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ describe '
|
||||
let(:taxon_veg) { create(:taxon, name: 'Vegetables') }
|
||||
|
||||
let!(:product1) {
|
||||
create(:simple_product, supplier: producer1, primary_taxon: taxon_fruit, taxons: [taxon_fruit])
|
||||
create(:simple_product, supplier: producer1, primary_taxon: taxon_fruit)
|
||||
}
|
||||
let!(:product2) {
|
||||
create(:simple_product, supplier: producer2, primary_taxon: taxon_veg, taxons: [taxon_veg])
|
||||
create(:simple_product, supplier: producer2, primary_taxon: taxon_veg)
|
||||
}
|
||||
|
||||
let(:shop) { create(:distributor_enterprise) }
|
||||
|
||||
@@ -146,7 +146,7 @@ describe 'Shops' do
|
||||
let!(:closed_oc) {
|
||||
create(:closed_order_cycle, distributors: [shop], variants: [p_closed.variants.first])
|
||||
}
|
||||
let!(:p_closed) { create(:simple_product, primary_taxon: taxon_closed, taxons: [taxon_closed]) }
|
||||
let!(:p_closed) { create(:simple_product, primary_taxon: taxon_closed) }
|
||||
let(:shop) { create(:distributor_enterprise, with_payment_and_shipping: true) }
|
||||
let(:taxon_closed) { create(:taxon, name: 'Closed') }
|
||||
|
||||
@@ -154,7 +154,7 @@ describe 'Shops' do
|
||||
let!(:open_oc) {
|
||||
create(:open_order_cycle, distributors: [shop], variants: [p_open.variants.first])
|
||||
}
|
||||
let!(:p_open) { create(:simple_product, primary_taxon: taxon_open, taxons: [taxon_open]) }
|
||||
let!(:p_open) { create(:simple_product, primary_taxon: taxon_open) }
|
||||
let(:taxon_open) { create(:taxon, name: 'Open') }
|
||||
|
||||
it "shows taxons for open order cycles only" do
|
||||
@@ -207,7 +207,7 @@ describe 'Shops' do
|
||||
end
|
||||
|
||||
describe "hub producer modal" do
|
||||
let!(:product) { create(:simple_product, supplier: producer, taxons: [taxon]) }
|
||||
let!(:product) { create(:simple_product, supplier: producer, primary_taxon: taxon) }
|
||||
let!(:taxon) { create(:taxon, name: 'Fruit') }
|
||||
let!(:order_cycle) {
|
||||
create(
|
||||
|
||||
Reference in New Issue
Block a user