diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb
index 6a807efab7..704ea2db73 100644
--- a/app/controllers/items_controller.rb
+++ b/app/controllers/items_controller.rb
@@ -31,11 +31,11 @@ def index
end
def create
- create = if Flipper.enabled?(:enable_packs)
- ItemCreateService.new(organization_id: current_organization.id, item_params: item_params, request_unit_ids:)
- else
- ItemCreateService.new(organization_id: current_organization.id, item_params: item_params)
- end
+ create = ItemCreateService.new(
+ organization_id: current_organization.id,
+ item_params: item_params,
+ request_unit_ids: request_unit_ids
+ )
result = create.call
if result.success?
@@ -182,11 +182,7 @@ def request_unit_ids
# We need to update both the item and the request_units together and fail together
def update_item
- if Flipper.enabled?(:enable_packs)
- update_item_and_request_units
- else
- @item.save
- end
+ update_item_and_request_units
end
def update_item_and_request_units
diff --git a/app/controllers/partners/requests_controller.rb b/app/controllers/partners/requests_controller.rb
index 0595a0f342..3fc3a8e781 100644
--- a/app/controllers/partners/requests_controller.rb
+++ b/app/controllers/partners/requests_controller.rb
@@ -80,13 +80,11 @@ def partner_request_params
def fetch_items
@requestable_items = PartnerFetchRequestableItemsService.new(partner_id: partner.id).call
- if Flipper.enabled?(:enable_packs)
- # hash of (item ID => hash of (request unit name => request unit plural name))
- item_ids = @requestable_items.to_h.values
- if item_ids.present?
- @item_units = Item.where(id: item_ids).to_h do |i|
- [i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }]
- end
+ # Packs are always enabled, so always fetch item units
+ item_ids = @requestable_items.to_h.values
+ if item_ids.present?
+ @item_units = Item.where(id: item_ids).to_h do |i|
+ [i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }]
end
end
end
diff --git a/app/models/partners/item_request.rb b/app/models/partners/item_request.rb
index 544d8f04af..078b448cba 100644
--- a/app/models/partners/item_request.rb
+++ b/app/models/partners/item_request.rb
@@ -37,7 +37,7 @@ def request_unit_is_supported
end
def name_with_unit(quantity_override = nil)
- if Flipper.enabled?(:enable_packs) && request_unit.present?
+ if request_unit.present?
"#{item&.name || name} - #{request_unit.pluralize(quantity_override || quantity.to_i)}"
else
item&.name || name
diff --git a/app/pdfs/distribution_pdf.rb b/app/pdfs/distribution_pdf.rb
index 56c9ad6a7e..0cb849befa 100644
--- a/app/pdfs/distribution_pdf.rb
+++ b/app/pdfs/distribution_pdf.rb
@@ -264,9 +264,7 @@ def insert_signature_fields
else
move_down 20
end
-
signature_lines_for "Received By:"
-
move_down 20
signature_lines_for "Delivered By:"
end
@@ -291,7 +289,7 @@ def signature_lines_for(label)
end
def request_display_qty(request_item)
- if Flipper.enabled?(:enable_packs) && request_item&.unit
+ if request_item&.unit
"#{request_item.quantity} #{request_item.unit.pluralize(request_item.quantity)}"
else
request_item&.quantity || ""
diff --git a/app/pdfs/picklists_pdf.rb b/app/pdfs/picklists_pdf.rb
index 63e03f3eb8..2ee121558d 100644
--- a/app/pdfs/picklists_pdf.rb
+++ b/app/pdfs/picklists_pdf.rb
@@ -144,7 +144,7 @@ def compute_and_render
end
def has_custom_units?(line_items)
- Flipper.enabled?(:enable_packs) && line_items.any? { |line_item| line_item.request_unit }
+ line_items.any? { |line_item| line_item.request_unit }
end
def data_with_units(line_items)
diff --git a/app/services/exports/export_request_service.rb b/app/services/exports/export_request_service.rb
index 02da2c4c83..fe8ba09b0b 100644
--- a/app/services/exports/export_request_service.rb
+++ b/app/services/exports/export_request_service.rb
@@ -70,16 +70,14 @@ def compute_item_headers
if item_request.item
item = item_request.item
item_names << item.name
- if Flipper.enabled?(:enable_packs)
- item.request_units.each do |unit|
- item_names << "#{item.name} - #{unit.name.pluralize}"
- end
-
- # It's possible that the unit is no longer valid, so we'd
- # add that individually
- if item_request.request_unit.present?
- item_names << "#{item.name} - #{item_request.request_unit.pluralize}"
- end
+ item.request_units.each do |unit|
+ item_names << "#{item.name} - #{unit.name.pluralize}"
+ end
+
+ # It's possible that the unit is no longer valid, so we'd
+ # add that individually
+ if item_request.request_unit.present?
+ item_names << "#{item.name} - #{item_request.request_unit.pluralize}"
end
end
end
@@ -97,7 +95,15 @@ def build_row_data(request)
row += Array.new(item_headers.size, 0)
request.item_requests.each do |item_request|
- item_name = item_request.item.present? ? item_request.name_with_unit(0) : DELETED_ITEMS_COLUMN_HEADER
+ item_name = if item_request.item.present?
+ if item_request.request_unit.present?
+ item_request.name_with_unit(0)
+ else
+ item_request.item.name
+ end
+ else
+ DELETED_ITEMS_COLUMN_HEADER
+ end
item_column_idx = headers_with_indexes[item_name]
row[item_column_idx] ||= 0
row[item_column_idx] += item_request.quantity.to_i
diff --git a/app/services/item_create_service.rb b/app/services/item_create_service.rb
index 01159d33e4..5450e36492 100644
--- a/app/services/item_create_service.rb
+++ b/app/services/item_create_service.rb
@@ -8,10 +8,7 @@ def initialize(organization_id:, item_params:, request_unit_ids: [])
def call
new_item = organization.items.new(item_params)
new_item.save!
- if Flipper.enabled?(:enable_packs)
- new_item.sync_request_units!(@request_unit_ids)
- end
-
+ new_item.sync_request_units!(@request_unit_ids)
Result.new(value: new_item)
rescue StandardError => e
Result.new(error: e)
diff --git a/app/services/organization_update_service.rb b/app/services/organization_update_service.rb
index d462a895ce..9173732671 100644
--- a/app/services/organization_update_service.rb
+++ b/app/services/organization_update_service.rb
@@ -18,15 +18,13 @@ def update(organization, params)
org_params["partner_form_fields"] = org_params["partner_form_fields"].compact_blank
end
- if Flipper.enabled?(:enable_packs)
- request_unit_names = org_params[:request_unit_names] || []
- # Find or create units for the organization
- request_unit_ids = request_unit_names.compact_blank.map do |request_unit_name|
- Unit.find_or_create_by(organization: organization, name: request_unit_name).id
- end
- org_params.delete(:request_unit_names)
- org_params[:request_unit_ids] = request_unit_ids
+ request_unit_names = org_params[:request_unit_names] || []
+ # Find or create units for the organization
+ request_unit_ids = request_unit_names.compact_blank.map do |request_unit_name|
+ Unit.find_or_create_by(organization: organization, name: request_unit_name).id
end
+ org_params.delete(:request_unit_names)
+ org_params[:request_unit_ids] = request_unit_ids
result = organization.update(org_params)
diff --git a/app/views/items/_form.html.erb b/app/views/items/_form.html.erb
index 7af1f6e98e..5196a04190 100644
--- a/app/views/items/_form.html.erb
+++ b/app/views/items/_form.html.erb
@@ -43,11 +43,9 @@
<%= f.input_field :package_size, class: "form-control", min: 0 %>
<% end %>
- <% if Flipper.enabled?(:enable_packs) %>
<%= f.input :request_units, label: "Additional Custom Request Units" do %>
<%= 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" %>
<% end %>
- <% end %>
<%= f.input :visible, label: "Item is Visible to Partners?", wrapper: :input_group do %>
<%= f.check_box :visible_to_partners, {class: "input-group-text", id: "visible_to_partners"}, "true", "false" %>
diff --git a/app/views/items/_item_list.html.erb b/app/views/items/_item_list.html.erb
index 5a3fe1e521..0a2278027a 100644
--- a/app/views/items/_item_list.html.erb
+++ b/app/views/items/_item_list.html.erb
@@ -11,10 +11,8 @@
Add. Info |
Quantity Per Individual |
Fair Market Value (per item) |
- <% if Flipper.enabled?(:enable_packs) %>
- <% unless current_organization.request_units.empty? %>
- Custom Request Units |
- <% end %>
+ <% unless current_organization.request_units.empty? %>
+ Custom Request Units |
<% end %>
Actions |
diff --git a/app/views/items/_item_row.html.erb b/app/views/items/_item_row.html.erb
index 5efb0ab31d..0e1d160750 100644
--- a/app/views/items/_item_row.html.erb
+++ b/app/views/items/_item_row.html.erb
@@ -4,10 +4,8 @@
<%= truncate item_row.additional_info, length: 25 %> |
<%= item_row.distribution_quantity %> |
<%= dollar_value(item_row.value_in_cents) %> |
- <% if Flipper.enabled?(:enable_packs) %>
- <% unless current_organization.request_units.empty? %>
- <%= item_row.request_units.pluck(:name).join(', ') %> |
- <% end %>
+ <% unless current_organization.request_units.empty? %>
+ <%= item_row.request_units.pluck(:name).join(', ') %> |
<% end %>
<%= view_button_to item_path(item_row) %>
diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb
index 644f6e90e4..01a5e48dde 100644
--- a/app/views/items/show.html.erb
+++ b/app/views/items/show.html.erb
@@ -64,11 +64,9 @@
| <%= @item.package_size || 0 %> |
- <% if Flipper.enabled?(:enable_packs) %>
- | Custom Units |
- <% item_units = @item.request_units&.pluck("item_units.name") %>
- <%= item_units&.join("; ") %> |
- <% end %>
+ Custom Units |
+ <% item_units = @item.request_units&.pluck("item_units.name") %>
+ <%= item_units&.join("; ") %> |
| Item is visible to partners |
diff --git a/app/views/organizations/_details.html.erb b/app/views/organizations/_details.html.erb
index 0a1fae3d51..90dee8f736 100644
--- a/app/views/organizations/_details.html.erb
+++ b/app/views/organizations/_details.html.erb
@@ -149,24 +149,22 @@
<%= humanize_boolean(@organization.enable_quantity_based_requests) %>
- <% if Flipper.enabled?(:enable_packs) %>
-
-
Custom Request units used (please use singular form -- e.g. pack, not packs)
-
- <% if @organization.request_units.length > 0 %>
- <% @organization.request_units.map do |unit| %>
- <%= fa_icon "angle-right" %>
-
- <%= unit.name.titlecase %>
-
- <% end %>
- <% else %>
+
+
Custom Request units used (please use singular form -- e.g. pack, not packs)
+
+ <% if @organization.request_units.length > 0 %>
+ <% @organization.request_units.map do |unit| %>
<%= fa_icon "angle-right" %>
- None
+
+ <%= unit.name.titlecase %>
+
<% end %>
-
-
- <% end %>
+ <% else %>
+ <%= fa_icon "angle-right" %>
+
None
+ <% end %>
+
+
Other emails
diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb
index 4e44a78e43..632ac18037 100644
--- a/app/views/organizations/edit.html.erb
+++ b/app/views/organizations/edit.html.erb
@@ -129,25 +129,23 @@
<%= f.input :enable_child_based_requests, label: 'Enable Partners to make child-based Requests?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
<%= f.input :enable_individual_requests, label: 'Enable Partners to make Requests by indicating number of individuals needing each Item?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
<%= f.input :enable_quantity_based_requests, label: 'Enable Partners to make quantity-based Requests?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
- <% if Flipper.enabled?(:enable_packs) %>
- <%= label_tag "organization[request_unit_names]", 'Custom request units used. Please use singular form -- e.g. pack, not packs. There will be a default "unit" entry provided.' %>
- <%= select_tag(
- "organization[request_unit_names]",
- options_from_collection_for_select(
- current_organization.request_units,
- 'name',
- 'name',
- ->(_) { true } # Select all of the current request units
- ),
- {
- multiple: true,
- class: 'form-control custom-select',
- 'data-controller': 'select2',
- 'data-select2-hide-dropdown-value': true,
- 'data-select2-config-value': '{"selectOnClose": "true", "tags": "true", "tokenSeparators": [",", "\t"]}'
- }
- ) %>
- <% end %>
+ <%= label_tag "organization[request_unit_names]", 'Custom request units used. Please use singular form -- e.g. pack, not packs. There will be a default "unit" entry provided.' %>
+ <%= select_tag(
+ "organization[request_unit_names]",
+ options_from_collection_for_select(
+ current_organization.request_units,
+ 'name',
+ 'name',
+ ->(_) { true } # Select all of the current request units
+ ),
+ {
+ multiple: true,
+ class: 'form-control custom-select',
+ 'data-controller': 'select2',
+ 'data-select2-hide-dropdown-value': true,
+ 'data-select2-config-value': '{"selectOnClose": "true", "tags": "true", "tokenSeparators": [",", "\t"]}'
+ }
+ ) %>
Other emails
diff --git a/app/views/partners/dashboards/_requests_in_progress.html.erb b/app/views/partners/dashboards/_requests_in_progress.html.erb
index 71a2f84151..5e1a16d287 100644
--- a/app/views/partners/dashboards/_requests_in_progress.html.erb
+++ b/app/views/partners/dashboards/_requests_in_progress.html.erb
@@ -24,7 +24,7 @@
<% request.item_requests.each do |item_request| %>
- <% if Flipper.enabled?(:enable_packs) && item_request.request_unit %>
+ <% if item_request.request_unit %>
<%= pluralize(item_request.quantity, item_request.request_unit) %>
—
<% else %>
diff --git a/app/views/partners/requests/_error.html.erb b/app/views/partners/requests/_error.html.erb
index d4c4b6708b..71b68a6bb4 100644
--- a/app/views/partners/requests/_error.html.erb
+++ b/app/views/partners/requests/_error.html.erb
@@ -8,7 +8,7 @@
Ensure each line item has a item selected AND a quantity greater than 0.
- <% if Flipper.enabled?(:enable_packs) && (current_partner&.organization || current_organization).request_units.any? %>
+ <% if (current_partner&.organization || current_organization).request_units.any? %>
Please ensure a single unit is selected for each item that supports it.
<% end %>
diff --git a/app/views/partners/requests/_item_request.html.erb b/app/views/partners/requests/_item_request.html.erb
index 2afdbcc112..4a26c47044 100644
--- a/app/views/partners/requests/_item_request.html.erb
+++ b/app/views/partners/requests/_item_request.html.erb
@@ -12,7 +12,7 @@
<%= field.number_field :quantity, label: false, step: 1, min: 1, class: 'form-control' %>
|
- <% if Flipper.enabled?(:enable_packs) && (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %>
+ <% if (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %>
<%= field.label :request_unit, "Unit", {class: 'sr-only'} %>
<%= field.select :request_unit, [], {include_blank: 'units'},
diff --git a/app/views/partners/requests/new.html.erb b/app/views/partners/requests/new.html.erb
index 8392e17828..4a89ed1556 100644
--- a/app/views/partners/requests/new.html.erb
+++ b/app/views/partners/requests/new.html.erb
@@ -42,7 +42,7 @@
|
| Item Requested |
Quantity |
- <% if Flipper.enabled?(:enable_packs) && (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %>
+ <% if (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %>
Units (if applicable) |
<% end %>
diff --git a/app/views/partners/requests/show.html.erb b/app/views/partners/requests/show.html.erb
index c658860818..4306be174d 100644
--- a/app/views/partners/requests/show.html.erb
+++ b/app/views/partners/requests/show.html.erb
@@ -56,7 +56,7 @@
<% @partner_request.item_requests.each do |item| %>
<%= item.name %> - <%= item.quantity %>
- <% if Flipper.enabled?(:enable_packs) && item.request_unit %>
+ <% if item.request_unit %>
<%= item.request_unit.pluralize(item.quantity.to_i) %>
<% end %>
diff --git a/app/views/partners/requests/validate.html.erb b/app/views/partners/requests/validate.html.erb
index 87be2655b2..0020859e6f 100644
--- a/app/views/partners/requests/validate.html.erb
+++ b/app/views/partners/requests/validate.html.erb
@@ -11,7 +11,7 @@
| Item Name |
Total Items |
- <% if Flipper.enabled?(:enable_packs) && @partner_request.item_requests.any?( &:request_unit ) %>
+ <% if @partner_request.item_requests.any?( &:request_unit ) %>
Units |
<% end %>
@@ -21,7 +21,7 @@
| <%= line_item.name %> |
<%= line_item.quantity %> |
- <% if Flipper.enabled?(:enable_packs) && @partner_request.item_requests.any?( &:request_unit ) %>
+ <% if @partner_request.item_requests.any?( &:request_unit ) %>
<%= line_item.request_unit&.pluralize(line_item.quantity.to_i) %> |
<% end %>
diff --git a/app/views/requests/show.html.erb b/app/views/requests/show.html.erb
index c2560ce0cd..567fba50ed 100644
--- a/app/views/requests/show.html.erb
+++ b/app/views/requests/show.html.erb
@@ -67,8 +67,7 @@
| Item |
Quantity |
- <% custom_units = Flipper.enabled?(:enable_packs) &&
- @request.item_requests.any? { |item| item.request_unit } %>
+ <% custom_units = @request.item_requests.any? { |item| item.request_unit } %>
<% if custom_units %>
Units (if applicable) |
<% end %>
diff --git a/app/views/requests_confirmation_mailer/confirmation_email.html.erb b/app/views/requests_confirmation_mailer/confirmation_email.html.erb
index ae7f75f4d4..26d6327f90 100644
--- a/app/views/requests_confirmation_mailer/confirmation_email.html.erb
+++ b/app/views/requests_confirmation_mailer/confirmation_email.html.erb
@@ -4,7 +4,7 @@
<% @request_items.each do |item| %>
- <%= item['name'] %> -
- <% if Flipper.enabled?(:enable_packs) && item['unit'] %>
+ <% if item['unit'] %>
<%= pluralize(item['quantity'] || item['person_count'], item['unit']) %>
<% else %>
<%= item['quantity'] || item['person_count'] %>
diff --git a/db/seeds.rb b/db/seeds.rb
index a5ab90bb63..68807394ac 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -349,7 +349,7 @@ def seed_random_item_with_name(organization, name)
receives_essentials_from_other: Faker::Lorem.sentence,
)
end
-
+
if p.partials_to_show.include? "organizational_capacity"
profile.update(
client_capacity: Faker::Lorem.sentence,
@@ -1111,8 +1111,6 @@ def seed_quantity(item_name, organization, storage_location, quantity)
Flipper.enable(:read_events)
Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: "partner_step_form")
Flipper.enable(:partner_step_form)
-Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: "enable_packs")
-Flipper.enable(:enable_packs)
# ----------------------------------------------------------------------------
# Account Requests
# ----------------------------------------------------------------------------
diff --git a/spec/controllers/items_controller_spec.rb b/spec/controllers/items_controller_spec.rb
index 31299f3bd9..b471266b9f 100644
--- a/spec/controllers/items_controller_spec.rb
+++ b/spec/controllers/items_controller_spec.rb
@@ -53,7 +53,6 @@
end
context "request units" do
- before(:each) { Flipper.enable(:enable_packs) }
let(:item) { create(:item, organization:) }
let(:unit) { create(:unit, organization:) }
it "should add new item's request units" do
@@ -168,7 +167,6 @@
end
it "should accept request_unit ids and create request_units" do
- Flipper.enable(:enable_packs)
unit = create(:unit, organization: organization)
item_params[:item] = item_params[:item].merge({request_unit_ids: [unit.id]})
post :create, params: item_params
diff --git a/spec/mailers/requests_confirmation_mailer_spec.rb b/spec/mailers/requests_confirmation_mailer_spec.rb
index 4a75e3b043..fbfc3e17d0 100644
--- a/spec/mailers/requests_confirmation_mailer_spec.rb
+++ b/spec/mailers/requests_confirmation_mailer_spec.rb
@@ -60,7 +60,6 @@
end
it "shows units" do
- Flipper.enable(:enable_packs)
item1 = create(:item, organization:)
item2 = create(:item, organization:)
create(:item_unit, item: item1, name: "Pack")
@@ -76,7 +75,6 @@
end
it "skips units when are not provided" do
- Flipper.enable(:enable_packs)
item = create(:item, organization:)
create(:item_unit, item: item, name: "Pack")
request = create(:request, :pending, request_items: [{item_id: item.id, quantity: 7}])
diff --git a/spec/pdfs/distribution_pdf_spec.rb b/spec/pdfs/distribution_pdf_spec.rb
index 765dc1a825..789e508d62 100644
--- a/spec/pdfs/distribution_pdf_spec.rb
+++ b/spec/pdfs/distribution_pdf_spec.rb
@@ -21,7 +21,6 @@
end
specify "#request_data with custom units feature" do
- Flipper.enable(:enable_packs)
results = described_class.new(organization, distribution).request_data
expect(results).to eq([
["Items Received", "Requested", "Received", "Value/item", "In-Kind Value Received", "Packages"],
@@ -56,7 +55,7 @@
["Item 1", "", 50],
["Item 2", 30, 100],
["Item 3", 50, ""],
- ["Item 4", 120, ""],
+ ["Item 4", "120 packs", ""],
["", "", ""],
["Total Items Received", 200, 150]
])
@@ -71,7 +70,7 @@
["Item 1", "", 50, "1"],
["Item 2", 30, 100, nil],
["Item 3", 50, "", nil],
- ["Item 4", 120, "", nil],
+ ["Item 4", "120 packs", "", nil],
["", "", ""],
["Total Items Received", 200, 150, ""]
])
@@ -89,7 +88,7 @@
["Item 1", "", 50],
["Item 2", 30, 100],
["Item 3", 50, ""],
- ["Item 4", 120, ""],
+ ["Item 4", "120 packs", ""],
["", "", ""],
["Total Items Received", 200, 150]
])
@@ -104,7 +103,7 @@
["Item 1", "", 50, "1"],
["Item 2", 30, 100, nil],
["Item 3", 50, "", nil],
- ["Item 4", 120, "", nil],
+ ["Item 4", "120 packs", "", nil],
["", "", ""],
["Total Items Received", 200, 150, ""]
])
@@ -122,7 +121,7 @@
["Item 1", "", 50, "$1.00", "$50.00"],
["Item 2", 30, 100, "$2.00", "$200.00"],
["Item 3", 50, "", "$3.00", nil],
- ["Item 4", 120, "", "$4.00", nil],
+ ["Item 4", "120 packs", "", "$4.00", nil],
["", "", "", "", ""],
["Total Items Received", 200, 150, "", "$250.00"]
])
@@ -137,7 +136,6 @@ def compare_pdf(distribution, expected_file_path)
begin
# Run the following from Rails sandbox console (bin/rails/console --sandbox) to regenerate these comparison PDFs:
# => load "lib/test_helpers/pdf_comparison_test_factory.rb"
- # => Flipper.enable(:enable_packs)
# => PDFComparisonTestFactory.create_comparison_pdfs
expect(pdf_file).to eq(IO.binread(expected_file_path))
rescue RSpec::Expectations::ExpectationNotMetError => e
@@ -148,7 +146,6 @@ def compare_pdf(distribution, expected_file_path)
# The generated PDFs (PDFs to use for comparison) are expecting the packs feature to be enabled.
before(:each) do
- Flipper.enable(:enable_packs)
end
let(:partner) { PDFComparisonTestFactory.create_partner(organization) }
diff --git a/spec/pdfs/picklists_pdf_spec.rb b/spec/pdfs/picklists_pdf_spec.rb
index 49171f5fc8..90e019de7a 100644
--- a/spec/pdfs/picklists_pdf_spec.rb
+++ b/spec/pdfs/picklists_pdf_spec.rb
@@ -123,8 +123,6 @@
end
context "When packs are enabled" do
- before { Flipper.enable(:enable_packs) }
-
specify "#data_with_units" do
item_with_units = create(:item, name: "Item with units", organization: organization)
create(:item_unit, item: item_with_units, name: "Pack")
diff --git a/spec/requests/distributions_requests_spec.rb b/spec/requests/distributions_requests_spec.rb
index 19670522bf..b2992e86e9 100644
--- a/spec/requests/distributions_requests_spec.rb
+++ b/spec/requests/distributions_requests_spec.rb
@@ -378,7 +378,6 @@
context 'with units' do
before(:each) do
- Flipper.enable(:enable_packs)
end
it 'should behave correctly' do
@@ -738,7 +737,6 @@
]
}
before(:each) do
- Flipper.enable(:enable_packs)
create(:line_item, itemizable: distribution, item_id: items[0].id, quantity: 25)
create(:line_item, itemizable: distribution, item_id: items[2].id, quantity: 10)
end
diff --git a/spec/requests/items_requests_spec.rb b/spec/requests/items_requests_spec.rb
index a3cc49ae14..bb8904812c 100644
--- a/spec/requests/items_requests_spec.rb
+++ b/spec/requests/items_requests_spec.rb
@@ -80,7 +80,6 @@
describe "GET #new" do
it "shows the organization request_units options if they exist" do
- Flipper.enable(:enable_packs)
organization_units = create_list(:unit, 3, organization: organization)
get new_item_path
organization_units.each do |unit|
@@ -91,7 +90,6 @@
describe "GET #edit" do
it "shows the selected request_units" do
- Flipper.enable(:enable_packs)
organization_units = create_list(:unit, 3, organization: organization)
selected_unit = organization_units.first
item = create(:item, organization: organization)
@@ -254,8 +252,6 @@
end
context "custom request items" do
- before(:each) { Flipper.enable(:enable_packs) }
-
it "does not show the column if the organization does not use custom request units" do
get items_path
expect(response.body).not_to include("Custom Request Units")
@@ -280,7 +276,7 @@
let!(:item) { create(:item, organization: organization, name: "ACTIVEITEM", item_category_id: item_category.id, distribution_quantity: 2000, on_hand_recommended_quantity: 2348, package_size: 100, value_in_cents: 20000, on_hand_minimum_quantity: 1200, visible_to_partners: true) }
let!(:item_unit_1) { create(:item_unit, item: item, name: 'ITEM1') }
let!(:item_unit_2) { create(:item_unit, item: item, name: 'ITEM2') }
- it 'shows complete item details except custom request' do
+ it 'shows complete item details including custom request units' do
get item_path(id: item.id)
expect(response.body).to include('Base Item')
expect(response.body).to include('BASEITEM')
@@ -298,18 +294,10 @@
expect(response.body).to include('2348')
expect(response.body).to include('Package Size')
expect(response.body).to include('100')
- expect(response.body).not_to include('Custom Units')
- expect(response.body).not_to include("#ITEM1; ITEM2")
- expect(response.body).to include('Item is visible to partners')
- expect(response.body).to include('Yes')
- end
-
- it 'shows custom request units when flipper enabled' do
- Flipper.enable(:enable_packs)
- get item_path(id: item.id)
-
expect(response.body).to include('Custom Units')
expect(response.body).to include("ITEM1; ITEM2")
+ expect(response.body).to include('Item is visible to partners')
+ expect(response.body).to include('Yes')
end
end
end
diff --git a/spec/requests/organization_requests_spec.rb b/spec/requests/organization_requests_spec.rb
index b0e294d3b0..56b5f501ac 100644
--- a/spec/requests/organization_requests_spec.rb
+++ b/spec/requests/organization_requests_spec.rb
@@ -137,20 +137,9 @@
expect(response.body).to include("Default Center")
end
- context "when enable_packs flipper is on" do
- it "displays organization's custom units" do
- Flipper.enable(:enable_packs)
- get organization_path
- expect(response.body).to include "Wolf Pack"
- end
- end
-
- context "when enable_packs flipper is off" do
- it "does not display organization's custom units" do
- Flipper.disable(:enable_packs)
- get organization_path
- expect(response.body).to_not include "Wolf Pack"
- end
+ it "displays organization's custom units" do
+ get organization_path
+ expect(response.body).to include "Wolf Pack"
end
it "cannot see 'Demote to User' button for admins" do
@@ -203,20 +192,9 @@
expect(html.text).to include("Receive email when Partner makes a Request?")
end
- context "when enable_packs flipper is on" do
- it "displays organization's custom units" do
- Flipper.enable(:enable_packs)
- get organization_path
- expect(response.body).to include "Wolf Pack"
- end
- end
-
- context "when enable_packs flipper is off" do
- it "does not display organization's custom units" do
- Flipper.disable(:enable_packs)
- get organization_path
- expect(response.body).to_not include "Wolf Pack"
- end
+ it "displays organization's custom units" do
+ get organization_path
+ expect(response.body).to include "Wolf Pack"
end
it "can see 'Demote to User' button for admins" do
@@ -259,22 +237,10 @@
)
end
- context "when enable_packs flipper is on" do
- it "should display custom units and units form" do
- Flipper.enable(:enable_packs)
- get edit_organization_path
- expect(response.body).to include("Custom request units used")
- expect(response.body).to include "WolfPack"
- end
- end
-
- context "when enable_packs flipper is off" do
- it "should not display custom units and units form" do
- Flipper.disable(:enable_packs)
- get edit_organization_path
- expect(response.body).to_not include("Custom request units used")
- expect(response.body).to_not include "WolfPack"
- end
+ it "should display custom units and units form" do
+ get edit_organization_path
+ expect(response.body).to include("Custom request units used")
+ expect(response.body).to include "WolfPack"
end
end
diff --git a/spec/requests/partners/dashboard_requests_spec.rb b/spec/requests/partners/dashboard_requests_spec.rb
index 7475387487..dac880f2b3 100644
--- a/spec/requests/partners/dashboard_requests_spec.rb
+++ b/spec/requests/partners/dashboard_requests_spec.rb
@@ -38,7 +38,6 @@
end
it "shows units" do
- Flipper.enable(:enable_packs)
create(:item_unit, item: item1, name: "Pack")
create(:item_unit, item: item2, name: "Pack")
request = create(:request, :pending, partner: partner, request_items: [])
@@ -51,7 +50,6 @@
end
it "skips units when are not provided" do
- Flipper.enable(:enable_packs)
create(:item_unit, item: item1, name: "Pack")
request = create(:request, :pending, partner: partner, request_items: [])
create(:item_request, request: request, quantity: 7, item: item1)
diff --git a/spec/requests/partners/requests_spec.rb b/spec/requests/partners/requests_spec.rb
index 55b88df00a..584bc5e972 100644
--- a/spec/requests/partners/requests_spec.rb
+++ b/spec/requests/partners/requests_spec.rb
@@ -54,11 +54,9 @@
context "when packs are enabled but there are no requestable items" do
before do
allow_any_instance_of(PartnerFetchRequestableItemsService).to receive(:call).and_return({})
- Flipper.enable(:enable_packs)
end
after do
- Flipper.disable(:enable_packs)
end
it 'should render without any issues' do
@@ -181,13 +179,11 @@
]
)
- Flipper.enable(:enable_packs)
get partners_request_path(request)
expect(response.body).to match(/First item - 125/m)
expect(response.body).to match(/Second item - 559\s+flats/m)
expect(response.body).to match(/Third item - 1\s+flat/m)
- Flipper.disable(:enable_packs)
get partners_request_path(request)
expect(response.body).to match(/First item - 125/m)
expect(response.body).to match(/Second item - 559/m)
@@ -290,7 +286,6 @@
end
it "creates without error" do
- Flipper.enable(:enable_packs)
expect { subject }.to change { Request.count }.by(1)
expect(response).to redirect_to(partners_request_path(Request.last.id))
expect(response.request.flash[:success]).to eql "Request was successfully created."
@@ -319,7 +314,6 @@
end
it "results in an error" do
- Flipper.enable(:enable_packs)
expect { post partners_requests_path, params: request_attributes }.to_not change { Request.count }
expect(response).to be_unprocessable
expect(response.body).to include("Please ensure a single unit is selected for each item")
diff --git a/spec/requests/requests_requests_spec.rb b/spec/requests/requests_requests_spec.rb
index 6ff8095bfc..68157a168d 100644
--- a/spec/requests/requests_requests_spec.rb
+++ b/spec/requests/requests_requests_spec.rb
@@ -91,7 +91,6 @@
end
context 'When packs are enabled' do
- before { Flipper.enable(:enable_packs) }
let(:item) { create(:item, name: "Item", organization: organization) }
let(:request) { create(:request, organization: organization) }
diff --git a/spec/services/exports/export_request_service_spec.rb b/spec/services/exports/export_request_service_spec.rb
index 100994f0e7..0d15b4f2d7 100644
--- a/spec/services/exports/export_request_service_spec.rb
+++ b/spec/services/exports/export_request_service_spec.rb
@@ -96,7 +96,6 @@
context "with custom units feature enabled" do
before do
- Flipper.enable(:enable_packs)
end
describe ".generate_csv_data" do
@@ -221,7 +220,6 @@
context "with custom units feature disabled" do
before do
- Flipper.disable(:enable_packs)
end
describe ".generate_csv_data" do
@@ -234,6 +232,7 @@
"2T Diapers -- UPDATED",
"3T Diapers",
"4T Diapers",
+ "4T Diapers - packs",
""
])
end
@@ -251,6 +250,7 @@
0, # 2T Diapers
150, # 3T Diapers
0, # 4T Diapers
+ 0, # 4T Diapers - packs
0 #
])
end
@@ -264,6 +264,7 @@
100, # 2T Diapers
0, # 3T Diapers
0, # 4T Diapers
+ 0, # 4T Diapers - packs
0 #
])
end
@@ -277,6 +278,7 @@
0, # 2T Diapers
0, # 3T Diapers
0, # 4T Diapers
+ 0, # 4T Diapers - packs
400 #
])
end
@@ -289,7 +291,8 @@
"Started",
3, # 2T Diapers
2, # 3T Diapers
- 4, # 4T Diapers
+ 0, # 4T Diapers
+ 4, # 4T Diapers - packs
0 #
])
end
@@ -303,6 +306,7 @@
0, # 2T Diapers
0, # 3T Diapers
77, # 4T Diapers
+ 0, # 4T Diapers - packs
0 #
])
end
@@ -315,7 +319,8 @@
"Started",
0, # 2T Diapers
0, # 3T Diapers
- 1, # 4T Diapers
+ 0, # 4T Diapers
+ 1, # 4T Diapers - packs
0 #
])
end
diff --git a/spec/services/item_create_service_spec.rb b/spec/services/item_create_service_spec.rb
index 8c8d3eb555..3de3fe7cce 100644
--- a/spec/services/item_create_service_spec.rb
+++ b/spec/services/item_create_service_spec.rb
@@ -1,11 +1,12 @@
RSpec.describe ItemCreateService, type: :service do
describe '#call' do
- subject { described_class.new(organization_id: organization_id, item_params: item_params).call }
+ subject { described_class.new(organization_id: organization_id, item_params: item_params, request_unit_ids: request_unit_ids).call }
let(:organization_id) { organization.id }
let(:item_params) { { fake: 'param' } }
+ let(:request_unit_ids) { [] }
let(:organization) { create(:organization) }
let(:fake_organization_items) { instance_double('organization.items') }
- let(:fake_organization_item) { instance_double(Item, id: 99_999, save!: -> {}) }
+ let(:fake_organization_item) { instance_double(Item, id: 99_999, save!: -> {}, sync_request_units!: true) }
let(:fake_organization_storage_locations) do
[
instance_double(StorageLocation, id: 'fake-id-1'),
diff --git a/spec/services/organization_update_service_spec.rb b/spec/services/organization_update_service_spec.rb
index 1a9e980aa6..f738fc9ef3 100644
--- a/spec/services/organization_update_service_spec.rb
+++ b/spec/services/organization_update_service_spec.rb
@@ -11,7 +11,6 @@
end
it "Should set request_units on the organization" do
- Flipper.enable(:enable_packs)
params = {request_unit_names: ["newpack"]}
described_class.update(organization, params)
expect(organization.errors.none?).to eq(true)
diff --git a/spec/services/requests_total_items_service_spec.rb b/spec/services/requests_total_items_service_spec.rb
index 2ad28ba24a..f2cad8049a 100644
--- a/spec/services/requests_total_items_service_spec.rb
+++ b/spec/services/requests_total_items_service_spec.rb
@@ -14,51 +14,103 @@
let(:item_ids) { sample_items.pluck(:id) }
let(:requests) do
local_requests = [
- create(:request, :with_item_requests, request_items: item_ids.map { |k| { "item_id" => k, "quantity" => 20 } }),
+ create(:request, :with_item_requests, request_items: item_ids.map { |k| { "item_id" => k, "quantity" => 20, "request_unit" => "bundle" } }),
create(:request, :with_item_requests, request_items: item_ids.map { |k| { "item_id" => k, "quantity" => 10, "request_unit" => "bundle" } }),
create(:request, :with_item_requests, request_items: item_ids.map { |k| { "item_id" => k, "quantity" => 50, "request_unit" => "bundle" } })
]
Request.where(id: local_requests.map(&:id))
end
- it 'return items with correct quantities calculated' do
- expect(subject.first.last).to eq(80)
+ it 'returns items with correct quantities calculated' do
+ expect(subject.values.first).to eq(80)
end
- it 'return the names of items correctly' do
- expect(subject.keys).to eq([
- "item_name_0",
- "item_name_1",
- "item_name_2"
- ])
+ it 'returns the names of items correctly' do
+ expect(subject.keys).to include("item_name_0 - bundles")
end
+ end
- context 'when custom request units are specified and enabled' do
- before do
- Flipper.enable(:enable_packs)
- end
+ context 'when request_unit is blank' do
+ let(:item) { create(:item, :with_unit, name: "Test Item", organization: organization, unit: "piece") }
+ let(:requests) do
+ request = create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 5, "request_unit" => nil}])
+ Request.where(id: request.id)
+ end
- it 'returns the names of items correctly' do
- expect(subject.keys).to eq([
- "item_name_0",
- "item_name_1",
- "item_name_2",
- "item_name_0 - bundles",
- "item_name_1 - bundles",
- "item_name_2 - bundles"
- ])
- end
+ it 'handles nil request_unit gracefully' do
+ expect { subject }.not_to raise_error
+ end
+ end
- it 'returns items with correct quantities calculated' do
- expect(subject).to eq({
- "item_name_0" => 20,
- "item_name_0 - bundles" => 60,
- "item_name_1" => 20,
- "item_name_1 - bundles" => 60,
- "item_name_2" => 20,
- "item_name_2 - bundles" => 60
- })
- end
+ context 'when request_unit is empty string' do
+ let(:item) { create(:item, :with_unit, name: "Test Item", organization: organization, unit: "piece") }
+ let(:requests) do
+ request = create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 5, "request_unit" => ""}])
+ Request.where(id: request.id)
+ end
+
+ it 'handles empty request_unit gracefully' do
+ expect { subject }.not_to raise_error
+ end
+ end
+
+ context 'when mixing items with and without request_unit' do
+ let(:item1) { create(:item, :with_unit, name: "Item 1", organization: organization, unit: "pack") }
+ let(:item2) { create(:item, :with_unit, name: "Item 2", organization: organization, unit: "bundle") }
+ let(:requests) do
+ local_requests = [
+ create(:request, :with_item_requests, request_items: [{"item_id" => item1.id, "quantity" => 10, "request_unit" => "pack"}]),
+ create(:request, :with_item_requests, request_items: [{"item_id" => item2.id, "quantity" => 5, "request_unit" => nil}])
+ ]
+ Request.where(id: local_requests.map(&:id))
+ end
+
+ it 'processes mixed request_unit scenarios' do
+ expect { subject }.not_to raise_error
+ expect(subject.size).to be >= 1
+ end
+ end
+
+ context 'when quantity is zero' do
+ let(:item) { create(:item, :with_unit, name: "Zero Item", organization: organization, unit: "piece") }
+ let(:requests) do
+ # Create a valid request first, then manually update to bypass validation
+ request = create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 1, "request_unit" => "piece"}])
+ # Update the quantity to 0 to bypass validation
+ request.item_requests.first.update_column(:quantity, 0)
+ Request.where(id: request.id)
+ end
+
+ it 'includes items with zero quantity' do
+ expect(subject["Zero Item - pieces"]).to eq(0)
+ end
+ end
+
+ context 'when quantity is string' do
+ let(:item) { create(:item, :with_unit, name: "String Qty Item", organization: organization, unit: "box") }
+ let(:requests) do
+ request = create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => "15", "request_unit" => "box"}])
+ Request.where(id: request.id)
+ end
+
+ it 'converts string quantity to integer' do
+ expect(subject["String Qty Item - boxes"]).to eq(15)
+ end
+ end
+
+ context 'when multiple requests have same item' do
+ let(:item) { create(:item, :with_unit, name: "Duplicate Item", organization: organization, unit: "unit") }
+ let(:requests) do
+ local_requests = [
+ create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 10, "request_unit" => "unit"}]),
+ create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 20, "request_unit" => "unit"}]),
+ create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 30, "request_unit" => "unit"}])
+ ]
+ Request.where(id: local_requests.map(&:id))
+ end
+
+ it 'sums quantities correctly' do
+ expect(subject["Duplicate Item - units"]).to eq(60)
end
end
@@ -75,7 +127,7 @@
end
context 'when request item belongs to deleted item' do
- let(:item) { create(:item, :with_unit, name: "Diaper", organization:, unit: "pack") }
+ let(:item) { create(:item, :with_unit, name: "Diaper", organization: organization, unit: "pack") }
let!(:requests) do
request = create(:request, :with_item_requests, request_items: [{"item_id" => item.id, "quantity" => 10, "request_unit" => "pack"}])
Request.where(id: request.id)
@@ -86,7 +138,7 @@
end
it 'returns item with correct quantity calculated' do
- expect(subject).to eq({"Diaper" => 10})
+ expect(subject).to eq({"Diaper - packs" => 10})
end
end
end
diff --git a/spec/system/partners/requests_system_spec.rb b/spec/system/partners/requests_system_spec.rb
index 4238d7c25d..cc9d656729 100644
--- a/spec/system/partners/requests_system_spec.rb
+++ b/spec/system/partners/requests_system_spec.rb
@@ -14,21 +14,8 @@
FactoryBot.create(:item_unit, name: "pack", item: item1)
end
- context "with packs off" do
- before(:each) do
- Flipper.disable(:enable_packs)
- end
-
- it "should not show packs on selection" do
- visit new_partners_request_path
- select "Item 1", from: "request_item_requests_attributes_0_item_id"
- expect(page).not_to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
- end
- end
-
context "with packs on" do
before(:each) do
- Flipper.enable(:enable_packs)
end
it "should require a unit selection" do