From 874b8a60b82bc4868e57a3a5b73ec345ef2b92d1 Mon Sep 17 00:00:00 2001 From: Leticia Errandonea Date: Wed, 26 Feb 2025 13:27:17 -0300 Subject: [PATCH] Remove cross_core_projects --- app/controllers/facility_orders_controller.rb | 4 +--- .../order_detail_stored_files_controller.rb | 2 +- app/controllers/reservations_controller.rb | 4 ---- app/forms/add_to_order_form.rb | 10 ++++------ app/lib/ability.rb | 6 +++--- app/models/order.rb | 6 ------ .../_merge_order_form.html.haml | 2 +- app/views/facility_orders/show.html.haml | 19 +++++++++---------- config/settings.yml | 1 - .../adding_to_a_cross_core_order_spec.rb | 4 ++-- spec/system/admin/adding_to_an_order_spec.rb | 2 +- spec/system/admin/reservation_actions_spec.rb | 2 +- 12 files changed, 23 insertions(+), 39 deletions(-) diff --git a/app/controllers/facility_orders_controller.rb b/app/controllers/facility_orders_controller.rb index 1732b36fe0..4302301cc9 100644 --- a/app/controllers/facility_orders_controller.rb +++ b/app/controllers/facility_orders_controller.rb @@ -108,7 +108,7 @@ def load_order def load_merge_orders missing_reservation_order_ids = [] - if SettingsHelper.feature_on?(:cross_core_projects) && @order.cross_core_project_id.present? + if @order.cross_core_project_id.present? project_order_ids = @order.cross_core_project.orders.pluck(:id) missing_reservation_order_ids = missing_reservation_order_ids(project_order_ids) else @@ -138,8 +138,6 @@ def problem_order_details end def load_cross_core_order_details - return unless SettingsHelper.feature_on?(:cross_core_projects) - @cross_core_project = @order.cross_core_project @cross_core_data_by_facility_id = {} diff --git a/app/controllers/order_detail_stored_files_controller.rb b/app/controllers/order_detail_stored_files_controller.rb index 6a22163ceb..afc76260bd 100644 --- a/app/controllers/order_detail_stored_files_controller.rb +++ b/app/controllers/order_detail_stored_files_controller.rb @@ -84,7 +84,7 @@ def ability_resource end def redirect_to_facility_order(consider_merge_order: false) - if SettingsHelper.feature_on?(:cross_core_projects) && @original_order_id.present? + if @original_order_id.present? original_order = Order.find(@original_order_id) order = consider_merge_order ? original_order.merge_order || original_order : original_order diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb index 8d20141831..809e2da5a5 100644 --- a/app/controllers/reservations_controller.rb +++ b/app/controllers/reservations_controller.rb @@ -418,8 +418,6 @@ def duration_change_valid? end def set_accounts_for_cross_core_project - return unless SettingsHelper.feature_on?(:cross_core_projects) - return if @order.cross_core_project_id.nil? @accounts_for_cross_core_project = AvailableAccountsFinder.new(original_project_order.user, @order.facility) @@ -436,8 +434,6 @@ def original_project_order end def set_cross_core_cancel_path - return unless SettingsHelper.feature_on?(:cross_core_projects) - return if @order.cross_core_project_id.blank? current_user_facilities = current_user.facilities diff --git a/app/forms/add_to_order_form.rb b/app/forms/add_to_order_form.rb index ba2d22349f..309de4995f 100644 --- a/app/forms/add_to_order_form.rb +++ b/app/forms/add_to_order_form.rb @@ -31,12 +31,10 @@ def save if @original_order.facility.id == @facility_id add_to_order! - elsif SettingsHelper.feature_on?(:cross_core_projects) - if order_for_selected_facility.nil? - create_cross_core_project_and_add_order! - else - add_to_order! - end + elsif order_for_selected_facility.nil? + create_cross_core_project_and_add_order! + else + add_to_order! end true diff --git a/app/lib/ability.rb b/app/lib/ability.rb index 3a3df09e30..609712caeb 100644 --- a/app/lib/ability.rb +++ b/app/lib/ability.rb @@ -426,7 +426,7 @@ def cross_core_abilities(user, resource, controller) can :available_for_cross_core_ordering, Product elsif controller.is_a?(FacilityAccountsController) && user.facility_staff_or_manager_of_any_facility? can [:accounts_available_for_order], Account - elsif controller.is_a?(FacilityOrderDetailsController) && resource.is_a?(Facility) && SettingsHelper.feature_on?(:cross_core_projects) + elsif controller.is_a?(FacilityOrderDetailsController) && resource.is_a?(Facility) can [:destroy], OrderDetail do |order_detail| project = order_detail.order.cross_core_project @@ -440,7 +440,7 @@ def cross_core_abilities(user, resource, controller) end end - if resource.is_a?(OrderDetail) && SettingsHelper.feature_on?(:cross_core_projects) + if resource.is_a?(OrderDetail) project = resource.order.cross_core_project if project.present? @@ -448,7 +448,7 @@ def cross_core_abilities(user, resource, controller) end end - if controller.is_a?(FileUploadsController) && resource.is_a?(Facility) && SettingsHelper.feature_on?(:cross_core_projects) + if controller.is_a?(FileUploadsController) && resource.is_a?(Facility) can [:upload_sample_results, :destroy], StoredFile do |fileupload| project = fileupload.order_detail.project diff --git a/app/models/order.rb b/app/models/order.rb index f76c5cdb07..7503f8a524 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -24,12 +24,6 @@ class Order < ApplicationRecord attr_reader :project_id - def cross_core_project - return nil unless SettingsHelper.feature_on?(:cross_core_projects) - - super - end - def self.created_by_user(user) where(created_by: user.id) end diff --git a/app/views/facility_orders/_merge_order_form.html.haml b/app/views/facility_orders/_merge_order_form.html.haml index bb04c2cf78..cf0890a01e 100644 --- a/app/views/facility_orders/_merge_order_form.html.haml +++ b/app/views/facility_orders/_merge_order_form.html.haml @@ -1,7 +1,7 @@ - if @merge_orders.blank? .well = simple_form_for [current_facility, @add_to_order_form], url: facility_order_path(current_facility, @order), method: :put, html: { class: "js--edit-order" } do |f| - - enable_cross_core_changes = SettingsHelper.feature_on?(:cross_core_projects) && can?(:available_for_cross_core_ordering, Product) + - enable_cross_core_changes = can?(:available_for_cross_core_ordering, Product) - if enable_cross_core_changes = f.label :facility_id, Facility.model_name.human = f.input_field :facility_id, diff --git a/app/views/facility_orders/show.html.haml b/app/views/facility_orders/show.html.haml index 6701c688c8..4569905e86 100644 --- a/app/views/facility_orders/show.html.haml +++ b/app/views/facility_orders/show.html.haml @@ -8,15 +8,14 @@ = banner_date_label @order, :ordered_at = banner_label @order, :user = banner_label @order, :created_by_user - - if SettingsHelper.feature_on?(:cross_core_projects) - - if @cross_core_project.present? - %dl.span2 - %dt= t("views.facility_orders.show.cross_core_project_id") - %dd - = link_to @cross_core_project.name, facility_project_path(current_facility, @cross_core_project.id) - %dl.span2 - %dt= t("views.facility_orders.show.cross_core_project_total") - %dd= number_to_currency @gross_order_value + - if @cross_core_project.present? + %dl.span2 + %dt= t("views.facility_orders.show.cross_core_project_id") + %dd + = link_to @cross_core_project.name, facility_project_path(current_facility, @cross_core_project.id) + %dl.span2 + %dt= t("views.facility_orders.show.cross_core_project_total") + %dd= number_to_currency @gross_order_value - if @merge_orders.blank? && current_ability.can?(:send_receipt, @order) .pull-right= render "send_receipt" @@ -30,7 +29,7 @@ - subheader_key = (@cross_core_project.present? ? "views.facility_orders.show.add_to_cross_core_order_header" : "views.facility_orders.show.add_to_order_header") %h2= t(subheader_key) -- if SettingsHelper.feature_on?(:cross_core_projects) && @cross_core_data_by_facility_id.present? +- if @cross_core_data_by_facility_id.present? #js--reportAnIssueModal.modal.hide.fade #accordion diff --git a/config/settings.yml b/config/settings.yml index e1537b9bea..a964030372 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -158,7 +158,6 @@ feature: facility_tile_list_admin: false po_require_affiliate_account: true walkup_reservations: true - cross_core_projects: true cross_core_order_view: <%= ENV.fetch("CROSS_CORE_ORDER_VIEW", true) %> show_reconciliation_deposit_number: <%= ENV.fetch("RECONCILIATION_DEPOSIT_NUMBER", false) %> show_daily_rate_option: true diff --git a/spec/system/admin/adding_to_a_cross_core_order_spec.rb b/spec/system/admin/adding_to_a_cross_core_order_spec.rb index 857e6e89ae..c6b012de80 100644 --- a/spec/system/admin/adding_to_a_cross_core_order_spec.rb +++ b/spec/system/admin/adding_to_a_cross_core_order_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe "Adding to an existing order for cross core", :js, feature_setting: { cross_core_projects: true } do +RSpec.describe "Adding to an existing order for cross core", :js do let(:facility) { product.facility } let(:order) { create(:purchased_order, product: product, ordered_at: 1.week.ago) } let(:user) { create(:user, :staff, facility: facility) } @@ -96,7 +96,7 @@ end describe "adding an instrument reservation" do - describe "from another facility", :js, feature_setting: { cross_core_projects: true } do + describe "from another facility", :js do let(:product) { create(:setup_item, :with_facility_account) } let!(:instrument) { create(:setup_instrument, facility: facility2, cross_core_ordering_available: true) } let(:user) { create(:user, :facility_administrator, facility:) } diff --git a/spec/system/admin/adding_to_an_order_spec.rb b/spec/system/admin/adding_to_an_order_spec.rb index 6e1fc647dc..65e1bff9af 100644 --- a/spec/system/admin/adding_to_an_order_spec.rb +++ b/spec/system/admin/adding_to_an_order_spec.rb @@ -177,7 +177,7 @@ end end - describe "from same facility (with feature flag on)", :js, feature_setting: { cross_core_projects: true } do + describe "from same facility (with feature flag on)", :js do let(:product) { create(:setup_item, :with_facility_account) } let!(:instrument) { create(:setup_instrument, facility: facility) } let(:user) { create(:user, :facility_administrator, facility:) } diff --git a/spec/system/admin/reservation_actions_spec.rb b/spec/system/admin/reservation_actions_spec.rb index 0692b086ea..f605dbf4ab 100644 --- a/spec/system/admin/reservation_actions_spec.rb +++ b/spec/system/admin/reservation_actions_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe "Reservation actions", :js, feature_setting: { cross_core_projects: true } do +RSpec.describe "Reservation actions", :js do include_context "cross core orders" let(:facility2_instrument) { create(:setup_instrument, facility: facility2) }