WIP: Rename override_variants to variant_overrides

This commit is contained in:
Rohan Mitchell
2014-12-10 11:49:56 +11:00
parent a1906a71fa
commit 51d2805de9
15 changed files with 16 additions and 16 deletions

View File

@@ -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()

View File

@@ -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).

View File

@@ -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|

View File

@@ -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'

View File

@@ -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]

View File

@@ -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

View File

@@ -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