Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#162225] Multi-Facility - Duplicates being created #4189

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/forms/add_to_order_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ def save

if @original_order.facility.id == @facility_id
add_to_order!
return true
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!
if SettingsHelper.feature_on?(:cross_core_projects)
Copy link
Contributor

@giladshanan giladshanan Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeticiaErrandonea maybe this should be elsif?

if order_for_selected_facility.nil?
create_cross_core_project_and_add_order!
else
add_to_order!
end
end

true
Expand Down
4 changes: 2 additions & 2 deletions app/views/facility_orders/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions spec/system/admin/adding_to_an_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
Loading