Skip to content

Commit

Permalink
Remove cross_core_projects
Browse files Browse the repository at this point in the history
  • Loading branch information
LeticiaErrandonea committed Feb 26, 2025
1 parent ecfe2a3 commit 874b8a6
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 39 deletions.
4 changes: 1 addition & 3 deletions app/controllers/facility_orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/order_detail_stored_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
10 changes: 4 additions & 6 deletions app/forms/add_to_order_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/lib/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -440,15 +440,15 @@ 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?
can [:add_accessories, :new, :show, :update, :cancel, :template_results], OrderDetail if user.facility_staff_or_manager_of?(project.facility)
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

Expand Down
6 changes: 0 additions & 6 deletions app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/facility_orders/_merge_order_form.html.haml
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
19 changes: 9 additions & 10 deletions app/views/facility_orders/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/adding_to_a_cross_core_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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:) }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/adding_to_an_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:) }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/reservation_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 874b8a6

Please sign in to comment.