-
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing specs for shipping methods decorator
- Loading branch information
1 parent
1fa93b3
commit b353d7a
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
spec/controllers/spree/admin/shipping_methods_controller_decorator_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::Admin::ShippingMethodsController do | ||
include AuthenticationWorkflow | ||
|
||
describe '#destroy' do | ||
let!(:shipping_method) { create(:shipping_method) } | ||
|
||
before { login_as_admin } | ||
|
||
context 'when the shipping method is in use' do | ||
before { create(:order, shipping_method: shipping_method) } | ||
|
||
it 'does not allow to destroy the shipping method' do | ||
expect { delete :destroy, id: shipping_method.id } | ||
.not_to change(Spree::ShippingMethod, :count) | ||
end | ||
|
||
it 'shows a flash error message' do | ||
spree_delete :destroy, id: shipping_method.id | ||
expect(flash[:error]).to match('That shipping method cannot be deleted') | ||
end | ||
|
||
it 'redirects to the collection url' do | ||
expect(spree_delete(:destroy, id: shipping_method.id)) | ||
.to redirect_to('/admin/shipping_methods') | ||
end | ||
end | ||
|
||
context 'when the shipping method is not in use' do | ||
it 'allows to destroy the shipping method' do | ||
expect { delete :destroy, id: shipping_method.id } | ||
.to change(Spree::ShippingMethod, :count) | ||
end | ||
end | ||
end | ||
end |