mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-06 07:29:16 +00:00
BPUR: rearrange acceptance tests
This commit is contained in:
@@ -15,35 +15,48 @@ feature %q{
|
||||
after :all do
|
||||
Capybara.default_wait_time = @default_wait_time
|
||||
end
|
||||
|
||||
describe "listing products" do
|
||||
before :each do
|
||||
login_to_admin_section
|
||||
end
|
||||
|
||||
scenario "listing products" do
|
||||
s1 = FactoryGirl.create(:supplier_enterprise)
|
||||
s2 = FactoryGirl.create(:supplier_enterprise)
|
||||
s3 = FactoryGirl.create(:supplier_enterprise)
|
||||
p = FactoryGirl.create(:product)
|
||||
it "displays a list of products" do
|
||||
p1 = FactoryGirl.create(:product)
|
||||
p2 = FactoryGirl.create(:product)
|
||||
|
||||
p.supplier = s1;
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
click_link 'Bulk Product Edit'
|
||||
visit '/admin/products/bulk_index'
|
||||
|
||||
page.should have_field "product_name", with: p.name
|
||||
page.should have_select "supplier_id", with_options: [s1.name,s2.name,s3.name], selected: s1.name
|
||||
page.should have_field "product_name", with: p1.name
|
||||
page.should have_field "product_name", with: p2.name
|
||||
end
|
||||
|
||||
it "displays a select box for suppliers, with the appropriate supplier selected" do
|
||||
s1 = FactoryGirl.create(:supplier_enterprise)
|
||||
s2 = FactoryGirl.create(:supplier_enterprise)
|
||||
s3 = FactoryGirl.create(:supplier_enterprise)
|
||||
p1 = FactoryGirl.create(:product, supplier: s2)
|
||||
p2 = FactoryGirl.create(:product, supplier: s3)
|
||||
|
||||
visit '/admin/products/bulk_index'
|
||||
|
||||
page.should have_select "supplier_id", with_options: [s1.name,s2.name,s3.name], selected: s2.name
|
||||
page.should have_select "supplier_id", with_options: [s1.name,s2.name,s3.name], selected: s3.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario "create a new product" do
|
||||
s = FactoryGirl.create(:supplier_enterprise)
|
||||
d = FactoryGirl.create(:distributor_enterprise)
|
||||
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
click_link 'Bulk Product Edit'
|
||||
|
||||
|
||||
visit '/admin/products/bulk_index'
|
||||
|
||||
click_link 'New Product'
|
||||
|
||||
|
||||
page.should have_content 'NEW PRODUCT'
|
||||
|
||||
|
||||
fill_in 'product_name', :with => 'Big Bag Of Apples'
|
||||
select(s.name, :from => 'product_supplier_id')
|
||||
choose('product_group_buy_0')
|
||||
@@ -51,7 +64,7 @@ feature %q{
|
||||
fill_in 'product_available_on', :with => Date.today.strftime("%Y/%m/%d")
|
||||
check('product_product_distributions_attributes_0__destroy')
|
||||
click_button 'Create'
|
||||
|
||||
|
||||
URI.parse(current_url).path.should == '/admin/products/bulk_index'
|
||||
flash_message.should == 'Product "Big Bag Of Apples" has been successfully created!'
|
||||
page.should have_field "product_name", with: 'Big Bag Of Apples'
|
||||
@@ -63,21 +76,22 @@ feature %q{
|
||||
s2 = FactoryGirl.create(:supplier_enterprise)
|
||||
p = FactoryGirl.create(:product)
|
||||
p.supplier = s1
|
||||
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
click_link 'Bulk Product Edit'
|
||||
|
||||
|
||||
visit '/admin/products/bulk_index'
|
||||
|
||||
page.should have_field "product_name", with: p.name
|
||||
page.should have_select "supplier_id", selected: s1.name
|
||||
|
||||
|
||||
fill_in "product_name", with: "Big Bag Of Potatoes"
|
||||
select(s2.name, :from => 'supplier_id')
|
||||
|
||||
|
||||
click_button 'Update'
|
||||
page.find("span#update-status-message").should have_content "Update complete"
|
||||
click_link 'Bulk Product Edit'
|
||||
|
||||
|
||||
visit '/admin/products/bulk_index'
|
||||
|
||||
page.should have_field "product_name", with: "Big Bag Of Potatoes"
|
||||
page.should have_select "supplier_id", selected: s2.name
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user