Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Added test to ensure new barcode item was saved
Browse files Browse the repository at this point in the history
  • Loading branch information
madisonlemmond committed Mar 19, 2019
2 parents 22ab344 + 39b8942 commit cc1af53
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spec/features/purchase_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,31 @@

expect(page).to have_field "purchase_line_items_attributes_0_quantity", with: (@existing_barcode.quantity * 2).to_s
end

scenario "a user can add items that do not yet have a barcode" do
# enter a new barcode
within "#purchase_line_items" do
expect(page).to have_xpath("//input[@id='_barcode-lookup-0']")
<<<<<<< HEAD
fill_in "_barcode-lookup-0", with: "123456\n"
=======
fill_in "_barcode-lookup-0", with: "0\n"
>>>>>>> 39b8942babda35e7f2a502a438ff2dd632a29623
end
# form finds no barcode and responds by prompting user to choose an item and quantity
expect(page).to have_css("#newBarcode")
within "#new_barcode_item" do
<<<<<<< HEAD
expect(page).to have_xpath("//input[@id='barcode_item_value']")
expect(page).to have_xpath("//input[@id='barcode_item_quantity']")
expect(page).to have_xpath("//select[@id='barcode_item_barcodeable_id']")
# fill that in
fill_in "barcode_item_value", with: "123456"
=======
expect(page).to have_xpath("//input[@id='barcode_item_quantity']")
expect(page).to have_xpath("//select[@id='barcode_item_barcodeable_id']")
expect(page).to have_field "barcode_item_value", with: "0"
# fill that in
>>>>>>> 39b8942babda35e7f2a502a438ff2dd632a29623
fill_in "barcode_item_quantity", with: "10"
select Item.alphabetized.first.name, from: "barcode_item_barcodeable_id"
end
Expand All @@ -166,8 +176,11 @@
end
# form updates
expect(page).to have_xpath("//input[@id='_barcode-lookup-new_line_items']")
<<<<<<< HEAD
expect(BarcodeItem.last.value).to eq("123456")
expect(BarcodeItem.last.quantity).to eq(10)
=======
>>>>>>> 39b8942babda35e7f2a502a438ff2dd632a29623
end
end
end
Expand Down

0 comments on commit cc1af53

Please sign in to comment.