mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Only show connected apps in enterprise settings, if system setting is enabled
This commit is contained in:
committed by
Rachel Arnould
parent
8716b75d3d
commit
fcea437d7e
@@ -26,7 +26,8 @@ module Admin
|
||||
show_enterprise_fees = can?(:manage_enterprise_fees,
|
||||
enterprise) && (is_shop || enterprise.is_primary_producer)
|
||||
show_connected_apps = can?(:manage_connected_apps, enterprise) &&
|
||||
feature?(:connected_apps, spree_current_user, enterprise)
|
||||
feature?(:connected_apps, spree_current_user, enterprise) &&
|
||||
Spree::Config.connected_apps_enabled.present?
|
||||
|
||||
build_enterprise_side_menu_items(
|
||||
is_shop:,
|
||||
|
||||
@@ -139,5 +139,8 @@ module Spree
|
||||
|
||||
# Available units
|
||||
preference :available_units, :string, default: "g,kg,T,mL,L,kL"
|
||||
|
||||
# Connected Apps
|
||||
preference :connected_apps_enabled, :string, default: nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,6 +28,8 @@ RSpec.describe Admin::EnterprisesHelper, type: :helper do
|
||||
end
|
||||
|
||||
it "lists enabled features when allowed", feature: :connected_apps do
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).and_return "discover_regen"
|
||||
|
||||
user.enterprises << enterprise
|
||||
expect(visible_items.pluck(:name)).to include "connected_apps"
|
||||
end
|
||||
|
||||
@@ -9,7 +9,10 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
login_as enterprise.owner
|
||||
end
|
||||
|
||||
it "is only visible when enabled" do
|
||||
it "is only visible when feature is enabled" do
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).
|
||||
and_return("discover_regen,affiliate_sales_data")
|
||||
|
||||
# Assuming that this feature will be the default one day, I'm treating this
|
||||
# as special case and disable the feature. I don't want to wrap all other
|
||||
# test cases in a context block for the feature toggle which will need
|
||||
@@ -28,7 +31,21 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
expect(page).to have_content "CONNECTED APPS"
|
||||
end
|
||||
|
||||
it "is only visible when setting is enabled" do
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).and_return(nil)
|
||||
visit edit_admin_enterprise_path(enterprise)
|
||||
expect(page).not_to have_content "CONNECTED APPS"
|
||||
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).
|
||||
and_return("discover_regen,affiliate_sales_data")
|
||||
visit edit_admin_enterprise_path(enterprise)
|
||||
expect(page).to have_content "CONNECTED APPS"
|
||||
end
|
||||
|
||||
describe "Discover Regenerative" do
|
||||
before do
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).and_return("discover_regen")
|
||||
end
|
||||
let(:section_heading) { self.class.description }
|
||||
|
||||
it "can be enabled and disabled" do
|
||||
@@ -76,6 +93,9 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
end
|
||||
|
||||
describe "Affiliate Sales Data" do
|
||||
before do
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).and_return("affiliate_sales_data")
|
||||
end
|
||||
let(:section_heading) { "INRAE / UFC QUE CHOISIR Research" }
|
||||
|
||||
it "can be enabled and disabled" do
|
||||
|
||||
Reference in New Issue
Block a user