Files
openfoodnetwork/spec/support/ability_helper.rb
luisramos0 bc8bca074c 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.
2019-03-29 22:16:39 +00:00

29 lines
1.1 KiB
Ruby

module AbilityHelper
shared_examples "allows access to Enterprise Fee Summary only if feature flag enabled" do
it "should not be able to read Enterprise Fee Summary" do
is_expected.not_to have_link_to_enterprise_fee_summary
is_expected.not_to have_direct_access_to_enterprise_fee_summary
end
context "when feature flag for Enterprise Fee Summary is enabled absolutely" do
before do
feature_flags = instance_double(FeatureFlags, enterprise_fee_summary_enabled?: true)
allow(FeatureFlags).to receive(:new).with(user) { feature_flags }
end
it "should be able to see link and read report" do
is_expected.to have_link_to_enterprise_fee_summary
is_expected.to have_direct_access_to_enterprise_fee_summary
end
end
def have_link_to_enterprise_fee_summary
have_ability([:enterprise_fee_summary], for: Spree::Admin::ReportsController)
end
def have_direct_access_to_enterprise_fee_summary
have_ability([:admin, :new, :create], for: :enterprise_fee_summary)
end
end
end