From 02f891772206cdd0b5a6b0c3a0412282921f01e5 Mon Sep 17 00:00:00 2001 From: Rob H Date: Sat, 18 Jan 2014 21:00:54 +0800 Subject: [PATCH] Add delete button to BOM page --- .../admin/orders/bulk_management.html.haml | 5 +- .../admin/bulk_order_management_spec.rb | 113 +++++++++++------- 2 files changed, 71 insertions(+), 47 deletions(-) diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index 77a9099b26..132c9c3afd 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -26,6 +26,7 @@ %th.variant Product (Unit): Var %th.quantity Quantity %th.max Max + %th.actions %tr.line_item{ 'ng-repeat' => 'line_item in lineItems | selectFilter:supplierFilter:distributorFilter', 'ng-class-even' => "'even'", 'ng-class-odd' => "'odd'" } %td.id {{ line_item.id }} %td.email {{ line_item.order.email }} @@ -33,4 +34,6 @@ %td.producer {{ line_item.supplier.name }} %td.variant {{ line_item.variant_unit_text }} %td.quantity {{ line_item.quantity }} - %td.max {{ line_item.max }} \ No newline at end of file + %td.max {{ line_item.max }} + %td.actions + %a{ :class => "delete-line-item icon-trash no-text" } \ No newline at end of file diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index ada2e788b9..e107cbbbb2 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -81,58 +81,79 @@ feature %q{ page.should have_selector "td.max", text: li2.max_quantity.to_s, :visible => true end end + end - context "using page page controls" do - context "using drop down seletors" do - let!(:s1) { FactoryGirl.create(:supplier_enterprise) } - let!(:s2) { FactoryGirl.create(:supplier_enterprise) } - let!(:d1) { FactoryGirl.create(:distributor_enterprise) } - let!(:d2) { FactoryGirl.create(:distributor_enterprise) } - let!(:p1) { FactoryGirl.create(:product, supplier: s1 ) } - let!(:p2) { FactoryGirl.create(:product, supplier: s2 ) } - let!(:o1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: d1 ) } - let!(:o2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: d2 ) } - let!(:li1) { FactoryGirl.create(:line_item, order: o1, product: p1 ) } - let!(:li2) { FactoryGirl.create(:line_item, order: o2, product: p2 ) } + context "using page page controls" do + before :each do + login_to_admin_section + end + + context "using drop down seletors" do + let!(:s1) { FactoryGirl.create(:supplier_enterprise) } + let!(:s2) { FactoryGirl.create(:supplier_enterprise) } + let!(:d1) { FactoryGirl.create(:distributor_enterprise) } + let!(:d2) { FactoryGirl.create(:distributor_enterprise) } + let!(:p1) { FactoryGirl.create(:product, supplier: s1 ) } + let!(:p2) { FactoryGirl.create(:product, supplier: s2 ) } + let!(:o1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: d1 ) } + let!(:o2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: d2 ) } + let!(:li1) { FactoryGirl.create(:line_item, order: o1, product: p1 ) } + let!(:li2) { FactoryGirl.create(:line_item, order: o2, product: p2 ) } + + before :each do + visit '/admin/orders/bulk_management' + end + + it "displays a select box for producers, which filters line items by the selected supplier" do + page.should have_select "supplier_filter", with_options: [s1.name,s2.name] + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should have_selector "td.id", text: li2.id.to_s, visible: true + select s1.name, from: "supplier_filter" + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should_not have_selector "td.id", text: li2.id.to_s, visible: true + end + + it "displays all line items when 'All' is selected from supplier filter" do + select s1.name, from: "supplier_filter" + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should_not have_selector "td.id", text: li2.id.to_s, visible: true + select "All", from: "supplier_filter" + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should have_selector "td.id", text: li2.id.to_s, visible: true + end + + it "displays a select box for distributors, which filters line items by the selected distributor" do + page.should have_select "distributor_filter", with_options: [d1.name,d2.name] + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should have_selector "td.id", text: li2.id.to_s, visible: true + select d1.name, from: "distributor_filter" + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should_not have_selector "td.id", text: li2.id.to_s, visible: true + end + + it "displays all line items when 'All' is selected from distributor filter" do + select d1.name, from: "distributor_filter" + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should_not have_selector "td.id", text: li2.id.to_s, visible: true + select "All", from: "distributor_filter" + page.should have_selector "td.id", text: li1.id.to_s, visible: true + page.should have_selector "td.id", text: li2.id.to_s, visible: true + end + end + + context "using action buttons" do + context "using delete buttons" do + let!(:o1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now ) } + let!(:o2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now ) } + let!(:li1) { FactoryGirl.create(:line_item, order: o1 ) } + let!(:li2) { FactoryGirl.create(:line_item, order: o2 ) } before :each do visit '/admin/orders/bulk_management' end - it "displays a select box for producers, which filters line items by the selected supplier" do - page.should have_select "supplier_filter", with_options: [s1.name,s2.name] - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should have_selector "td.id", text: li2.id.to_s, visible: true - select s1.name, from: "supplier_filter" - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should_not have_selector "td.id", text: li2.id.to_s, visible: true - end - - it "displays all line items when 'All' is selected from supplier filter" do - select s1.name, from: "supplier_filter" - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should_not have_selector "td.id", text: li2.id.to_s, visible: true - select "All", from: "supplier_filter" - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should have_selector "td.id", text: li2.id.to_s, visible: true - end - - it "displays a select box for distributors, which filters line items by the selected distributor" do - page.should have_select "distributor_filter", with_options: [d1.name,d2.name] - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should have_selector "td.id", text: li2.id.to_s, visible: true - select d1.name, from: "distributor_filter" - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should_not have_selector "td.id", text: li2.id.to_s, visible: true - end - - it "displays all line items when 'All' is selected from distributor filter" do - select d1.name, from: "distributor_filter" - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should_not have_selector "td.id", text: li2.id.to_s, visible: true - select "All", from: "distributor_filter" - page.should have_selector "td.id", text: li1.id.to_s, visible: true - page.should have_selector "td.id", text: li2.id.to_s, visible: true + it "shows a delete button for each line item" do + page.should have_selector "a.delete-line-item", :count => 2 end end end