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 2 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
1 change: 1 addition & 0 deletions app/forms/add_to_order_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def save

if @original_order.facility.id == @facility_id
add_to_order!
return true
end

return true unless SettingsHelper.feature_on?(:cross_core_projects)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'd prefer to wrap the feature flagged changes in a conditional, instead of using a guard clause:

  if 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

... then we can still git true on line 45.
This would be easier to read and clearer what needs to happen when we are ready to remove the flag.

Expand Down
5 changes: 3 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,9 @@
- 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 facility_project_path(current_facility, project_id) do
= project_id
giladshanan marked this conversation as resolved.
Show resolved Hide resolved
%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