Remove feature flag for Enterprise Fee Summary

This commit is contained in:
Kristina Lim
2019-05-29 02:50:41 +08:00
parent 6a0925539f
commit ecea0600b6
7 changed files with 6 additions and 92 deletions

View File

@@ -14,13 +14,6 @@ class FeatureFlags
user.superadmin?
end
# Checks whether the "Enterprise Fee Summary" is enabled for the specified user
#
# @return [Boolean]
def enterprise_fee_summary_enabled?
user.superadmin?
end
private
attr_reader :user

View File

@@ -289,9 +289,6 @@ class AbilityDecorator
end
def add_enterprise_fee_summary_abilities(user)
feature_enabled = FeatureFlags.new(user).enterprise_fee_summary_enabled?
return unless feature_enabled
# Reveal the report link in spree/admin/reports#index
can [:enterprise_fee_summary], Spree::Admin::ReportsController
# Allow direct access to the report resource

View File

@@ -8,9 +8,6 @@ describe Spree::Admin::Reports::EnterpriseFeeSummariesController, type: :control
let(:current_user) { distributor.owner }
before do
feature_flags = instance_double(FeatureFlags, enterprise_fee_summary_enabled?: true)
allow(FeatureFlags).to receive(:new).with(current_user) { feature_flags }
allow(controller).to receive(:spree_current_user) { current_user }
end
@@ -21,15 +18,6 @@ describe Spree::Admin::Reports::EnterpriseFeeSummariesController, type: :control
expect(response).to be_success
expect(response).to render_template(new_template_path)
end
context "when feature flag is in effect" do
before { allow(FeatureFlags).to receive(:new).with(current_user).and_call_original }
it "is unauthorized" do
get :new
expect(response).to redirect_to spree.unauthorized_path
end
end
end
describe "#create" do
@@ -41,15 +29,6 @@ describe Spree::Admin::Reports::EnterpriseFeeSummariesController, type: :control
expect(response.body).not_to be_blank
expect(response.header["Content-Type"]).to eq("text/csv")
end
context "when feature flag is in effect" do
before { allow(FeatureFlags).to receive(:new).with(current_user).and_call_original }
it "is unauthorized" do
post :create, report: { start_at: "2018-10-09 07:30:00" }, report_format: "csv"
expect(response).to redirect_to spree.unauthorized_path
end
end
end
context "when the parameters are invalid" do

View File

@@ -11,9 +11,6 @@ feature "enterprise fee summaries", js: true do
let!(:other_order_cycle) { create(:simple_order_cycle, coordinator: other_distributor) }
before do
feature_flags = instance_double(FeatureFlags, enterprise_fee_summary_enabled?: true)
allow(FeatureFlags).to receive(:new).with(current_user) { feature_flags }
login_as current_user
end
@@ -36,17 +33,6 @@ feature "enterprise fee summaries", js: true do
click_on I18n.t("admin.reports.enterprise_fee_summary.name")
expect(page).to have_button(I18n.t("filters.generate_report", scope: i18n_scope))
end
context "when feature flag is in effect" do
before { allow(FeatureFlags).to receive(:new).with(current_user).and_call_original }
it "does not show link now allow direct access to the report" do
visit spree.admin_reports_path
expect(page).to have_no_link I18n.t("admin.reports.enterprise_fee_summary.name")
visit spree.new_admin_reports_enterprise_fee_summary_path
expect(page).to have_no_button(I18n.t("filters.generate_report", scope: i18n_scope))
end
end
end
context "when accessing the report as an enterprise user without sufficient permissions" do
@@ -58,17 +44,6 @@ feature "enterprise fee summaries", js: true do
visit spree.new_admin_reports_enterprise_fee_summary_path
expect(page).to have_content(I18n.t("unauthorized"))
end
context "when feature flag is in effect" do
before { allow(FeatureFlags).to receive(:new).with(current_user).and_call_original }
it "does not show link now allow direct access to the report" do
visit spree.admin_reports_path
expect(page).to have_no_link I18n.t("admin.reports.enterprise_fee_summary.name")
visit spree.new_admin_reports_enterprise_fee_summary_path
expect(page).to have_no_button(I18n.t("filters.generate_report", scope: i18n_scope))
end
end
end
end

View File

@@ -25,22 +25,4 @@ describe FeatureFlags do
end
end
end
describe "#enterprise_fee_summary_enabled?" do
context "when the user is superadmin" do
let!(:user) { create(:admin_user) }
it "returns true" do
expect(feature_flags).to be_enterprise_fee_summary_enabled
end
end
context "when the user is not superadmin" do
let!(:user) { create(:user) }
it "returns false" do
expect(feature_flags).not_to be_enterprise_fee_summary_enabled
end
end
end
end

View File

@@ -216,7 +216,7 @@ module Spree
is_expected.to 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"
include_examples "allows access to Enterprise Fee Summary"
it "should not be able to read other reports" do
is_expected.not_to have_ability([:sales_total, :group_buys, :payments, :orders_and_distributors, :users_and_enterprises, :xero_invoices], for: Spree::Admin::ReportsController)
@@ -409,7 +409,7 @@ module Spree
is_expected.to 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"
include_examples "allows access to Enterprise Fee Summary"
it "should not be able to read other reports" do
is_expected.not_to have_ability([:sales_total, :users_and_enterprises], for: Spree::Admin::ReportsController)

View File

@@ -1,20 +1,8 @@
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
shared_examples "allows access to Enterprise Fee Summary" do
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
def have_link_to_enterprise_fee_summary