File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 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
139159end
You can’t perform that action at this time.
0 commit comments