Skip to content

Commit

Permalink
Fix property destroy - use destroy instead of discard
Browse files Browse the repository at this point in the history
(cherry picked from commit 29d6a81)
  • Loading branch information
tonxyx committed Jan 2, 2024
1 parent 4daeeff commit 2b40441
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 2b40441

Please sign in to comment.