diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb
index 6be2f18aa6..4da100b153 100644
--- a/app/controllers/items_controller.rb
+++ b/app/controllers/items_controller.rb
@@ -31,11 +31,7 @@ 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:)
result = create.call
if result.success?
@@ -81,7 +77,7 @@ def update
return
end
- if update_item
+ if update_item_and_request_units
redirect_to items_path, notice: "#{@item.name} updated!"
else
flash.now[:error] = "Something didn't work quite right -- try again? #{@item.errors.map { |error| "#{error.attribute}: #{error.message}" }}"
@@ -185,15 +181,6 @@ def request_unit_ids
params.require(:item).permit(request_unit_ids: []).fetch(:request_unit_ids, [])
end
- # 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
- end
-
def update_item_and_request_units
begin
Item.transaction do
diff --git a/app/controllers/partners/requests_controller.rb b/app/controllers/partners/requests_controller.rb
index 7ea1c94b82..ccb16245ec 100644
--- a/app/controllers/partners/requests_controller.rb
+++ b/app/controllers/partners/requests_controller.rb
@@ -81,13 +81,12 @@ 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
+
+ # 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
end
end
diff --git a/app/models/partners/item_request.rb b/app/models/partners/item_request.rb
index e472497c48..12b4666d3a 100644
--- a/app/models/partners/item_request.rb
+++ b/app/models/partners/item_request.rb
@@ -41,7 +41,7 @@ def item_name
end
def quantity_with_units
- if Flipper.enabled?(:enable_packs) && request_unit.present?
+ if request_unit.present?
"#{quantity} #{request_unit.pluralize(quantity.to_i)}"
else
quantity
@@ -49,7 +49,7 @@ def quantity_with_units
end
def name_with_unit(quantity_override = nil)
- if Flipper.enabled?(:enable_packs) && request_unit.present?
+ if request_unit.present?
"#{item_name} - #{request_unit.pluralize(quantity_override || quantity.to_i)}"
else
item_name
diff --git a/app/models/view/request_info.rb b/app/models/view/request_info.rb
index 301eb54261..32e5edfe26 100644
--- a/app/models/view/request_info.rb
+++ b/app/models/view/request_info.rb
@@ -27,7 +27,7 @@ def location
end
def custom_units
- Flipper.enabled?(:enable_packs) && request.item_requests.any? { |item| item.request_unit }
+ request.item_requests.any? { |item| item.request_unit }
end
def cancellable?
diff --git a/app/pdfs/distribution_pdf.rb b/app/pdfs/distribution_pdf.rb
index 0ac2181263..7f201aad26 100644
--- a/app/pdfs/distribution_pdf.rb
+++ b/app/pdfs/distribution_pdf.rb
@@ -288,7 +288,7 @@ def signature_lines_for(label)
end
def request_display_qty(item_request)
- if Flipper.enabled?(:enable_packs) && item_request&.request_unit
+ if item_request&.request_unit
"#{item_request.quantity} #{item_request.request_unit.pluralize(item_request.quantity.to_i)}"
else
item_request&.quantity || ""
diff --git a/app/pdfs/picklists_pdf.rb b/app/pdfs/picklists_pdf.rb
index 8d91d69d2b..d751e30dc0 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 bedcba4227..4aacf08941 100644
--- a/app/services/exports/export_request_service.rb
+++ b/app/services/exports/export_request_service.rb
@@ -73,16 +73,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
diff --git a/app/services/item_create_service.rb b/app/services/item_create_service.rb
index 01159d33e4..4cfe39a812 100644
--- a/app/services/item_create_service.rb
+++ b/app/services/item_create_service.rb
@@ -8,9 +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
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 ee5cf0e8d6..32bf9e1f7f 100644
--- a/app/views/items/_form.html.erb
+++ b/app/views/items/_form.html.erb
@@ -44,7 +44,7 @@
<%= f.input_field :package_size, class: "form-control", min: 0 %>
<% end %>
- <% if Flipper.enabled?(:enable_packs) && current_organization.request_units.present? %>
+ <% if current_organization.request_units.present? %>
<%= 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 %>
diff --git a/app/views/items/_item_list.html.erb b/app/views/items/_item_list.html.erb
index 29a2fb1429..c4ab2e5710 100644
--- a/app/views/items/_item_list.html.erb
+++ b/app/views/items/_item_list.html.erb
@@ -12,10 +12,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 6b0c377347..70e7eb69b6 100644
--- a/app/views/items/_item_row.html.erb
+++ b/app/views/items/_item_row.html.erb
@@ -5,10 +5,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.blank? %>
- <%= item_row.request_units.pluck(:name).join(', ') %> |
- <% end %>
+ <% unless current_organization.request_units.blank? %>
+ <%= 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 ac9f4d99ab..b4af9aef32 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 c406f604d6..bf6ba21d48 100644
--- a/app/views/organizations/_details.html.erb
+++ b/app/views/organizations/_details.html.erb
@@ -154,24 +154,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 b3618e4e34..3187584045 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/db/seeds.rb b/db/seeds.rb
index be325f1d2c..6fff0e3802 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1111,8 +1111,6 @@ def seed_quantity(item_name, organization, storage_location, quantity)
Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: "new_logo")
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/docs/user_guide/bank/exports.md b/docs/user_guide/bank/exports.md
index 2d3ccde6dd..b5ffa305c6 100644
--- a/docs/user_guide/bank/exports.md
+++ b/docs/user_guide/bank/exports.md
@@ -415,8 +415,7 @@ For each filtered Request,
- Date,
- Requestor (i.e. partner)
- Status, and
-- the quantity of each Item requested.
- - Note: If you have packs enabled (upcoming feature), there will be a column for each unit that you have enabled for each Item. Otherwise, one column per Item.
+- the quantity of each Item requested. There will be a column for each unit that you have enabled for each Item.
## Storage Locations
### Navigating to export Storage Locations
diff --git a/spec/controllers/items_controller_spec.rb b/spec/controllers/items_controller_spec.rb
index 489643bf7f..3f765c8ef3 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 d0afdc3568..8f0bb5f2bc 100644
--- a/spec/mailers/requests_confirmation_mailer_spec.rb
+++ b/spec/mailers/requests_confirmation_mailer_spec.rb
@@ -61,7 +61,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")
@@ -77,7 +76,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, :with_item_requests, request_items: [{item_id: item.id, quantity: 7}])
diff --git a/spec/models/view/request_info_spec.rb b/spec/models/view/request_info_spec.rb
index 0dabbbd87f..93b871146e 100644
--- a/spec/models/view/request_info_spec.rb
+++ b/spec/models/view/request_info_spec.rb
@@ -105,47 +105,21 @@
describe "#custom_units" do
context "when there are request units for an item request" do
- context "when enable_packs is disabled" do
- it "returns false" do
- organization = build(:organization)
- item = build(:item, name: "First item")
- create(:item_unit, item: item, name: "flat")
- request = create(
- :request,
- :with_item_requests,
- organization:,
- request_items: [
- {item_id: item.id, quantity: "559", request_unit: "flat"}
- ]
- )
-
- request_info = View::RequestInfo.new(params: {id: request.id}, organization:)
-
- expect(request_info.custom_units).to be_falsey
- end
- end
+ it "returns true" do
+ organization = build(:organization)
+ item = build(:item, name: "First item")
+ create(:item_unit, item: item, name: "flat")
+ request = create(
+ :request,
+ :with_item_requests,
+ organization:,
+ request_items: [
+ {item_id: item.id, quantity: "559", request_unit: "flat"}
+ ]
+ )
+ request_info = View::RequestInfo.new(params: {id: request.id}, organization:)
- context "when enable_packs is enabled" do
- it "returns true" do
- Flipper.enable(:enable_packs)
-
- organization = build(:organization)
- item = build(:item, name: "First item")
- create(:item_unit, item: item, name: "flat")
- request = create(
- :request,
- :with_item_requests,
- organization:,
- request_items: [
- {item_id: item.id, quantity: "559", request_unit: "flat"}
- ]
- )
- request_info = View::RequestInfo.new(params: {id: request.id}, organization:)
-
- expect(request_info.custom_units).to be_truthy
-
- Flipper.disable(:enable_packs)
- end
+ expect(request_info.custom_units).to be_truthy
end
end
end
diff --git a/spec/pdfs/distribution_pdf_spec.rb b/spec/pdfs/distribution_pdf_spec.rb
index 24dba9f6e2..736470f41b 100644
--- a/spec/pdfs/distribution_pdf_spec.rb
+++ b/spec/pdfs/distribution_pdf_spec.rb
@@ -21,8 +21,7 @@
PDFComparisonTestFactory.create_line_items_request(distribution: distribution, partner: partner, storage_creation: storage_creation)
end
- specify "#request_data with custom units feature" do
- Flipper.enable(:enable_packs)
+ specify "#request_data" do
results = described_class.new(organization, distribution).request_data
expect(results).to eq([
["Items Received", "Requested", "Received", "Value/item", "In-Kind Value Received", "Packages"],
@@ -138,7 +137,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
@@ -147,11 +145,6 @@ def compare_pdf(distribution, expected_file_path)
end
end
- # 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) }
let(:file_paths) { PDFComparisonTestFactory.get_file_paths }
let(:expected_different_address_file_path) { file_paths.expected_different_address_file_path }
diff --git a/spec/pdfs/picklists_pdf_spec.rb b/spec/pdfs/picklists_pdf_spec.rb
index b79d4c1925..4a5847f1b5 100644
--- a/spec/pdfs/picklists_pdf_spec.rb
+++ b/spec/pdfs/picklists_pdf_spec.rb
@@ -108,40 +108,20 @@
end
end
- context "When packs are not enabled" do
- specify "#data_no_units" do
- request = create(:request, :pending, organization: organization)
- create(:item_request, request: request, item: item1, name: "Item 1", quantity: 5)
- create(:item_request, request: request, item: item2, name: "Item 2", quantity: 10)
- pdf = described_class.new(organization, [request])
- data = pdf.data_no_units(request.item_requests)
-
- expect(data).to eq([
- ["Items Requested", "Quantity", "[X]", "Differences / Comments"],
- ["Item 1", "5", "[ ]", ""],
- ["Item 2", "10", "[ ]", ""]
- ])
- end
- 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")
- request = create(:request, :pending, organization: organization)
- create(:item_request, request: request, item: item_with_units, name: "Item with units", request_unit: "Pack", quantity: 5)
- create(:item_request, request: request, item: item2, name: "Item 2", quantity: 10)
- pdf = described_class.new(organization, [request])
- data = pdf.data_with_units(request.item_requests)
-
- expect(data).to eq([
- ["Items Requested", "Quantity", "Unit (if applicable)", "[X]", "Differences / Comments"],
- ["Item with units", "5", "Packs", "[ ]", ""],
- ["Item 2", "10", nil, "[ ]", ""]
- ])
- end
+ 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")
+ request = create(:request, :pending, organization: organization)
+ create(:item_request, request: request, item: item_with_units, name: "Item with units", request_unit: "Pack", quantity: 5)
+ create(:item_request, request: request, item: item2, name: "Item 2", quantity: 10)
+ pdf = described_class.new(organization, [request])
+ data = pdf.data_with_units(request.item_requests)
+
+ expect(data).to eq([
+ ["Items Requested", "Quantity", "Unit (if applicable)", "[X]", "Differences / Comments"],
+ ["Item with units", "5", "Packs", "[ ]", ""],
+ ["Item 2", "10", nil, "[ ]", ""]
+ ])
end
describe "picklist pdf output" do
@@ -150,7 +130,6 @@ def compare_picklist_pdf(requests, 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
@@ -159,11 +138,6 @@ def compare_picklist_pdf(requests, expected_file_path)
end
end
- # 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(:storage_creation) { PDFComparisonTestFactory.create_organization_storage_items }
let(:organization) { storage_creation.organization }
let(:partner) { PDFComparisonTestFactory.create_partner_with_quota(organization) }
diff --git a/spec/requests/distributions_requests_spec.rb b/spec/requests/distributions_requests_spec.rb
index 39c58c4b1f..8ef8d99a6d 100644
--- a/spec/requests/distributions_requests_spec.rb
+++ b/spec/requests/distributions_requests_spec.rb
@@ -452,10 +452,6 @@
end
context 'with units' do
- before(:each) do
- Flipper.enable(:enable_packs)
- end
-
it 'should behave correctly' do
get new_distribution_path(default_params)
expect(response).to be_successful
@@ -907,7 +903,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 ddd1a1574c..c785cb5023 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)
@@ -319,8 +317,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")
@@ -365,14 +361,13 @@
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).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)
+ it 'shows custom request units' do
get item_path(id: item.id)
expect(response.body).to include('Custom Units')
diff --git a/spec/requests/organization_requests_spec.rb b/spec/requests/organization_requests_spec.rb
index 1c31a53f1e..70cc04d0c1 100644
--- a/spec/requests/organization_requests_spec.rb
+++ b/spec/requests/organization_requests_spec.rb
@@ -139,20 +139,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
context "with a reminder schedule" do
@@ -231,20 +220,9 @@
expect(html.text).to include("Include packages in distribution export:")
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
@@ -278,6 +256,7 @@
it { is_expected.to render_template(:edit) }
it { expect(response).to be_successful }
+
it 'initializing the given organization' do
expect(assigns(:organization)).to be_a(Organization) &
have_attributes(
@@ -287,22 +266,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 "displays 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 c81a98c127..49faf1bf97 100644
--- a/spec/requests/partners/requests_spec.rb
+++ b/spec/requests/partners/requests_spec.rb
@@ -51,14 +51,9 @@
expect(response).to render_template(:new)
end
- context "when packs are enabled but there are no requestable items" do
+ context "when 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,17 +176,10 @@
]
)
- 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)
- expect(response.body).to match(/Third item - 1/m)
end
end
@@ -290,7 +278,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 +306,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 af085e1e91..3352b70908 100644
--- a/spec/requests/requests_requests_spec.rb
+++ b/spec/requests/requests_requests_spec.rb
@@ -153,40 +153,28 @@
end
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) }
-
- it 'shows a units column and custom unit if any item has custom units' do
- create(:item_unit, item: item, name: "Pack")
- create(:item_request, request: request, request_unit: "Pack", item: item)
-
- get request_path(request)
-
- expect(response.body).to include('Units (if applicable)')
- expect(response.body).to include('Packs | ')
- end
+ it 'shows a units column and custom unit if any item has custom units' do
+ item = create(:item, name: "Item", organization: organization)
+ request = create(:request, organization: organization)
+ create(:item_unit, item: item, name: "Pack")
+ create(:item_request, request: request, request_unit: "Pack", item: item)
- it 'does not show a units column or any unit if no items have custom units' do
- create(:item_unit, item: item, name: "Pack")
- create(:item_request, request: request, request_unit: nil, item: item)
+ get request_path(request)
- get request_path(request)
-
- expect(response.body).to_not include('Units (if applicable)')
- expect(response.body).to_not include('Packs | ')
- end
+ expect(response.body).to include('Units (if applicable)')
+ expect(response.body).to include('Packs | ')
end
- context 'When packs are not enabled' do
- let(:request) { create(:request, organization: organization) }
+ it 'does not show a units column or any unit if no items have custom units' do
+ item = create(:item, name: "Item", organization: organization)
+ request = create(:request, organization: organization)
+ create(:item_unit, item: item, name: "Pack")
+ create(:item_request, request: request, request_unit: nil, item: item)
- it 'does not show a units column' do
- get request_path(request)
+ get request_path(request)
- expect(response.body).not_to include('Units (if applicable)')
- end
+ expect(response.body).to_not include('Units (if applicable)')
+ expect(response.body).to_not include('Packs | ')
end
context 'when the request has a Fulfilled status' do
diff --git a/spec/services/exports/export_request_service_spec.rb b/spec/services/exports/export_request_service_spec.rb
index 9ee35c7552..868a3b0278 100644
--- a/spec/services/exports/export_request_service_spec.rb
+++ b/spec/services/exports/export_request_service_spec.rb
@@ -112,306 +112,162 @@
described_class.new(Request.all, org).generate_csv_data
end
- context "with custom units feature enabled" do
- before do
- Flipper.enable(:enable_packs)
+ describe ".generate_csv_data" do
+ it "includes headers as the first row with ordered item names alphabetically with deleted item included at the end" do
+ expect(subject.first).to eq([
+ "Date",
+ "Requestor",
+ "Type",
+ "Status",
+ "2T Diapers -- UPDATED",
+ "3T Diapers",
+ "4T Diapers",
+ "4T Diapers - packs",
+ "apple",
+ "Banana",
+ "Inactive Item",
+ "Unrequested Item",
+ "Zebra",
+ ""
+ ])
end
- describe ".generate_csv_data" do
- it "includes headers as the first row with ordered item names alphabetically with deleted item included at the end" do
- expect(subject.first).to eq([
- "Date",
- "Requestor",
- "Type",
- "Status",
- "2T Diapers -- UPDATED",
- "3T Diapers",
- "4T Diapers",
- "4T Diapers - packs",
- "apple",
- "Banana",
- "Inactive Item",
- "Unrequested Item",
- "Zebra",
- ""
- ])
- end
-
- it "includes rows for each request" do
- expect(subject.count).to eq(8)
- end
-
- it "has expected data for the 3T Diapers request" do
- expect(subject).to include([
- request_3t.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Child",
- "Started",
- 0, # 2T Diapers
- 150, # 3T Diapers
- 0, # 4T Diapers
- 0, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
-
- it "has expected data for the 2T Diapers request" do
- expect(subject).to include([
- request_2t.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Individual",
- "Fulfilled",
- 100, # 2T Diapers
- 0, # 3T Diapers
- 0, # 4T Diapers
- 0, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
-
- it "has expected data for the request with deleted items" do
- expect(subject).to include([
- request_with_deleted_items.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- nil,
- "Fulfilled",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 0, # 4T Diapers
- 0, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 400 #
- ])
- end
-
- it "has expected data for the request with multiple items" do
- expect(subject).to include([
- request_with_multiple_items.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- nil,
- "Started",
- 3, # 2T Diapers
- 2, # 3T Diapers
- 0, # 4T Diapers
- 4, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
-
- it "has expected data for the request with 4T diapers without pack unit" do
- expect(subject).to include([
- request_4t.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Quantity",
- "Started",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 77, # 4T Diapers
- 0, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
-
- it "has expected data for the request with 4T diapers with pack unit" do
- expect(subject).to include([
- request_4t_pack.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Quantity",
- "Started",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 0, # 4T Diapers
- 1, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
-
- it "has expected data even when the unit was deleted" do
- item_4t.request_units.destroy_all
- expect(subject).to include([
- request_4t_pack.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Quantity",
- "Started",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 0, # 4T Diapers
- 1, # 4T Diapers - packs
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
+ it "includes rows for each request" do
+ expect(subject.count).to eq(8)
end
- end
- context "with custom units feature disabled" do
- before do
- Flipper.disable(:enable_packs)
+ it "has expected data for the 3T Diapers request" do
+ expect(subject).to include([
+ request_3t.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ "Child",
+ "Started",
+ 0, # 2T Diapers
+ 150, # 3T Diapers
+ 0, # 4T Diapers
+ 0, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 0 #
+ ])
end
- describe ".generate_csv_data" do
- it "includes headers as the first row with ordered item names alphabetically with deleted item included at the end" do
- expect(subject.first).to eq([
- "Date",
- "Requestor",
- "Type",
- "Status",
- "2T Diapers -- UPDATED",
- "3T Diapers",
- "4T Diapers",
- "apple",
- "Banana",
- "Inactive Item",
- "Unrequested Item",
- "Zebra",
- ""
- ])
- end
-
- it "includes rows for each request" do
- expect(subject.count).to eq(8)
- end
-
- it "has expected data for the 3T Diapers request" do
- expect(subject).to include([
- request_3t.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Child",
- request_3t.status.humanize,
- 0, # 2T Diapers
- 150, # 3T Diapers
- 0, # 4T Diapers
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
+ it "has expected data for the 2T Diapers request" do
+ expect(subject).to include([
+ request_2t.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ "Individual",
+ "Fulfilled",
+ 100, # 2T Diapers
+ 0, # 3T Diapers
+ 0, # 4T Diapers
+ 0, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 0 #
+ ])
+ end
- it "has expected data for the 2T Diapers request" do
- expect(subject).to include([
- request_2t.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Individual",
- "Fulfilled",
- 100, # 2T Diapers
- 0, # 3T Diapers
- 0, # 4T Diapers
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
+ it "has expected data for the request with deleted items" do
+ expect(subject).to include([
+ request_with_deleted_items.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ nil,
+ "Fulfilled",
+ 0, # 2T Diapers
+ 0, # 3T Diapers
+ 0, # 4T Diapers
+ 0, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 400 #
+ ])
+ end
- it "has expected data for the request with deleted items" do
- expect(subject).to include([
- request_with_deleted_items.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- nil,
- "Fulfilled",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 0, # 4T Diapers
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 400 #
- ])
- end
+ it "has expected data for the request with multiple items" do
+ expect(subject).to include([
+ request_with_multiple_items.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ nil,
+ "Started",
+ 3, # 2T Diapers
+ 2, # 3T Diapers
+ 0, # 4T Diapers
+ 4, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 0 #
+ ])
+ end
- it "has expected data for the request with multiple items" do
- expect(subject).to include([
- request_with_multiple_items.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- nil,
- "Started",
- 3, # 2T Diapers
- 2, # 3T Diapers
- 4, # 4T Diapers
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
+ it "has expected data for the request with 4T diapers without pack unit" do
+ expect(subject).to include([
+ request_4t.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ "Quantity",
+ "Started",
+ 0, # 2T Diapers
+ 0, # 3T Diapers
+ 77, # 4T Diapers
+ 0, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 0 #
+ ])
+ end
- it "has expected data for the request with 4T diapers without pack unit" do
- expect(subject).to include([
- request_4t.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Quantity",
- "Started",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 77, # 4T Diapers
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
+ it "has expected data for the request with 4T diapers with pack unit" do
+ expect(subject).to include([
+ request_4t_pack.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ "Quantity",
+ "Started",
+ 0, # 2T Diapers
+ 0, # 3T Diapers
+ 0, # 4T Diapers
+ 1, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 0 #
+ ])
+ end
- it "has expected data for the request with 4T diapers with pack unit" do
- expect(subject).to include([
- request_4t_pack.created_at.strftime("%m/%d/%Y").to_s,
- "Howdy Partner",
- "Quantity",
- "Started",
- 0, # 2T Diapers
- 0, # 3T Diapers
- 1, # 4T Diapers
- 0, # apple
- 0, # Banana
- 0, # Inactive Item
- 0, # Unrequested Item
- 0, # Zebra
- 0 #
- ])
- end
+ it "has expected data even when the unit was deleted" do
+ item_4t.request_units.destroy_all
+ expect(subject).to include([
+ request_4t_pack.created_at.strftime("%m/%d/%Y").to_s,
+ "Howdy Partner",
+ "Quantity",
+ "Started",
+ 0, # 2T Diapers
+ 0, # 3T Diapers
+ 0, # 4T Diapers
+ 1, # 4T Diapers - packs
+ 0, # apple
+ 0, # Banana
+ 0, # Inactive Item
+ 0, # Unrequested Item
+ 0, # Zebra
+ 0 #
+ ])
end
end
end
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..2ddacf11ca 100644
--- a/spec/services/requests_total_items_service_spec.rb
+++ b/spec/services/requests_total_items_service_spec.rb
@@ -33,11 +33,7 @@
])
end
- context 'when custom request units are specified and enabled' do
- before do
- Flipper.enable(:enable_packs)
- end
-
+ context 'when custom request units are specified' do
it 'returns the names of items correctly' do
expect(subject.keys).to eq([
"item_name_0",
diff --git a/spec/system/partners/requests_system_spec.rb b/spec/system/partners/requests_system_spec.rb
index 4238d7c25d..1d3104b728 100644
--- a/spec/system/partners/requests_system_spec.rb
+++ b/spec/system/partners/requests_system_spec.rb
@@ -14,73 +14,55 @@
FactoryBot.create(:item_unit, name: "pack", item: item1)
end
- context "with packs off" do
- before(:each) do
- Flipper.disable(:enable_packs)
- end
+ it "should require a unit selection" do
+ visit new_partners_request_path
+ expect(Request.count).to eq(0)
+ expect(page).not_to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
+ select "Item 1", from: "request_item_requests_attributes_0_item_id"
+ expect(page).to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
+ expect(page).to have_select("request_item_requests_attributes_0_request_unit",
+ selected: "Please select a unit",
+ options: ["Please select a unit", "units", "packs"])
+ fill_in "request_item_requests_attributes_0_quantity", with: 50
+ click_on "Submit Essentials Request"
- 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
+ expect(page).to have_text "Please ensure a single unit is selected for each item that supports it."
+ expect(Request.count).to eq(0)
end
- context "with packs on" do
- before(:each) do
- Flipper.enable(:enable_packs)
- end
+ it "shows packs on selection" do
+ visit new_partners_request_path
+ expect(Request.count).to eq(0)
+ expect(page).not_to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
+ select "Item 1", from: "request_item_requests_attributes_0_item_id"
+ expect(page).to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
+ expect(page).to have_select("request_item_requests_attributes_0_request_unit",
+ selected: "Please select a unit",
+ options: ["Please select a unit", "units", "packs"])
+ select "packs", from: "request_item_requests_attributes_0_request_unit"
+ click_on "Add Another Item"
- it "should require a unit selection" do
- visit new_partners_request_path
- expect(Request.count).to eq(0)
- expect(page).not_to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
- select "Item 1", from: "request_item_requests_attributes_0_item_id"
- expect(page).to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
- expect(page).to have_select("request_item_requests_attributes_0_request_unit",
- selected: "Please select a unit",
- options: ["Please select a unit", "units", "packs"])
- fill_in "request_item_requests_attributes_0_quantity", with: 50
- click_on "Submit Essentials Request"
+ # get selector to use in subsequent steps
+ new_item = find_all(:css, "select[data-item-units-target=itemSelect]")[1]
+ id = new_item[:id].match(/\d+/)[0]
- expect(page).to have_text "Please ensure a single unit is selected for each item that supports it."
- expect(Request.count).to eq(0)
- end
+ expect(page).not_to have_selector("request_item_requests_attributes_#{id}_request_unit", visible: true)
+ select "Item 2", from: "request_item_requests_attributes_#{id}_item_id"
+ expect(page).not_to have_selector("request_item_requests_attributes_#{id}_request_unit", visible: true)
+ fill_in "request_item_requests_attributes_0_quantity", with: 50
+ fill_in "request_item_requests_attributes_#{id}_quantity", with: 20
+ click_on "Submit Essentials Request"
+ click_on "Yes, it's correct"
+ expect(page).to have_text "Request has been successfully created"
- it "should show packs on selection" do
- visit new_partners_request_path
- expect(Request.count).to eq(0)
- expect(page).not_to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
- select "Item 1", from: "request_item_requests_attributes_0_item_id"
- expect(page).to have_selector("#request_item_requests_attributes_0_request_unit", visible: true)
- expect(page).to have_select("request_item_requests_attributes_0_request_unit",
- selected: "Please select a unit",
- options: ["Please select a unit", "units", "packs"])
- select "packs", from: "request_item_requests_attributes_0_request_unit"
- click_on "Add Another Item"
-
- # get selector to use in subsequent steps
- new_item = find_all(:css, "select[data-item-units-target=itemSelect]")[1]
- id = new_item[:id].match(/\d+/)[0]
-
- expect(page).not_to have_selector("request_item_requests_attributes_#{id}_request_unit", visible: true)
- select "Item 2", from: "request_item_requests_attributes_#{id}_item_id"
- expect(page).not_to have_selector("request_item_requests_attributes_#{id}_request_unit", visible: true)
- fill_in "request_item_requests_attributes_0_quantity", with: 50
- fill_in "request_item_requests_attributes_#{id}_quantity", with: 20
- click_on "Submit Essentials Request"
- click_on "Yes, it's correct"
- expect(page).to have_text "Request has been successfully created"
-
- expect(Request.count).to eq(1)
- request = Request.last
- expect(request.item_requests[0].quantity).to eq("50")
- expect(request.item_requests[0].item_id).to eq(item1.id)
- expect(request.item_requests[0].request_unit).to eq("pack")
- expect(request.item_requests[1].quantity).to eq("20")
- expect(request.item_requests[1].item_id).to eq(item2.id)
- expect(request.item_requests[1].request_unit).to eq(nil)
- end
+ expect(Request.count).to eq(1)
+ request = Request.last
+ expect(request.item_requests[0].quantity).to eq("50")
+ expect(request.item_requests[0].item_id).to eq(item1.id)
+ expect(request.item_requests[0].request_unit).to eq("pack")
+ expect(request.item_requests[1].quantity).to eq("20")
+ expect(request.item_requests[1].item_id).to eq(item2.id)
+ expect(request.item_requests[1].request_unit).to eq(nil)
end
end
end