|
|
|
|
@@ -18,14 +18,14 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_field "product_name", with: p1.name, :visible => true
|
|
|
|
|
page.should have_field "product_name", with: p2.name, :visible => true
|
|
|
|
|
expect(page).to have_field "product_name", with: p1.name, :visible => true
|
|
|
|
|
expect(page).to have_field "product_name", with: p2.name, :visible => true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a message when number of products is zero" do
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_text "No matching products found."
|
|
|
|
|
expect(page).to have_text "No matching products found."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
pending "displays a message when number of products is too great" do
|
|
|
|
|
@@ -33,16 +33,7 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_text "Search returned too many products to display (500+), please apply more search filters to reduce the number of matching products"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays pagination information" do
|
|
|
|
|
p1 = FactoryGirl.create(:product)
|
|
|
|
|
p2 = FactoryGirl.create(:product)
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_text "Displaying 1-2 of 2 products"
|
|
|
|
|
expect(page).to have_text "Search returned too many products to display (500+), please apply more search filters to reduce the number of matching products"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a select box for suppliers, with the appropriate supplier selected" do
|
|
|
|
|
@@ -54,8 +45,8 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select "supplier", with_options: [s1.name,s2.name,s3.name], selected: s2.name
|
|
|
|
|
page.should have_select "supplier", with_options: [s1.name,s2.name,s3.name], selected: s3.name
|
|
|
|
|
expect(page).to have_select "producer", with_options: [s1.name,s2.name,s3.name], selected: s2.name
|
|
|
|
|
expect(page).to have_select "producer", with_options: [s1.name,s2.name,s3.name], selected: s3.name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a date input for available_on for each product, formatted to yyyy-mm-dd hh:mm:ss" do
|
|
|
|
|
@@ -63,11 +54,11 @@ feature %q{
|
|
|
|
|
p2 = FactoryGirl.create(:product, available_on: Date.today-1)
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Toggle Columns").click
|
|
|
|
|
first("li.column-list-item", text: "Available On").click
|
|
|
|
|
first("div#columns_dropdown", :text => "COLUMNS").click
|
|
|
|
|
first("div#columns_dropdown div.menu div.menu_item", text: "Available On").click
|
|
|
|
|
|
|
|
|
|
page.should have_field "available_on", with: p1.available_on.strftime("%F %T")
|
|
|
|
|
page.should have_field "available_on", with: p2.available_on.strftime("%F %T")
|
|
|
|
|
expect(page).to have_field "available_on", with: p1.available_on.strftime("%F %T")
|
|
|
|
|
expect(page).to have_field "available_on", with: p2.available_on.strftime("%F %T")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a price input for each product without variants (ie. for master variant)" do
|
|
|
|
|
@@ -82,9 +73,9 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_field "price", with: "22.0"
|
|
|
|
|
page.should have_field "price", with: "44.0"
|
|
|
|
|
page.should_not have_field "price", with: "66.0", visible: true
|
|
|
|
|
expect(page).to have_field "price", with: "22.0"
|
|
|
|
|
expect(page).to have_field "price", with: "44.0"
|
|
|
|
|
expect(page).to have_no_field "price", with: "66.0", visible: true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays an on hand count input for each product (ie. for master variant) if no regular variants exist" do
|
|
|
|
|
@@ -97,9 +88,9 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should_not have_selector "span[name='on_hand']", text: "0"
|
|
|
|
|
page.should have_field "on_hand", with: "15"
|
|
|
|
|
page.should have_field "on_hand", with: "12"
|
|
|
|
|
expect(page).to have_no_selector "span[name='on_hand']", text: "0"
|
|
|
|
|
expect(page).to have_field "on_hand", with: "15"
|
|
|
|
|
expect(page).to have_field "on_hand", with: "12"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays an on hand count in a span for each product (ie. for master variant) if other variants exist" do
|
|
|
|
|
@@ -113,9 +104,9 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should_not have_field "on_hand", with: "15"
|
|
|
|
|
page.should have_selector "span[name='on_hand']", text: "4"
|
|
|
|
|
page.should have_field "on_hand", with: "12"
|
|
|
|
|
expect(page).to have_no_field "on_hand", with: "15"
|
|
|
|
|
expect(page).to have_selector "span[name='on_hand']", text: "4"
|
|
|
|
|
expect(page).to have_field "on_hand", with: "12"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays 'on demand' for the on hand count when the product is available on demand" do
|
|
|
|
|
@@ -124,8 +115,8 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "span[name='on_hand']", text: "On demand"
|
|
|
|
|
page.should_not have_field "on_hand", visible: true
|
|
|
|
|
expect(page).to have_selector "span[name='on_hand']", text: "On demand"
|
|
|
|
|
expect(page).to have_no_field "on_hand", visible: true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays 'on demand' for any variant that is available on demand" do
|
|
|
|
|
@@ -136,10 +127,10 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
first("a.view-variants").trigger('click')
|
|
|
|
|
|
|
|
|
|
page.should_not have_selector "span[name='on_hand']", text: "On demand", visible: true
|
|
|
|
|
page.should have_field "variant_on_hand", with: "4"
|
|
|
|
|
page.should_not have_field "variant_on_hand", with: "", visible: true
|
|
|
|
|
page.should have_selector "span[name='variant_on_hand']", text: "On demand"
|
|
|
|
|
expect(page).to have_no_selector "span[name='on_hand']", text: "On demand", visible: true
|
|
|
|
|
expect(page).to have_field "variant_on_hand", with: "4"
|
|
|
|
|
expect(page).to have_no_field "variant_on_hand", with: "", visible: true
|
|
|
|
|
expect(page).to have_selector "span[name='variant_on_hand']", text: "On demand"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a select box for the unit of measure for the product's variants" do
|
|
|
|
|
@@ -147,7 +138,7 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select "variant_unit_with_scale", selected: "Weight (g)"
|
|
|
|
|
expect(page).to have_select "variant_unit_with_scale", selected: "Weight (g)"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a text field for the item name when unit is set to 'Items'" do
|
|
|
|
|
@@ -155,8 +146,8 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select "variant_unit_with_scale", selected: "Items"
|
|
|
|
|
page.should have_field "variant_unit_name", with: "packet"
|
|
|
|
|
expect(page).to have_select "variant_unit_with_scale", selected: "Items"
|
|
|
|
|
expect(page).to have_field "variant_unit_name", with: "packet"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -170,13 +161,13 @@ feature %q{
|
|
|
|
|
v2 = FactoryGirl.create(:variant, display_name: "something2" )
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
page.should have_selector "a.view-variants"
|
|
|
|
|
expect(page).to have_selector "a.view-variants"
|
|
|
|
|
all("a.view-variants").each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_field "product_name", with: v1.product.name
|
|
|
|
|
page.should have_field "product_name", with: v2.product.name
|
|
|
|
|
page.should have_field "variant_display_name", with: v1.display_name
|
|
|
|
|
page.should have_field "variant_display_name", with: v2.display_name
|
|
|
|
|
expect(page).to have_field "product_name", with: v1.product.name
|
|
|
|
|
expect(page).to have_field "product_name", with: v2.product.name
|
|
|
|
|
expect(page).to have_field "variant_display_name", with: v1.display_name
|
|
|
|
|
expect(page).to have_field "variant_display_name", with: v2.display_name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays an on_hand input (for each variant) for each product" do
|
|
|
|
|
@@ -187,9 +178,9 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
all("a.view-variants").each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_selector "span[name='on_hand']", text: "21"
|
|
|
|
|
page.should have_field "variant_on_hand", with: "15"
|
|
|
|
|
page.should have_field "variant_on_hand", with: "6"
|
|
|
|
|
expect(page).to have_selector "span[name='on_hand']", text: "21"
|
|
|
|
|
expect(page).to have_field "variant_on_hand", with: "15"
|
|
|
|
|
expect(page).to have_field "variant_on_hand", with: "6"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -201,9 +192,9 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
all("a.view-variants").each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_field "price", with: "2.0", visible: false
|
|
|
|
|
page.should have_field "variant_price", with: "12.75"
|
|
|
|
|
page.should have_field "variant_price", with: "2.5"
|
|
|
|
|
expect(page).to have_field "price", with: "2.0", visible: false
|
|
|
|
|
expect(page).to have_field "variant_price", with: "12.75"
|
|
|
|
|
expect(page).to have_field "variant_price", with: "2.5"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays a unit value field (for each variant) for each product" do
|
|
|
|
|
@@ -214,10 +205,10 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
all("a.view-variants").each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_field "variant_unit_value_with_description", with: "1.2 (small bag)"
|
|
|
|
|
page.should have_field "variant_unit_value_with_description", with: "4.8 (large bag)"
|
|
|
|
|
page.should have_field "variant_display_as", with: "bag"
|
|
|
|
|
page.should have_field "variant_display_as", with: "bin"
|
|
|
|
|
expect(page).to have_field "variant_unit_value_with_description", with: "1.2 (small bag)"
|
|
|
|
|
expect(page).to have_field "variant_unit_value_with_description", with: "4.8 (large bag)"
|
|
|
|
|
expect(page).to have_field "variant_display_as", with: "bag"
|
|
|
|
|
expect(page).to have_field "variant_display_as", with: "bin"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -232,7 +223,7 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
find("a", text: "NEW PRODUCT").click
|
|
|
|
|
page.should have_content 'NEW PRODUCT'
|
|
|
|
|
expect(page).to have_content 'NEW PRODUCT'
|
|
|
|
|
|
|
|
|
|
fill_in 'product_name', :with => 'Big Bag Of Apples'
|
|
|
|
|
select(s.name, :from => 'product_supplier_id')
|
|
|
|
|
@@ -240,9 +231,9 @@ feature %q{
|
|
|
|
|
select taxon.name, from: 'product_primary_taxon_id'
|
|
|
|
|
click_button 'Create'
|
|
|
|
|
|
|
|
|
|
URI.parse(current_url).path.should == '/admin/products/bulk_edit'
|
|
|
|
|
flash_message.should == 'Product "Big Bag Of Apples" has been successfully created!'
|
|
|
|
|
page.should have_field "product_name", with: 'Big Bag Of Apples'
|
|
|
|
|
expect(URI.parse(current_url).path).to eq '/admin/products/bulk_edit'
|
|
|
|
|
expect(flash_message).to eq 'Product "Big Bag Of Apples" has been successfully created!'
|
|
|
|
|
expect(page).to have_field "product_name", with: 'Big Bag Of Apples'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -253,13 +244,13 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
# I should not see an add variant button
|
|
|
|
|
page.should_not have_selector 'a.add-variant', visible: true
|
|
|
|
|
expect(page).to have_no_selector 'a.add-variant', visible: true
|
|
|
|
|
|
|
|
|
|
# When I set the unit
|
|
|
|
|
select "Weight (kg)", from: "variant_unit_with_scale"
|
|
|
|
|
|
|
|
|
|
# I should see an add variant button
|
|
|
|
|
page.should have_selector 'a.add-variant', visible: true
|
|
|
|
|
expect(page).to have_selector 'a.add-variant', visible: true
|
|
|
|
|
|
|
|
|
|
# When I add three variants
|
|
|
|
|
page.find('a.add-variant', visible: true).trigger('click')
|
|
|
|
|
@@ -267,13 +258,15 @@ feature %q{
|
|
|
|
|
page.find('a.add-variant', visible: true).trigger('click')
|
|
|
|
|
|
|
|
|
|
# They should be added, and should see no edit buttons
|
|
|
|
|
page.all("tr.variant").count.should == 3
|
|
|
|
|
page.should_not have_selector "a.edit-variant", visible: true
|
|
|
|
|
variant_count = page.all("tr.variant").count
|
|
|
|
|
expect(variant_count).to eq 3
|
|
|
|
|
expect(page).to have_no_selector "a.edit-variant", visible: true
|
|
|
|
|
|
|
|
|
|
# When I remove two, they should be removed
|
|
|
|
|
page.all('a.delete-variant').first.click
|
|
|
|
|
page.all('a.delete-variant').first.click
|
|
|
|
|
page.all("tr.variant").count.should == 1
|
|
|
|
|
variant_count = page.all("tr.variant").count
|
|
|
|
|
expect(variant_count).to eq 1
|
|
|
|
|
|
|
|
|
|
# When I fill out variant details and hit update
|
|
|
|
|
fill_in "variant_display_name", with: "Case of 12 Bottles"
|
|
|
|
|
@@ -282,18 +275,18 @@ feature %q{
|
|
|
|
|
fill_in "variant_price", with: "4.0"
|
|
|
|
|
fill_in "variant_on_hand", with: "10"
|
|
|
|
|
click_button 'Update'
|
|
|
|
|
page.find("span#update-status-message").should have_content "Update complete"
|
|
|
|
|
expect(page.find("span#update-status-message")).to have_content "Update complete"
|
|
|
|
|
|
|
|
|
|
updated_variant = Spree::Variant.where(deleted_at: nil).last
|
|
|
|
|
updated_variant.display_name.should == "Case of 12 Bottles"
|
|
|
|
|
updated_variant.unit_value.should == 3000
|
|
|
|
|
updated_variant.unit_description.should == "(12x250 mL bottles)"
|
|
|
|
|
updated_variant.display_as.should == "Case"
|
|
|
|
|
updated_variant.price.should == 4.0
|
|
|
|
|
updated_variant.on_hand.should == 10
|
|
|
|
|
expect(updated_variant.display_name).to eq "Case of 12 Bottles"
|
|
|
|
|
expect(updated_variant.unit_value).to eq 3000
|
|
|
|
|
expect(updated_variant.unit_description).to eq "(12x250 mL bottles)"
|
|
|
|
|
expect(updated_variant.display_as).to eq "Case"
|
|
|
|
|
expect(updated_variant.price).to eq 4.0
|
|
|
|
|
expect(updated_variant.on_hand).to eq 10
|
|
|
|
|
|
|
|
|
|
# Then I should see edit buttons for the new variant
|
|
|
|
|
page.should have_selector "a.edit-variant", visible: true
|
|
|
|
|
expect(page).to have_selector "a.edit-variant", visible: true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -309,18 +302,18 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Toggle Columns").click
|
|
|
|
|
first("li.column-list-item", text: "Available On").click
|
|
|
|
|
first("div#columns_dropdown", :text => "COLUMNS").click
|
|
|
|
|
first("div#columns_dropdown div.menu div.menu_item", text: "Available On").click
|
|
|
|
|
|
|
|
|
|
page.should have_field "product_name", with: p.name
|
|
|
|
|
page.should have_select "supplier", selected: s1.name
|
|
|
|
|
page.should have_field "available_on", with: p.available_on.strftime("%F %T")
|
|
|
|
|
page.should have_field "price", with: "10.0"
|
|
|
|
|
page.should have_select "variant_unit_with_scale", selected: "Volume (L)"
|
|
|
|
|
page.should have_field "on_hand", with: "6"
|
|
|
|
|
expect(page).to have_field "product_name", with: p.name
|
|
|
|
|
expect(page).to have_select "producer", selected: s1.name
|
|
|
|
|
expect(page).to have_field "available_on", with: p.available_on.strftime("%F %T")
|
|
|
|
|
expect(page).to have_field "price", with: "10.0"
|
|
|
|
|
expect(page).to have_select "variant_unit_with_scale", selected: "Volume (L)"
|
|
|
|
|
expect(page).to have_field "on_hand", with: "6"
|
|
|
|
|
|
|
|
|
|
fill_in "product_name", with: "Big Bag Of Potatoes"
|
|
|
|
|
select(s2.name, :from => 'supplier')
|
|
|
|
|
select(s2.name, :from => 'producer')
|
|
|
|
|
fill_in "available_on", with: (Date.today-3).strftime("%F %T")
|
|
|
|
|
fill_in "price", with: "20"
|
|
|
|
|
select "Weight (kg)", from: "variant_unit_with_scale"
|
|
|
|
|
@@ -328,17 +321,17 @@ feature %q{
|
|
|
|
|
fill_in "display_as", with: "Big Bag"
|
|
|
|
|
|
|
|
|
|
click_button 'Update'
|
|
|
|
|
page.find("span#update-status-message").should have_content "Update complete"
|
|
|
|
|
expect(page.find("span#update-status-message")).to have_content "Update complete"
|
|
|
|
|
|
|
|
|
|
p.reload
|
|
|
|
|
p.name.should == "Big Bag Of Potatoes"
|
|
|
|
|
p.supplier.should == s2
|
|
|
|
|
p.variant_unit.should == "weight"
|
|
|
|
|
p.variant_unit_scale.should == 1000 # Kg
|
|
|
|
|
p.available_on.should == 3.days.ago.beginning_of_day
|
|
|
|
|
p.master.display_as.should == "Big Bag"
|
|
|
|
|
p.price.should == 20.0
|
|
|
|
|
p.on_hand.should == 18
|
|
|
|
|
expect(p.name).to eq "Big Bag Of Potatoes"
|
|
|
|
|
expect(p.supplier).to eq s2
|
|
|
|
|
expect(p.variant_unit).to eq "weight"
|
|
|
|
|
expect(p.variant_unit_scale).to eq 1000 # Kg
|
|
|
|
|
expect(p.available_on).to eq 3.days.ago.beginning_of_day
|
|
|
|
|
expect(p.master.display_as).to eq "Big Bag"
|
|
|
|
|
expect(p.price).to eq 20.0
|
|
|
|
|
expect(p.on_hand).to eq 18
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario "updating a product with a variant unit of 'items'" do
|
|
|
|
|
@@ -348,7 +341,7 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select "variant_unit_with_scale", selected: "Weight (kg)"
|
|
|
|
|
expect(page).to have_select "variant_unit_with_scale", selected: "Weight (kg)"
|
|
|
|
|
|
|
|
|
|
select "Items", from: "variant_unit_with_scale"
|
|
|
|
|
fill_in "variant_unit_name", with: "loaf"
|
|
|
|
|
@@ -370,7 +363,7 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select "variant_unit_with_scale", selected: ''
|
|
|
|
|
expect(page).to have_select "variant_unit_with_scale", selected: ''
|
|
|
|
|
|
|
|
|
|
select "Weight (kg)", from: "variant_unit_with_scale"
|
|
|
|
|
first("a.view-variants").trigger('click')
|
|
|
|
|
@@ -395,8 +388,8 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select "variant_unit_with_scale", selected: ''
|
|
|
|
|
page.should_not have_field "master_unit_value_with_description", visible: true
|
|
|
|
|
expect(page).to have_select "variant_unit_with_scale", selected: ''
|
|
|
|
|
expect(page).to have_no_field "master_unit_value_with_description", visible: true
|
|
|
|
|
|
|
|
|
|
select "Weight (kg)", from: "variant_unit_with_scale"
|
|
|
|
|
fill_in "master_unit_value_with_description", with: '123 abc'
|
|
|
|
|
@@ -420,7 +413,7 @@ feature %q{
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
select "Weight (kg)", from: "variant_unit_with_scale"
|
|
|
|
|
page.should_not have_field "master_unit_value_with_description", visible: true
|
|
|
|
|
expect(page).to have_no_field "master_unit_value_with_description", visible: true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -434,20 +427,20 @@ feature %q{
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
page.should have_selector "a.view-variants"
|
|
|
|
|
expect(page).to have_selector "a.view-variants"
|
|
|
|
|
first("a.view-variants").trigger('click')
|
|
|
|
|
|
|
|
|
|
page.should have_field "variant_price", with: "3.0"
|
|
|
|
|
page.should have_field "variant_unit_value_with_description", with: "250 (bottle)"
|
|
|
|
|
page.should have_field "variant_on_hand", with: "9"
|
|
|
|
|
page.should have_selector "span[name='on_hand']", text: "9"
|
|
|
|
|
expect(page).to have_field "variant_price", with: "3.0"
|
|
|
|
|
expect(page).to have_field "variant_unit_value_with_description", with: "250 (bottle)"
|
|
|
|
|
expect(page).to have_field "variant_on_hand", with: "9"
|
|
|
|
|
expect(page).to have_selector "span[name='on_hand']", text: "9"
|
|
|
|
|
|
|
|
|
|
select "Volume (L)", from: "variant_unit_with_scale"
|
|
|
|
|
fill_in "variant_price", with: "4.0"
|
|
|
|
|
fill_in "variant_on_hand", with: "10"
|
|
|
|
|
fill_in "variant_unit_value_with_description", with: "2 (8x250 mL bottles)"
|
|
|
|
|
|
|
|
|
|
page.should have_selector "span[name='on_hand']", text: "10"
|
|
|
|
|
expect(page).to have_selector "span[name='on_hand']", text: "10"
|
|
|
|
|
|
|
|
|
|
click_button 'Update'
|
|
|
|
|
page.find("span#update-status-message").should have_content "Update complete"
|
|
|
|
|
@@ -466,10 +459,10 @@ feature %q{
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
page.should have_selector "a.view-variants"
|
|
|
|
|
expect(page).to have_selector "a.view-variants"
|
|
|
|
|
first("a.view-variants").trigger('click')
|
|
|
|
|
|
|
|
|
|
page.should have_field "variant_price", with: "3.0"
|
|
|
|
|
expect(page).to have_field "variant_price", with: "3.0"
|
|
|
|
|
|
|
|
|
|
fill_in "variant_price", with: "10.0"
|
|
|
|
|
|
|
|
|
|
@@ -486,7 +479,7 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_field "product_name", with: "original name"
|
|
|
|
|
expect(page).to have_field "product_name", with: "original name"
|
|
|
|
|
|
|
|
|
|
fill_in "product_name", with: "new name 1"
|
|
|
|
|
|
|
|
|
|
@@ -545,14 +538,14 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6", :text => "Filter Products"
|
|
|
|
|
expect(page).to have_selector "div.option_tab_titles h6", :text => "Filter Products"
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Filter Products").click
|
|
|
|
|
|
|
|
|
|
select2_select "Name", from: "filter_property"
|
|
|
|
|
select2_select "Contains", from: "filter_predicate"
|
|
|
|
|
fill_in "filter_value", :with => "1"
|
|
|
|
|
click_button "Apply Filter"
|
|
|
|
|
page.should_not have_field "product_name", with: p2.name
|
|
|
|
|
expect(page).to have_no_field "product_name", with: p2.name
|
|
|
|
|
fill_in "product_name", :with => "new product1"
|
|
|
|
|
|
|
|
|
|
click_on 'Update'
|
|
|
|
|
@@ -561,22 +554,6 @@ feature %q{
|
|
|
|
|
p1.name.should == "new product1"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario "updating a product when there are more products than the default API page size" do
|
|
|
|
|
p = FactoryGirl.create(:simple_product)
|
|
|
|
|
25.times { FactoryGirl.create(:simple_product) }
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
within "tr#p_#{p.id}" do
|
|
|
|
|
fill_in 'product_name', with: "new name"
|
|
|
|
|
end
|
|
|
|
|
click_button 'Update'
|
|
|
|
|
page.find("span#update-status-message").should have_content "Update complete"
|
|
|
|
|
p.reload
|
|
|
|
|
p.name.should == "new name"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "using action buttons" do
|
|
|
|
|
describe "using delete buttons" do
|
|
|
|
|
it "shows a delete button for products, which deletes the appropriate product when clicked" do
|
|
|
|
|
@@ -587,15 +564,15 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.delete-product", :count => 3
|
|
|
|
|
expect(page).to have_selector "a.delete-product", :count => 3
|
|
|
|
|
|
|
|
|
|
first("a.delete-product").click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.delete-product", :count => 2
|
|
|
|
|
expect(page).to have_selector "a.delete-product", :count => 2
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.delete-product", :count => 2
|
|
|
|
|
expect(page).to have_selector "a.delete-product", :count => 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "shows a delete button for variants, which deletes the appropriate variant when clicked" do
|
|
|
|
|
@@ -605,20 +582,20 @@ feature %q{
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
page.should have_selector "a.view-variants"
|
|
|
|
|
expect(page).to have_selector "a.view-variants"
|
|
|
|
|
all("a.view-variants").each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.delete-variant", :count => 3
|
|
|
|
|
expect(page).to have_selector "a.delete-variant", :count => 3
|
|
|
|
|
|
|
|
|
|
first("a.delete-variant").click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.delete-variant", :count => 2
|
|
|
|
|
expect(page).to have_selector "a.delete-variant", :count => 2
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
page.should have_selector "a.view-variants"
|
|
|
|
|
expect(page).to have_selector "a.view-variants"
|
|
|
|
|
all("a.view-variants").select { |e| e.visible? }.each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.delete-variant", :count => 2
|
|
|
|
|
expect(page).to have_selector "a.delete-variant", :count => 2
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -631,7 +608,7 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.edit-product", :count => 3
|
|
|
|
|
expect(page).to have_selector "a.edit-product", :count => 3
|
|
|
|
|
|
|
|
|
|
first("a.edit-product").click
|
|
|
|
|
|
|
|
|
|
@@ -645,12 +622,14 @@ feature %q{
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
page.should have_selector "a.view-variants"
|
|
|
|
|
expect(page).to have_selector "a.view-variants"
|
|
|
|
|
all("a.view-variants").each { |e| e.trigger('click') }
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.edit-variant", :count => 3
|
|
|
|
|
expect(page).to have_selector "a.edit-variant", :count => 3
|
|
|
|
|
|
|
|
|
|
first("a.edit-variant").click
|
|
|
|
|
within "tr#v_#{v1.id}" do
|
|
|
|
|
first("a.edit-variant").click
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
URI.parse(current_url).path.should == "/admin/products/#{v1.product.permalink}/variants/#{v1.id}/edit"
|
|
|
|
|
end
|
|
|
|
|
@@ -665,159 +644,48 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.clone-product", :count => 3
|
|
|
|
|
expect(page).to have_selector "a.clone-product", :count => 3
|
|
|
|
|
|
|
|
|
|
first("a.clone-product").click
|
|
|
|
|
page.should have_selector "a.clone-product", :count => 4
|
|
|
|
|
page.should have_field "product_name", with: "COPY OF #{p1.name}"
|
|
|
|
|
page.should have_select "supplier", selected: "#{p1.supplier.name}"
|
|
|
|
|
within "tr#p_#{p1.id}" do
|
|
|
|
|
first("a.clone-product").click
|
|
|
|
|
end
|
|
|
|
|
expect(page).to have_selector "a.clone-product", :count => 4
|
|
|
|
|
expect(page).to have_field "product_name", with: "COPY OF #{p1.name}"
|
|
|
|
|
expect(page).to have_select "producer", selected: "#{p1.supplier.name}"
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "a.clone-product", :count => 4
|
|
|
|
|
page.should have_field "product_name", with: "COPY OF #{p1.name}"
|
|
|
|
|
page.should have_select "supplier", selected: "#{p1.supplier.name}"
|
|
|
|
|
expect(page).to have_selector "a.clone-product", :count => 4
|
|
|
|
|
expect(page).to have_field "product_name", with: "COPY OF #{p1.name}"
|
|
|
|
|
expect(page).to have_select "producer", selected: "#{p1.supplier.name}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "using the page" do
|
|
|
|
|
describe "using tabs to hide and display page controls" do
|
|
|
|
|
it "shows a column display toggle button, which shows a list of columns when clicked" do
|
|
|
|
|
FactoryGirl.create(:simple_product)
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.column_toggle", :visible => false
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.unselected", :text => "Toggle Columns"
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Toggle Columns").click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.selected", :text => "Toggle Columns"
|
|
|
|
|
page.should have_selector "div.column_toggle", :visible => true
|
|
|
|
|
page.should have_selector "li.column-list-item", text: "Available On"
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.filters", :visible => false
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.unselected", :text => "Filter Products"
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Filter Products").click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.unselected", :text => "Toggle Columns"
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.selected", :text => "Filter Products"
|
|
|
|
|
page.should have_selector "div.filters", :visible => true
|
|
|
|
|
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Filter Products").click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.unselected", :text => "Filter Products"
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6.unselected", :text => "Toggle Columns"
|
|
|
|
|
page.should have_selector "div.filters", :visible => false
|
|
|
|
|
page.should have_selector "div.column_toggle", :visible => false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "using column display toggle" do
|
|
|
|
|
it "shows a column display toggle button, which shows a list of columns when clicked" do
|
|
|
|
|
describe "using column display dropdown" do
|
|
|
|
|
it "shows a column display dropdown, which shows a list of columns when clicked" do
|
|
|
|
|
FactoryGirl.create(:simple_product)
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Toggle Columns").click
|
|
|
|
|
first("li.column-list-item", text: "Available On").click
|
|
|
|
|
first("div#columns_dropdown", :text => "COLUMNS").click
|
|
|
|
|
first("div#columns_dropdown div.menu div.menu_item", text: "Available On").click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "th", :text => "NAME"
|
|
|
|
|
page.should have_selector "th", :text => "SUPPLIER"
|
|
|
|
|
page.should have_selector "th", :text => "PRICE"
|
|
|
|
|
page.should have_selector "th", :text => "ON HAND"
|
|
|
|
|
page.should have_selector "th", :text => "AV. ON"
|
|
|
|
|
expect(page).to have_selector "th", :text => "NAME"
|
|
|
|
|
expect(page).to have_selector "th", :text => "PRODUCER"
|
|
|
|
|
expect(page).to have_selector "th", :text => "PRICE"
|
|
|
|
|
expect(page).to have_selector "th", :text => "ON HAND"
|
|
|
|
|
expect(page).to have_selector "th", :text => "AV. ON"
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6", :text => "Toggle Columns"
|
|
|
|
|
first("div#columns_dropdown div.menu div.menu_item", text: /.{0,1}Producer/).click
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div ul.column-list li.column-list-item", text: "Supplier"
|
|
|
|
|
first("li.column-list-item", text: "Supplier").click
|
|
|
|
|
|
|
|
|
|
page.should_not have_selector "th", :text => "SUPPLIER"
|
|
|
|
|
page.should have_selector "th", :text => "NAME"
|
|
|
|
|
page.should have_selector "th", :text => "PRICE"
|
|
|
|
|
page.should have_selector "th", :text => "ON HAND"
|
|
|
|
|
page.should have_selector "th", :text => "AV. ON"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "using pagination controls" do
|
|
|
|
|
it "shows pagination controls" do
|
|
|
|
|
27.times { FactoryGirl.create(:product) }
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select 'perPage', :selected => '25'
|
|
|
|
|
within '.pagination' do
|
|
|
|
|
page.should have_text "1 2"
|
|
|
|
|
page.should have_text "Next"
|
|
|
|
|
page.should have_text "Last"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "allows the number of visible products to be altered" do
|
|
|
|
|
27.times { FactoryGirl.create(:product) }
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
select '25', :from => 'perPage'
|
|
|
|
|
page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 25
|
|
|
|
|
select '50', :from => 'perPage'
|
|
|
|
|
page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 27
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays the correct products when changing pages" do
|
|
|
|
|
25.times { FactoryGirl.create(:product, :name => "page1product") }
|
|
|
|
|
5.times { FactoryGirl.create(:product, :name => "page2product") }
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
select '25', :from => 'perPage'
|
|
|
|
|
page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page1product" }.should == true
|
|
|
|
|
find("a", text: "2").click
|
|
|
|
|
page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page2product" }.should == true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "moves the user to the last available page when changing the number of pages in any way causes user to become orphaned" do
|
|
|
|
|
50.times { FactoryGirl.create(:product) }
|
|
|
|
|
FactoryGirl.create(:product, :name => "fancy_product_name")
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
select '25', :from => 'perPage'
|
|
|
|
|
find("a", text: "3").click
|
|
|
|
|
select '50', :from => 'perPage'
|
|
|
|
|
page.first("div.pagenav span.page.current").should have_text "2"
|
|
|
|
|
page.all("input[name='product_name']", :visible => true).length.should == 1
|
|
|
|
|
|
|
|
|
|
select '25', :from => 'perPage'
|
|
|
|
|
fill_in "quick_filter", :with => "fancy_product_name"
|
|
|
|
|
page.first("div.pagenav span.page.current").should have_text "1"
|
|
|
|
|
page.all("input[name='product_name']", :visible => true).length.should == 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "paginates the filtered product list rather than all products" do
|
|
|
|
|
25.times { FactoryGirl.create(:product, :name => "product_name") }
|
|
|
|
|
3.times { FactoryGirl.create(:product, :name => "test_product_name") }
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
select '25', :from => 'perPage'
|
|
|
|
|
page.should have_text "1 2"
|
|
|
|
|
fill_in "quick_filter", :with => "test_product_name"
|
|
|
|
|
page.all("input[name='product_name']", :visible => true).length.should == 3
|
|
|
|
|
page.all("input[name='product_name']", :visible => true).all?{ |e| e.value == "test_product_name" }.should == true
|
|
|
|
|
page.should_not have_text "1 2"
|
|
|
|
|
page.should have_text "1"
|
|
|
|
|
expect(page).to have_no_selector "th", :text => "PRODUCER"
|
|
|
|
|
expect(page).to have_selector "th", :text => "NAME"
|
|
|
|
|
expect(page).to have_selector "th", :text => "PRICE"
|
|
|
|
|
expect(page).to have_selector "th", :text => "ON HAND"
|
|
|
|
|
expect(page).to have_selector "th", :text => "AV. ON"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -828,12 +696,12 @@ feature %q{
|
|
|
|
|
login_to_admin_section
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_selector "div.option_tab_titles h6", :text => "Filter Products"
|
|
|
|
|
expect(page).to have_selector "div.option_tab_titles h6", :text => "Filter Products"
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Filter Products").click
|
|
|
|
|
|
|
|
|
|
page.should have_select "filter_property", visible: false
|
|
|
|
|
page.should have_select "filter_predicate", visible: false
|
|
|
|
|
page.should have_field "filter_value"
|
|
|
|
|
expect(page).to have_select "filter_property", visible: false
|
|
|
|
|
expect(page).to have_select "filter_predicate", visible: false
|
|
|
|
|
expect(page).to have_field "filter_value"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "clicking the 'Apply Filter' Button" do
|
|
|
|
|
@@ -853,16 +721,16 @@ feature %q{
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "adds a new filter to the list of applied filters" do
|
|
|
|
|
page.should have_text "Name Equals Product1"
|
|
|
|
|
expect(page).to have_text "Name Equals Product1"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays the 'loading' splash" do
|
|
|
|
|
page.should have_selector "div.loading", :text => "Loading Products..."
|
|
|
|
|
expect(page).to have_selector "div.loading", :text => "Loading Products..."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "loads appropriate products" do
|
|
|
|
|
page.should have_field "product_name", :with => "Product1"
|
|
|
|
|
page.should_not have_field "product_name", :with => "Product2"
|
|
|
|
|
expect(page).to have_field "product_name", :with => "Product1"
|
|
|
|
|
expect(page).to have_no_field "product_name", :with => "Product2"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "clicking the 'Remove Filter' link" do
|
|
|
|
|
@@ -871,12 +739,12 @@ feature %q{
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "removes the filter from the list of applied filters" do
|
|
|
|
|
page.should_not have_text "Name Equals Product1"
|
|
|
|
|
expect(page).to have_no_text "Name Equals Product1"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "loads appropriate products" do
|
|
|
|
|
page.should have_field "product_name", :with => "Product1"
|
|
|
|
|
page.should have_field "product_name", :with => "Product2"
|
|
|
|
|
expect(page).to have_field "product_name", :with => "Product1"
|
|
|
|
|
expect(page).to have_field "product_name", :with => "Product2"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@@ -905,15 +773,15 @@ feature %q{
|
|
|
|
|
it "shows only products that I supply" do
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_field 'product_name', with: product_supplied.name
|
|
|
|
|
page.should_not have_field 'product_name', with: product_not_supplied.name
|
|
|
|
|
expect(page).to have_field 'product_name', with: product_supplied.name
|
|
|
|
|
expect(page).to have_no_field 'product_name', with: product_not_supplied.name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "shows only suppliers that I manage" do
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_select 'supplier', with_options: [s1.name, s2.name], selected: s1.name
|
|
|
|
|
page.should_not have_select 'supplier', with_options: [s3.name]
|
|
|
|
|
expect(page).to have_select 'producer', with_options: [s1.name, s2.name], selected: s1.name
|
|
|
|
|
expect(page).to have_no_select 'producer', with_options: [s3.name]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "shows inactive products that I supply" do
|
|
|
|
|
@@ -921,24 +789,24 @@ feature %q{
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
|
|
|
|
|
page.should have_field 'product_name', with: product_supplied_inactive.name
|
|
|
|
|
expect(page).to have_field 'product_name', with: product_supplied_inactive.name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "allows me to update a product" do
|
|
|
|
|
p = product_supplied
|
|
|
|
|
|
|
|
|
|
visit '/admin/products/bulk_edit'
|
|
|
|
|
first("div.option_tab_titles h6", :text => "Toggle Columns").click
|
|
|
|
|
first("li.column-list-item", text: "Available On").click
|
|
|
|
|
first("div#columns_dropdown", :text => "COLUMNS").click
|
|
|
|
|
first("div#columns_dropdown div.menu div.menu_item", text: "Available On").click
|
|
|
|
|
|
|
|
|
|
page.should have_field "product_name", with: p.name
|
|
|
|
|
page.should have_select "supplier", selected: s1.name
|
|
|
|
|
page.should have_field "available_on", with: p.available_on.strftime("%F %T")
|
|
|
|
|
page.should have_field "price", with: "10.0"
|
|
|
|
|
page.should have_field "on_hand", with: "6"
|
|
|
|
|
expect(page).to have_field "product_name", with: p.name
|
|
|
|
|
expect(page).to have_select "producer", selected: s1.name
|
|
|
|
|
expect(page).to have_field "available_on", with: p.available_on.strftime("%F %T")
|
|
|
|
|
expect(page).to have_field "price", with: "10.0"
|
|
|
|
|
expect(page).to have_field "on_hand", with: "6"
|
|
|
|
|
|
|
|
|
|
fill_in "product_name", with: "Big Bag Of Potatoes"
|
|
|
|
|
select(s2.name, :from => 'supplier')
|
|
|
|
|
select(s2.name, :from => 'producer')
|
|
|
|
|
fill_in "available_on", with: (Date.today-3).strftime("%F %T")
|
|
|
|
|
fill_in "price", with: "20"
|
|
|
|
|
select "Weight (kg)", from: "variant_unit_with_scale"
|
|
|
|
|
@@ -946,17 +814,17 @@ feature %q{
|
|
|
|
|
fill_in "display_as", with: "Big Bag"
|
|
|
|
|
|
|
|
|
|
click_button 'Update'
|
|
|
|
|
page.find("span#update-status-message").should have_content "Update complete"
|
|
|
|
|
expect(page.find("span#update-status-message")).to have_content "Update complete"
|
|
|
|
|
|
|
|
|
|
p.reload
|
|
|
|
|
p.name.should == "Big Bag Of Potatoes"
|
|
|
|
|
p.supplier.should == s2
|
|
|
|
|
p.variant_unit.should == "weight"
|
|
|
|
|
p.variant_unit_scale.should == 1000 # Kg
|
|
|
|
|
p.available_on.should == 3.days.ago.beginning_of_day
|
|
|
|
|
p.master.display_as.should == "Big Bag"
|
|
|
|
|
p.price.should == 20.0
|
|
|
|
|
p.on_hand.should == 18
|
|
|
|
|
expect(p.name).to eq "Big Bag Of Potatoes"
|
|
|
|
|
expect(p.supplier).to eq s2
|
|
|
|
|
expect(p.variant_unit).to eq "weight"
|
|
|
|
|
expect(p.variant_unit_scale).to eq 1000 # Kg
|
|
|
|
|
expect(p.available_on).to eq 3.days.ago.beginning_of_day
|
|
|
|
|
expect(p.master.display_as).to eq "Big Bag"
|
|
|
|
|
expect(p.price).to eq 20.0
|
|
|
|
|
expect(p.on_hand).to eq 18
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|