diff --git a/app/forms/add_to_order_form.rb b/app/forms/add_to_order_form.rb index 0bc10167fc..ba8dd685c9 100644 --- a/app/forms/add_to_order_form.rb +++ b/app/forms/add_to_order_form.rb @@ -31,14 +31,12 @@ def save if @original_order.facility.id == @facility_id add_to_order! - end - - return true unless SettingsHelper.feature_on?(:cross_core_projects) - - if order_for_selected_facility.nil? - create_cross_core_project_and_add_order! - else - 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 end true diff --git a/app/views/facility_orders/show.html.haml b/app/views/facility_orders/show.html.haml index d82e250120..4ca30547c9 100644 --- a/app/views/facility_orders/show.html.haml +++ b/app/views/facility_orders/show.html.haml @@ -13,8 +13,8 @@ - if project_id %dl.span2 %dt= t("views.facility_orders.show.cross_core_project_id") - = link_to facility_project_path(current_facility, project_id) do - %dd= project_id + %dd + = link_to project_id, facility_project_path(current_facility, project_id) %dl.span2 %dt= t("views.facility_orders.show.cross_core_project_total") - gross_order_value = @order.total + @cross_core_orders_by_facility.values.sum(&:total) diff --git a/spec/system/admin/adding_to_an_order_spec.rb b/spec/system/admin/adding_to_an_order_spec.rb index f40abcf750..37d3ddde03 100644 --- a/spec/system/admin/adding_to_an_order_spec.rb +++ b/spec/system/admin/adding_to_an_order_spec.rb @@ -169,6 +169,37 @@ end end + describe "from same facility (with feature flag on)", :js, feature_setting: { cross_core_projects: true } do + let(:product) { create(:setup_item, :with_facility_account) } + let!(:instrument) { create(:setup_instrument, facility: facility) } + let(:user) { create(:user, :facility_administrator, facility:) } + + before do + visit facility_order_path(facility, order) + fill_in "add_to_order_form[quantity]", with: "1" + select_from_chosen instrument.name, from: "add_to_order_form[product_id]" + click_button "Add To Order" + end + + it "requires a reservation to be set up before adding to the order" do + expect(page).to have_content("The following order details need your attention.") + + click_link "Make a Reservation" + click_button "Create" + + expect(order.reload.order_details.count).to be(2) + expect(order.order_details.last.product).to eq(instrument) + end + + it "brings you back to the facility order path on 'Cancel'" do + click_link "Make a Reservation" + click_link "Cancel" + + expect(current_path).to eq(facility_order_path(facility, order)) + expect(page).to have_link("Make a Reservation") + end + end + describe "from another facility", :js, feature_setting: { cross_core_projects: true } do let(:facility2) { create(:setup_facility) } let(:product) { create(:setup_item, :with_facility_account) }