Skip to content

Commit d56fbe2

Browse files
committed
Add missing model test
1 parent b1d17f9 commit d56fbe2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

core/spec/models/spree/store_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,24 @@
136136
expect { Spree::Store.new(reverse_charge_status: :invalid_status) }.to raise_error(ArgumentError)
137137
end
138138
end
139+
140+
describe "#validate_not_default" do
141+
context "when deleting a default store" do
142+
it "prevents deletion" do
143+
store = create(:store, default: true)
144+
expect(store.destroy).to eq false
145+
expect(store.errors.full_messages.join).to match /Cannot destroy/
146+
expect { store.reload }.not_to raise_error
147+
end
148+
end
149+
150+
context "when deleting a non-default store" do
151+
it "allows deletion" do
152+
create(:store, default: true)
153+
store = create(:store, default: false)
154+
expect(store.destroy).to be_truthy
155+
expect { store.reload }.to raise_error(ActiveRecord::RecordNotFound)
156+
end
157+
end
158+
end
139159
end

0 commit comments

Comments
 (0)