Update cancan permissions for second iteration of bulk invoices

This commit is contained in:
Matt-Yorkley
2019-02-01 21:44:30 +00:00
parent a910468fc7
commit 2c3eeec2b9
3 changed files with 6 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ module Spree
module Admin
class InvoicesController < Spree::Admin::BaseController
respond_to :json
authorize_resource class: false
def create
invoice_service = BulkInvoiceService.new

View File

@@ -210,9 +210,10 @@ class AbilityDecorator
# during the order creation process from the admin backend
order.distributor.nil? || user.enterprises.include?(order.distributor) || order.order_cycle.andand.coordinated_by?(user)
end
can [:admin, :bulk_management, :managed, :bulk_invoice], Spree::Order do
can [:admin, :bulk_management, :managed], Spree::Order do
user.admin? || user.enterprises.any?(&:is_distributor)
end
can [:admin, :create, :show, :poll], :invoice
can [:admin, :visible], Enterprise
can [:admin, :index, :create, :update, :destroy], :line_item
can [:admin, :index, :create], Spree::LineItem

View File

@@ -2,10 +2,11 @@ require 'spec_helper'
describe Spree::Admin::InvoicesController, type: :controller do
let(:order) { create(:order_with_totals_and_distribution) }
let(:user) { create(:admin_user) }
let(:enterprise_user) { create(:user) }
let!(:enterprise) { create(:enterprise, owner: enterprise_user) }
before do
allow(controller).to receive(:spree_current_user) { user }
allow(controller).to receive(:spree_current_user) { enterprise_user }
end
describe "#create" do