Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmohare committed Jun 1, 2024
1 parent 9256452 commit d4510e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rails/app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def process_bulk_create_items
end
items = params[:items]
items.split(",").map{ |x| x.strip }.each do |item_name|
Item.new(name: item_name, collection: @collection, creator: current_user).save
item = Item.new(name: item_name, creator: current_user, collection: @collection)
item.collections << @collection
item.save!
end
render :show
end
Expand Down
2 changes: 1 addition & 1 deletion rails/app/views/collections/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<% end %>
</div>

<% if @items.any? %>
<% if @items && @items.any? %>
<% search_table_headers = ["Item", "Action"].compact %>
<%= render "table", table_headers: search_table_headers do %>
<% @items.each do |item| %>
Expand Down
1 change: 1 addition & 0 deletions rails/test/controllers/collections_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def setup
end

test "should process_bulk_create_items" do
puts "LoggedInUser process_bulk_create_items"
collection = collections(:one)
assert_difference('Item.count', 3) do
post process_bulk_create_items_url(collection), params: { items: 'Item 1, Item 2, Item 3' }
Expand Down

0 comments on commit d4510e4

Please sign in to comment.