Moving commits from 1241 to trigger build on UK staging

This commit is contained in:
Lynne Davis
2016-12-19 15:06:43 +00:00
parent b075ed373a
commit d77f775c4c
3 changed files with 36 additions and 3 deletions

View File

@@ -4,5 +4,5 @@ Darkswarm.filter 'products', (Matcher) ->
text ?= ""
return products if text == ""
products.filter (product) =>
propertiesToMatch = [product.name, product.supplier.name, product.primary_taxon.name]
propertiesToMatch = [product.name, product.variant_names, product.supplier.name, product.primary_taxon.name]
Matcher.match propertiesToMatch, text

View File

@@ -25,7 +25,6 @@ Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons, Pro
prices = (v.price for v in product.variants)
product.price = Math.min.apply(null, prices)
product.hasVariants = product.variants?.length > 0
product.primaryImage = product.images[0]?.small_url if product.images
product.primaryImageOrMissing = product.primaryImage || "/assets/noimage/small.png"
product.largeImage = product.images[0]?.large_url if product.images
@@ -45,5 +44,7 @@ Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons, Pro
if product.variants
product.variants = for variant in product.variants
variant = Variants.register variant
if product.name != variant.name_to_display
product.variant_names += variant.name_to_display
variant.product = product
variant

View File

@@ -142,7 +142,9 @@ feature "As a consumer I want to shop with a distributor", js: true do
describe "after selecting an order cycle with products visible" do
let(:variant1) { create(:variant, product: product, price: 20) }
let(:variant2) { create(:variant, product: product, price: 30) }
let(:variant2) { create(:variant, product: product, price: 30, display_name: "Badgers") }
let(:product2) { create(:simple_product, supplier: supplier, name: "Meercats") }
let(:variant3) { create(:variant, product: product2, price: 40, display_name: "Ferrets") }
let(:exchange) { Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id) }
before do
@@ -150,6 +152,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
add_variant_to_order_cycle(exchange, variant)
add_variant_to_order_cycle(exchange, variant1)
add_variant_to_order_cycle(exchange, variant2)
add_variant_to_order_cycle(exchange, variant3)
order.order_cycle = oc1
end
@@ -171,6 +174,35 @@ feature "As a consumer I want to shop with a distributor", js: true do
# Product price should be listed as the lesser of these
page.should have_price "$43.00"
end
it "filters search results properly" do
visit shop_path
select "frogs", :from => "order_cycle_id"
fill_in "search", with: "74576345634XXXXXX"
page.should have_content "Sorry, no results found"
page.should_not have_content product2.name
fill_in "search", with: "Meer" # For product named "Meercats"
page.should have_content product2.name
page.should_not have_content product.name
end
it "returns search results for products where the search term matches one of the product's variant names" do
visit shop_path
select "frogs", :from => "order_cycle_id"
fill_in "search", with: "Badg" # For variant with display_name "Badgers"
within('div.pad-top') do
page.should have_content product.name
page.should have_content variant2.display_name
page.should_not have_content product2.name
page.should_not have_content variant3.display_name
end
end
end
describe "group buy products" do