Skip to content

Commit

Permalink
Fix property destroy - use destroy instead of discard
Browse files Browse the repository at this point in the history
  • Loading branch information
tonxyx committed Dec 29, 2023
1 parent 2c82985 commit 29d6a81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def destroy
@properties = Spree::Property.where(id: params[:id])

Spree::Property.transaction do
@properties.discard_all
@properties.destroy_all
end

flash[:notice] = t('.success')
Expand Down
8 changes: 4 additions & 4 deletions admin/spec/features/properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
before { sign_in create(:admin_user, email: '[email protected]') }

it "lists properties and allows deleting them" do
create(:property, name: "Type", presentation: "Type")
create(:property, name: "Type prop", presentation: "Type prop")
create(:property, name: "Size", presentation: "Size")

visit "/admin/properties"
expect(page).to have_content("Type")
expect(page).to have_content("Type prop")
expect(page).to have_content("Size")

expect(page).to be_axe_clean

select_row("Type")
select_row("Type prop")
click_on "Delete"
expect(page).to have_content("Properties were successfully removed.")
expect(page).not_to have_content("Type")
expect(page).not_to have_content("Type prop")
expect(Spree::Property.count).to eq(1)
end
end

0 comments on commit 29d6a81

Please sign in to comment.