Skip to content

Commit

Permalink
Merge pull request #1988 from laurawadden/show-deleted
Browse files Browse the repository at this point in the history
Do not show broken links in admin product view when product is deleted
  • Loading branch information
kennyadsl authored Jun 12, 2017
2 parents 153332b + 4b7d470 commit eae7bf7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions backend/app/views/spree/admin/shared/_product_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
<% end if can?(:admin, Spree::Product) %>
<%= content_tag :li, class: ('active' if current == 'Images') do %>
<%= link_to Spree.t(:images), spree.admin_product_images_url(@product) %>
<% end if can?(:admin, Spree::Image) %>
<% end if can?(:admin, Spree::Image) && !@product.deleted? %>
<%= content_tag :li, class: ('active' if current == 'Variants') do %>
<%= link_to plural_resource_name(Spree::Variant), spree.admin_product_variants_url(@product) %>
<% end if can?(:admin, Spree::Variant) %>
<%= content_tag :li, class: ('active' if current == 'Prices') do %>
<%= link_to plural_resource_name(Spree::Price), spree.admin_product_prices_url(@product) %>
<% end if can?(:admin, Spree::Price) %>
<% end if can?(:admin, Spree::Price) && !@product.deleted? %>
<%= content_tag :li, class: ('active' if current == 'Product Properties') do %>
<%= link_to plural_resource_name(Spree::ProductProperty), spree.admin_product_product_properties_url(@product) %>
<% end if can?(:admin, Spree::ProductProperty) %>
<% end if can?(:admin, Spree::ProductProperty) && !@product.deleted? %>
<%= content_tag :li, class: ('active' if current == 'Stock Management') do %>
<%= link_to Spree.t(:stock_management), spree.admin_product_stock_url(@product) %>
<% end if can?(:admin, Spree::StockItem) %>
<% end if can?(:admin, Spree::StockItem) && !@product.deleted? %>
</ul>
</nav>
<% end %>
5 changes: 4 additions & 1 deletion backend/spec/features/admin/products/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def build_option_type_with_values(name, values)
context 'deleting a product', js: true do
let!(:product) { create(:product) }

it "is still viewable" do
it "product details are still viewable" do
visit spree.admin_products_path

expect(page).to have_content(product.name)
Expand All @@ -267,6 +267,9 @@ def build_option_type_with_values(name, values)
click_button "Search"
click_link product.name
expect(page).to have_field('Master Price', with: product.price.to_f)
expect(page).to_not have_content('Images')
expect(page).to_not have_content('Prices')
expect(page).to_not have_content('Product Properties')
end
end
end
Expand Down

0 comments on commit eae7bf7

Please sign in to comment.