From 79668e06a7dadc7a719ef0d9b8ad0c267f007831 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 15 Jan 2021 10:24:50 +0000 Subject: [PATCH] Remove ability to create new product from products page, use /admin/products/new instead. It's simpler if there is just one place to add a new product. Closes #6650 This removes the 'creating directly from the new product path' test scenario because we have another 'assigning important attributes' scenario above which provides enough coverage. --- .../admin/products/index/_header.html.haml | 4 +--- app/views/spree/admin/products/new.js.erb | 12 ---------- spec/features/admin/products_spec.rb | 22 ------------------- 3 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 app/views/spree/admin/products/new.js.erb diff --git a/app/views/spree/admin/products/index/_header.html.haml b/app/views/spree/admin/products/index/_header.html.haml index 943abc021c..e48b5b7a89 100644 --- a/app/views/spree/admin/products/index/_header.html.haml +++ b/app/views/spree/admin/products/index/_header.html.haml @@ -5,8 +5,6 @@ %div{ :class => "toolbar", 'data-hook' => "toolbar" } %ul{ :class => "actions header-action-links inline-menu" } %li#new_product_link - = button_link_to t(:new_product), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_product' } + = button_link_to t(:new_product), new_object_url, { :icon => 'icon-plus', :id => 'admin_new_product' } = render partial: 'spree/admin/shared/product_sub_menu' - -%div#new_product(data-hook) diff --git a/app/views/spree/admin/products/new.js.erb b/app/views/spree/admin/products/new.js.erb deleted file mode 100644 index 33c38aac13..0000000000 --- a/app/views/spree/admin/products/new.js.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# This chunk is just a copy of Spree's backend/app/views/spree/admin/products/new.js.erb %> -$("#new_product").html('<%= escape_javascript(render :template => "spree/admin/products/new", :formats => [:html], :handlers => [:haml]) %>'); -handle_date_picker_fields(); -<% unless Rails.env.test? %> - $('.select2').select2(); -<% end %> -$("#table-filter").hide(); -$("#admin_new_product").parent().hide(); - -<%# We need to replace the page's title as well. We're navigating to a new page - although through ajax %> -$('.js-admin-page-title').html('<%= t('.title') %>'); diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 60adf49939..e2a3b8a3c3 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -68,28 +68,6 @@ feature ' expect(product.master.options_text).to eq("5kg") end - scenario "creating directly from the new product path", js: true do - login_as_admin_and_visit spree.new_admin_product_path - - select 'New supplier', from: 'product_supplier_id' - fill_in 'product_name', with: 'A new product !!!' - select "Weight (kg)", from: 'product_variant_unit_with_scale' - fill_in 'product_unit_value_with_description', with: 5 - select taxon.name, from: "product_primary_taxon_id" - fill_in 'product_price', with: '19.99' - fill_in 'product_on_hand', with: 5 - select 'Test Tax Category', from: 'product_tax_category_id' - page.find("div[id^='taTextElement']").native.send_keys('A description...') - - click_button 'Create' - - expect(current_path).to eq spree.admin_products_path - expect(flash_message).to eq('Product "A new product !!!" has been successfully created!') - product = Spree::Product.find_by(name: 'A new product !!!') - expect(product.variant_unit).to eq('weight') - expect(product.variant_unit_scale).to eq(1000) - end - scenario "creating an on-demand product", js: true do login_as_admin_and_visit spree.admin_products_path