mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Switch object in the ability to access reports. This adapts to this change in Spree: 3685569db4
Adapt NavigationHelper to return the controller object for reports so that Reports tab works correctly.
This commit is contained in:
@@ -250,7 +250,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
:xero_invoices,
|
||||
:packing
|
||||
]
|
||||
reports = all_reports.select { |action| can? action, :report }
|
||||
reports = all_reports.select { |action| can? action, Spree::Admin::ReportsController }
|
||||
reports.map { |report| [report, describe_report(report)] }.to_h
|
||||
end
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ module Spree
|
||||
klass = Spree::Order if klass == :bulk_order_management
|
||||
klass = EnterpriseGroup if klass == :group
|
||||
klass = VariantOverride if klass == :Inventory
|
||||
klass = Spree::Admin::ReportsController if klass == :report
|
||||
klass
|
||||
end
|
||||
alias_method_chain :klass_for, :sym_fallback
|
||||
|
||||
@@ -187,7 +187,7 @@ class AbilityDecorator
|
||||
# Reports page
|
||||
can [:admin, :index, :customers, :orders_and_distributors, :group_buys, :bulk_coop, :payments,
|
||||
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :packing],
|
||||
:report
|
||||
Spree::Admin::ReportsController
|
||||
add_enterprise_fee_summary_abilities(user)
|
||||
end
|
||||
|
||||
@@ -263,7 +263,7 @@ 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, :xero_invoices], :report
|
||||
:order_cycle_management, :xero_invoices], Spree::Admin::ReportsController
|
||||
add_enterprise_fee_summary_abilities(user)
|
||||
|
||||
can [:create], Customer
|
||||
@@ -293,7 +293,7 @@ class AbilityDecorator
|
||||
return unless feature_enabled
|
||||
|
||||
# Reveal the report link in spree/admin/reports#index
|
||||
can [:enterprise_fee_summary], :report
|
||||
can [:enterprise_fee_summary], Spree::Admin::ReportsController
|
||||
# Allow direct access to the report resource
|
||||
can [:admin, :new, :create], :enterprise_fee_summary
|
||||
end
|
||||
|
||||
@@ -9,7 +9,11 @@ module Spree
|
||||
end
|
||||
|
||||
it "returns a symbol when there's no available class" do
|
||||
helper.klass_for('reports').should == :report
|
||||
helper.klass_for('lions').should == :lion
|
||||
end
|
||||
|
||||
it "returns Spree::Admin::ReportsController for reports" do
|
||||
helper.klass_for('reports').should == Spree::Admin::ReportsController
|
||||
end
|
||||
|
||||
it "returns :overview for the dashboard" do
|
||||
|
||||
@@ -214,13 +214,13 @@ module Spree
|
||||
end
|
||||
|
||||
it "should be able to read some reports" do
|
||||
should have_ability([:admin, :index, :customers, :bulk_coop, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management], for: :report)
|
||||
should have_ability([:admin, :index, :customers, :bulk_coop, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management], for: Spree::Admin::ReportsController)
|
||||
end
|
||||
|
||||
include_examples "allows access to Enterprise Fee Summary only if feature flag enabled"
|
||||
|
||||
it "should not be able to read other reports" do
|
||||
should_not have_ability([:sales_total, :group_buys, :payments, :orders_and_distributors, :users_and_enterprises, :xero_invoices], for: :report)
|
||||
should_not have_ability([:sales_total, :group_buys, :payments, :orders_and_distributors, :users_and_enterprises, :xero_invoices], for: Spree::Admin::ReportsController)
|
||||
end
|
||||
|
||||
it "should not be able to access customer actions" do
|
||||
@@ -407,13 +407,13 @@ module Spree
|
||||
end
|
||||
|
||||
it "should be able to read some reports" do
|
||||
should have_ability([:admin, :index, :customers, :sales_tax, :group_buys, :bulk_coop, :payments, :orders_and_distributors, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :xero_invoices], for: :report)
|
||||
should have_ability([:admin, :index, :customers, :sales_tax, :group_buys, :bulk_coop, :payments, :orders_and_distributors, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :xero_invoices], for: Spree::Admin::ReportsController)
|
||||
end
|
||||
|
||||
include_examples "allows access to Enterprise Fee Summary only if feature flag enabled"
|
||||
|
||||
it "should not be able to read other reports" do
|
||||
should_not have_ability([:sales_total, :users_and_enterprises], for: :report)
|
||||
should_not have_ability([:sales_total, :users_and_enterprises], for: Spree::Admin::ReportsController)
|
||||
end
|
||||
|
||||
it "should be able to access customer actions" do
|
||||
|
||||
@@ -18,7 +18,7 @@ module AbilityHelper
|
||||
end
|
||||
|
||||
def have_link_to_enterprise_fee_summary
|
||||
have_ability([:enterprise_fee_summary], for: :report)
|
||||
have_ability([:enterprise_fee_summary], for: Spree::Admin::ReportsController)
|
||||
end
|
||||
|
||||
def have_direct_access_to_enterprise_fee_summary
|
||||
|
||||
Reference in New Issue
Block a user