Discarding changes reloads from DB

But it also clears any search filters. To confirm exactly what behaviour is desired before fixing...
This commit is contained in:
David Cook
2023-09-15 15:38:14 +10:00
parent 8ff67aca41
commit 99ac48a258
2 changed files with 20 additions and 1 deletions

View File

@@ -9,7 +9,7 @@
.error
= error_msg
.form-buttons.six.columns
= form.submit t('.reset'), type: :reset, class: "medium"
= form.submit t('.reset'), type: :reset, class: "medium", 'data-reflex': 'click->products#fetch'
= form.submit t('.save'), class: "medium"
%table.products
%col{ width:"15%" }

View File

@@ -205,6 +205,25 @@ describe 'As an admin, I can see the new product page' do
pending
expect(page).to have_content "Changes saved"
end
it "can discard changes and reload latest data" do
within row_containing_name("Apples") do
fill_in "Name", with: "Pommes"
end
# Meanwhile, the SKU was updated
product_a.update! sku: "APL-10"
expect {
click_button "Discard changes"
product_a.reload
}.to_not change { product_a.name }
within row_containing_name("Apples") do
expect(page).to have_field "Name", with: "Apples" # Changed value wasn't saved
expect(page).to have_field "SKU", with: "APL-10" # Updated value shown
end
end
end
def expect_page_to_be(page_number)