Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add "Additional Information" Field to Items for Bank Use Only #4643

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def item_params
:on_hand_recommended_quantity,
:distribution_quantity,
:visible_to_partners,
:active
:active,
:additional_info
)
end

Expand Down
4 changes: 4 additions & 0 deletions app/views/items/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<%= 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" %>
<% end %>

<%= f.input :additional_info, label: "Additional Information (Bank Use Only)", wrapper: :input_group do %>
<%= f.text_field :additional_info, class: "form-control" %>
<% end %>
</div>
<!-- /.card-body -->
<div class="card-footer">
Expand Down
1 change: 1 addition & 0 deletions app/views/items/_item_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<tr>
<th>Category</th>
<th>Name</th>
<th>Add. Info</th>
<th>Quantity Per Individual</th>
<th>Fair Market Value (per item)</th>
<% if Flipper.enabled?(:enable_packs) %>
Expand Down
1 change: 1 addition & 0 deletions app/views/items/_item_row.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<tr data-item-id="<%= item_row.id %>">
<td><%= item_row.item_category && link_to(item_row.item_category&.name, item_category_path(item_row.item_category), class: 'text-blue-500') %></td>
<td><%= item_row.name %></td>
<td><%= truncate item_row.additional_info, length: 25 %></td>
<td><%= item_row.distribution_quantity %></td>
<td class="numeric"><%= dollar_value(item_row.value_in_cents) %></td>
<% if Flipper.enabled?(:enable_packs) %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/items/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<th>Item is visible to partners</th>
<td><%= @item.visible_to_partners ? 'Yes' : 'No' %></td>
</tr>
<tr>
<th>Additional Information (Bank Use Only)</th>
<td><%= @item.additional_info %></td>
</tr>
</tbody>
</table>
</div>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20240831173731_add_additional_info_to_items.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAdditionalInfoToItems < ActiveRecord::Migration[7.1]
def change
add_column :items, :additional_info, :text
end
end
15 changes: 14 additions & 1 deletion spec/controllers/items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
expect(subject).to redirect_to(items_path)
expect(item.reload.visible_to_partners).to be true
end

it "updates an item with new additional_info" do
put :update, params: { id: item.id, item: { additional_info: "Updated bank information" } }
expect(item.reload.additional_info).to eq "Updated bank information"
end
end

context "invisible" do
Expand Down Expand Up @@ -135,7 +140,8 @@
partner_key: create(:base_item).partner_key,
value_in_cents: 1001,
package_size: 5,
distribution_quantity: 30
distribution_quantity: 30,
additional_info: "Sensitive bank information"
}
}
end
Expand All @@ -154,6 +160,13 @@
expect(response).not_to have_error
end

it "creates an item with additional_info" do
expect do
post :create, params: item_params
end.to change { Item.count }.by(1)
expect(Item.last.additional_info).to eq "Sensitive bank information"
end

it "should accept request_unit ids and create request_units" do
Flipper.enable(:enable_packs)
unit = create(:unit, organization: organization)
Expand Down
Loading