Skip to content

Commit f911e07

Browse files
authored
Merge pull request #5380 from brodyf42/5374_remove_request_unit_from_item_form_for_orgs_without_request_units
[5374] Hide Additional Custom Request Units section when editing item if the organization has no request units
2 parents f957323 + ce93b36 commit f911e07

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/views/items/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<%= f.input_field :package_size, class: "form-control", min: 0 %>
4545
<% end %>
4646

47-
<% if Flipper.enabled?(:enable_packs) %>
47+
<% if Flipper.enabled?(:enable_packs) && current_organization.request_units.present? %>
4848
<%= f.input :request_units, label: "Additional Custom Request Units" do %>
4949
<%= f.association :request_units, as: :check_boxes, collection: current_organization.request_units, checked: selected_item_request_units(@item), label_method: :name, value_method: :id, class: "form-check-input" %>
5050
<% end %>

spec/requests/items_requests_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
end
112112
end
113113

114+
context "when the organization has no request_units" do
115+
let(:item) { create(:item, organization: organization) }
116+
before { organization.request_units.destroy_all }
117+
118+
it "does not show the Additional Custom Request Units section" do
119+
get edit_item_path(item)
120+
expect(response.body).to_not match "Additional Custom Request Units"
121+
end
122+
end
123+
114124
context "when item is housing a kit" do
115125
let(:kit) { create(:kit, organization:) }
116126
let(:item) { create(:item, organization: organization, kit:) }

0 commit comments

Comments
 (0)