From 2e0d5eb8295e9e7afe2c18ee96473032d0265e71 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 23 Oct 2014 10:27:53 +1100 Subject: [PATCH] Adding set_sells action to enterprises --- app/models/spree/ability_decorator.rb | 2 +- config/routes.rb | 4 ++++ spec/models/spree/ability_spec.rb | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index a5d5f8be33..e3c90c7aa3 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -50,7 +50,7 @@ class AbilityDecorator can [:admin, :index, :read, :create, :edit, :update_positions, :destroy], ProducerProperty can [:admin, :index, :create], Enterprise - can [:read, :edit, :update, :bulk_update], Enterprise do |enterprise| + can [:read, :edit, :update, :bulk_update, :set_sells], Enterprise do |enterprise| user.enterprises.include? enterprise end diff --git a/config/routes.rb b/config/routes.rb index ca4a6b59ff..53169df888 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,6 +48,10 @@ Openfoodnetwork::Application.routes.draw do post :bulk_update, as: :bulk_update end + member do + post :set_sells + end + resources :producer_properties do post :update_positions, on: :collection end diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 0274099aa7..dd42b73e01 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -280,11 +280,11 @@ module Spree end it 'should have the ability to read and edit enterprises that I manage' do - should have_ability([:read, :edit, :update, :bulk_update], for: s1) + should have_ability([:read, :edit, :update, :bulk_update, :set_sells], for: s1) end it 'should not have the ability to read and edit enterprises that I do not manage' do - should_not have_ability([:read, :edit, :update, :bulk_update], for: s2) + should_not have_ability([:read, :edit, :update, :bulk_update, :set_sells], for: s2) end it 'should have the ability administrate and create enterpises' do