From 37ff61d663fd69de8e0ac96c8f8122b52ae66585 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Sat, 2 May 2015 19:51:54 +1000 Subject: [PATCH] Adding basic routing to display customer index page --- app/controllers/admin/customers_controller.rb | 4 ++++ app/models/spree/ability_decorator.rb | 2 ++ app/views/admin/customers/index.html.haml | 1 + config/routes.rb | 2 ++ spec/models/spree/ability_spec.rb | 8 ++++++++ 5 files changed, 17 insertions(+) create mode 100644 app/controllers/admin/customers_controller.rb create mode 100644 app/views/admin/customers/index.html.haml diff --git a/app/controllers/admin/customers_controller.rb b/app/controllers/admin/customers_controller.rb new file mode 100644 index 0000000000..d663b4f0ea --- /dev/null +++ b/app/controllers/admin/customers_controller.rb @@ -0,0 +1,4 @@ +module Admin + class CustomersController < ResourceController + end +end diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index b8539979c2..b5ad4ec07b 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -185,6 +185,8 @@ class AbilityDecorator # Reports page can [:admin, :index, :customers, :group_buys, :bulk_coop, :sales_tax, :payments, :orders_and_distributors, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management], :report + + can [:admin, :index], Customer end diff --git a/app/views/admin/customers/index.html.haml b/app/views/admin/customers/index.html.haml new file mode 100644 index 0000000000..95b841ac50 --- /dev/null +++ b/app/views/admin/customers/index.html.haml @@ -0,0 +1 @@ +Customers diff --git a/config/routes.rb b/config/routes.rb index 4621ee4a35..aa49f225dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -79,6 +79,8 @@ Openfoodnetwork::Application.routes.draw do resources :variant_overrides do post :bulk_update, on: :collection end + + resources :customers, only: [:index] end namespace :api do diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 0dc9364967..8ff1054f19 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -220,6 +220,10 @@ module Spree should_not have_ability([:sales_total, :group_buys, :payments, :orders_and_distributors, :users_and_enterprises], for: :report) end + it "should not be able to list customers" do + should_not have_ability([:admin, :index], for: Customer) + end + describe "order_cycles abilities" do context "where the enterprise is not in an order_cycle" do let!(:order_cycle) { create(:simple_order_cycle) } @@ -407,6 +411,10 @@ module Spree should_not have_ability([:sales_total, :users_and_enterprises], for: :report) end + it "should be able to list customers" do + should have_ability([:admin, :index], for: Customer) + end + context "for a given order_cycle" do let!(:order_cycle) { create(:simple_order_cycle) } let!(:exchange){ create(:exchange, incoming: false, order_cycle: order_cycle, receiver: d1, sender: order_cycle.coordinator) }