mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
34 lines
1.0 KiB
Ruby
34 lines
1.0 KiB
Ruby
require 'spec_helper'
|
|
|
|
module Spree
|
|
module Admin
|
|
describe VariantsController do
|
|
before { login_as_admin }
|
|
|
|
describe "search action" do
|
|
let!(:p1) { create(:simple_product, name: 'Product 1') }
|
|
let!(:p2) { create(:simple_product, name: 'Product 2') }
|
|
let!(:v1) { p1.variants.first }
|
|
let!(:v2) { p2.variants.first }
|
|
let!(:d) { create(:distributor_enterprise) }
|
|
let!(:oc) { create(:simple_order_cycle, distributors: [d], variants: [v1]) }
|
|
|
|
it "filters by distributor" do
|
|
spree_get :search, q: 'Prod', distributor_id: d.id.to_s
|
|
assigns(:variants).should == [v1]
|
|
end
|
|
|
|
it "filters by order cycle" do
|
|
spree_get :search, q: 'Prod', order_cycle_id: oc.id.to_s
|
|
assigns(:variants).should == [v1]
|
|
end
|
|
|
|
it "does not filter when no distributor or order cycle is specified" do
|
|
spree_get :search, q: 'Prod'
|
|
assigns(:variants).sort.should == [v1,v2].sort
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|