diff --git a/app/assets/javascripts/admin/services/dirty_variant_overrides.js.coffee b/app/assets/javascripts/admin/services/dirty_variant_overrides.js.coffee index 14a1ff35f9..72455326a2 100644 --- a/app/assets/javascripts/admin/services/dirty_variant_overrides.js.coffee +++ b/app/assets/javascripts/admin/services/dirty_variant_overrides.js.coffee @@ -24,6 +24,6 @@ angular.module("ofn.admin").factory "DirtyVariantOverrides", ($http) -> save: -> $http method: "POST" - url: "/admin/products/override_variants" + url: "/admin/products/variant_overrides" data: variant_overrides: @all() diff --git a/app/controllers/spree/admin/products_controller_decorator.rb b/app/controllers/spree/admin/products_controller_decorator.rb index 00742bdbec..feb64ecf9b 100644 --- a/app/controllers/spree/admin/products_controller_decorator.rb +++ b/app/controllers/spree/admin/products_controller_decorator.rb @@ -4,7 +4,7 @@ Spree::Admin::ProductsController.class_eval do include OpenFoodNetwork::SpreeApiKeyLoader include OrderCyclesHelper before_filter :load_form_data, :only => [:bulk_edit, :new, :create, :edit, :update] - before_filter :load_spree_api_key, :only => [:bulk_edit, :override_variants] + before_filter :load_spree_api_key, :only => [:bulk_edit, :variant_overrides] alias_method :location_after_save_original, :location_after_save @@ -49,7 +49,7 @@ Spree::Admin::ProductsController.class_eval do end end - def override_variants + def variant_overrides @hubs = order_cycle_hub_enterprises(without_validation: true) @producers = order_cycle_producer_enterprises @hub_permissions = OpenFoodNetwork::Permissions.new(spree_current_user). diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index 6371d26aff..97d4235b9a 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -65,10 +65,10 @@ class AbilityDecorator def add_product_management_abilities(user) # Enterprise User can only access products that they are a supplier for can [:create], Spree::Product - can [:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :override_variants, :clone, :destroy], Spree::Product do |product| + can [:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :variant_overrides, :clone, :destroy], Spree::Product do |product| OpenFoodNetwork::Permissions.new(user).managed_product_enterprises.include? product.supplier end - can :override_variants, nil + can :variant_overrides, nil can [:create], Spree::Variant can [:admin, :index, :read, :edit, :update, :search, :destroy], Spree::Variant do |variant| diff --git a/app/overrides/spree/admin/shared/_product_sub_menu/add_override_variants_tab.html.haml.deface b/app/overrides/spree/admin/shared/_product_sub_menu/add_override_variants_tab.html.haml.deface index 381f80a44d..88e720fd07 100644 --- a/app/overrides/spree/admin/shared/_product_sub_menu/add_override_variants_tab.html.haml.deface +++ b/app/overrides/spree/admin/shared/_product_sub_menu/add_override_variants_tab.html.haml.deface @@ -1,4 +1,4 @@ / insert_bottom "[data-hook='admin_product_sub_tabs']" -# Commented out until this feature is ready --#= tab :override_details, url: override_variants_admin_products_path, match_path: '/products/override_variants' +-#= tab :overrides, url: variant_overrides_admin_products_path, match_path: '/products/variant_overrides' diff --git a/app/views/spree/admin/products/override_variants.html.haml b/app/views/spree/admin/products/variant_overrides.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants.html.haml rename to app/views/spree/admin/products/variant_overrides.html.haml diff --git a/app/views/spree/admin/products/override_variants/_actions.html.haml b/app/views/spree/admin/products/variant_overrides/_actions.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_actions.html.haml rename to app/views/spree/admin/products/variant_overrides/_actions.html.haml diff --git a/app/views/spree/admin/products/override_variants/_data.html.haml b/app/views/spree/admin/products/variant_overrides/_data.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_data.html.haml rename to app/views/spree/admin/products/variant_overrides/_data.html.haml diff --git a/app/views/spree/admin/products/override_variants/_header.html.haml b/app/views/spree/admin/products/variant_overrides/_header.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_header.html.haml rename to app/views/spree/admin/products/variant_overrides/_header.html.haml diff --git a/app/views/spree/admin/products/override_variants/_hub_choice.html.haml b/app/views/spree/admin/products/variant_overrides/_hub_choice.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_hub_choice.html.haml rename to app/views/spree/admin/products/variant_overrides/_hub_choice.html.haml diff --git a/app/views/spree/admin/products/override_variants/_products.html.haml b/app/views/spree/admin/products/variant_overrides/_products.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_products.html.haml rename to app/views/spree/admin/products/variant_overrides/_products.html.haml diff --git a/app/views/spree/admin/products/override_variants/_products_product.html.haml b/app/views/spree/admin/products/variant_overrides/_products_product.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_products_product.html.haml rename to app/views/spree/admin/products/variant_overrides/_products_product.html.haml diff --git a/app/views/spree/admin/products/override_variants/_products_variants.html.haml b/app/views/spree/admin/products/variant_overrides/_products_variants.html.haml similarity index 100% rename from app/views/spree/admin/products/override_variants/_products_variants.html.haml rename to app/views/spree/admin/products/variant_overrides/_products_variants.html.haml diff --git a/config/routes.rb b/config/routes.rb index fd891fbb9c..9cea328411 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -118,7 +118,7 @@ Spree::Core::Engine.routes.prepend do match '/admin/reports/orders_and_fulfillment' => 'admin/reports#orders_and_fulfillment', :as => "orders_and_fulfillment_admin_reports", :via => [:get, :post] match '/admin/reports/users_and_enterprises' => 'admin/reports#users_and_enterprises', :as => "users_and_enterprises_admin_reports", :via => [:get, :post] match '/admin/products/bulk_edit' => 'admin/products#bulk_edit', :as => "bulk_edit_admin_products" - match '/admin/products/override_variants' => 'admin/products#override_variants', :as => "override_variants_admin_products" + match '/admin/products/variant_overrides' => 'admin/products#variant_overrides', :as => "variant_overrides_admin_products" match '/admin/orders/bulk_management' => 'admin/orders#bulk_management', :as => "admin_bulk_order_management" match '/admin/reports/products_and_inventory' => 'admin/reports#products_and_inventory', :as => "products_and_inventory_admin_reports", :via => [:get, :post] match '/admin/reports/customers' => 'admin/reports#customers', :as => "customers_admin_reports", :via => [:get, :post] diff --git a/spec/features/admin/override_variants_spec.rb b/spec/features/admin/override_variants_spec.rb index 810cb1e0a9..0067683a8d 100644 --- a/spec/features/admin/override_variants_spec.rb +++ b/spec/features/admin/override_variants_spec.rb @@ -23,12 +23,12 @@ feature %q{ describe "selecting a hub" do it "displays a list of hub choices" do - visit '/admin/products/override_variants' + visit '/admin/products/variant_overrides' page.should have_select2 'hub_id', options: ['', hub.name, hub2.name] end it "displays the hub" do - visit '/admin/products/override_variants' + visit '/admin/products/variant_overrides' select2_select hub.name, from: 'hub_id' click_button 'Go' @@ -51,7 +51,7 @@ feature %q{ context "with no overrides" do before do - visit '/admin/products/override_variants' + visit '/admin/products/variant_overrides' select2_select hub.name, from: 'hub_id' click_button 'Go' end @@ -73,7 +73,7 @@ feature %q{ let!(:override) { create(:variant_override, variant: variant, hub: hub, price: 77.77, count_on_hand: 11111) } before do - visit '/admin/products/override_variants' + visit '/admin/products/variant_overrides' select2_select hub.name, from: 'hub_id' click_button 'Go' end diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 1662ab7942..6c99038170 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -140,23 +140,23 @@ module Spree let(:order) {create(:order)} it "should be able to read/write their enterprises' products and variants" do - should have_ability([:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :override_variants, :clone, :destroy], for: p1) + should have_ability([:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :variant_overrides, :clone, :destroy], for: p1) should have_ability([:admin, :index, :read, :edit, :update, :search, :destroy], for: p1.master) end it "should be able to read/write related enterprises' products and variants with manage_products permission" do er_p - should have_ability([:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :override_variants, :clone, :destroy], for: p_related) + should have_ability([:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :variant_overrides, :clone, :destroy], for: p_related) should have_ability([:admin, :index, :read, :edit, :update, :search, :destroy], for: p_related.master) end it "should not be able to read/write other enterprises' products and variants" do - should_not have_ability([:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :override_variants, :clone, :destroy], for: p2) + should_not have_ability([:admin, :read, :update, :product_distributions, :bulk_edit, :bulk_update, :variant_overrides, :clone, :destroy], for: p2) should_not have_ability([:admin, :index, :read, :edit, :update, :search, :destroy], for: p2.master) end - it "should be able to override_variants on nil (required for override_variants)" do - should have_ability :override_variants, for: nil + it "should be able to variant_overrides on nil (required for variant_overrides)" do + should have_ability :variant_overrides, for: nil end it "should not be able to access admin actions on orders" do