From e8f24dc2ddeffc2f2aa43bbe86839ade9d1aa3ac Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 9 Jun 2013 21:43:02 +0530 Subject: [PATCH] BPUR: Add edit link for products and variants --- .../spree/admin/products/bulk_index.html.haml | 2 ++ .../admin/bulk_product_update_spec.rb | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/views/spree/admin/products/bulk_index.html.haml b/app/views/spree/admin/products/bulk_index.html.haml index d9b0a6d1d1..11b017ac51 100644 --- a/app/views/spree/admin/products/bulk_index.html.haml +++ b/app/views/spree/admin/products/bulk_index.html.haml @@ -35,6 +35,7 @@ %td %input{ 'ng-model' => 'product.available_on', :name => 'available_on', 'ng-track-product' => 'available_on', :type => 'text' } %td.actions + %a{ 'ng-href' => '/admin/products/{{product.permalink_live}}/edit', :class => "edit-product icon-edit no-text" } %a{ 'ng-click' => 'deleteProduct(product)', :class => "delete-product icon-trash no-text" } %tr{ 'ng-repeat' => 'variant in product.variants' } %td @@ -46,6 +47,7 @@ %input.field{ 'ng-model' => 'variant.on_hand', 'ng-change' => 'updateOnHand(product)', :name => 'variant_on_hand', 'ng-track-variant' => 'on_hand', :type => 'number' } %td %td.actions + %a{ 'ng-href' => '/admin/products/{{product.permalink_live}}/variants/{{variant.id}}/edit', :class => "edit-variant icon-edit no-text" } %a{ 'ng-click' => 'deleteVariant(product,variant)', :class => "delete-variant icon-trash no-text" } %input{:type => 'button', :value => 'Update', 'ng-click' => 'prepareProductsForSubmit()'} %span{ id: "update-status-message", 'ng-style' => 'updateStatusMessage.style' } diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 54ee9acbcb..c90fc04ee2 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -298,5 +298,37 @@ feature %q{ page.should have_selector "a.delete-variant", :count => 2 end end + + describe "using edit buttons" do + it "shows an edit button for products, which takes the user to the standard edit page for that product" do + p1 = FactoryGirl.create(:product) + p2 = FactoryGirl.create(:product) + p3 = FactoryGirl.create(:product) + login_to_admin_section + + visit '/admin/products/bulk_index' + + page.should have_selector "a.edit-product", :count => 3 + + first("a.edit-product").click + + URI.parse(current_url).path.should == "/admin/products/#{p1.permalink}/edit" + end + + it "shows an edit button for variants, which takes the user to the standard edit page for that variant" do + v1 = FactoryGirl.create(:variant) + v2 = FactoryGirl.create(:variant) + v3 = FactoryGirl.create(:variant) + login_to_admin_section + + visit '/admin/products/bulk_index' + + page.should have_selector "a.edit-variant", :count => 3 + + first("a.edit-variant").click + + URI.parse(current_url).path.should == "/admin/products/#{v1.product.permalink}/variants/#{v1.id}/edit" + end + end end end \ No newline at end of file