diff options
author | lizconlan <liz@mysociety.org> | 2014-11-14 13:08:19 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-11-19 13:41:31 +0000 |
commit | 0ceaec8e0f0ff2ec49b74d49805f3f7b4cd8e953 (patch) | |
tree | 65bb51abd0ceeacc7bc5671d64878ba476f8edb1 /spec/controllers | |
parent | e09f967869bc53751a98bfe2cd88d81feca1423f (diff) |
Fix view bug preventing PublicBodyCategories being deleted in the admin interface
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin_public_body_categories_controller_spec.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/controllers/admin_public_body_categories_controller_spec.rb b/spec/controllers/admin_public_body_categories_controller_spec.rb index 35454990d..e58677a5d 100644 --- a/spec/controllers/admin_public_body_categories_controller_spec.rb +++ b/spec/controllers/admin_public_body_categories_controller_spec.rb @@ -178,15 +178,21 @@ describe AdminPublicBodyCategoriesController do end context 'when destroying a public body category' do - - it "destroys a public body category" do + it "destroys empty public body categories" do pbc = PublicBodyCategory.create(:title => "Empty Category", :category_tag => "empty", :description => "-") n = PublicBodyCategory.count post :destroy, { :id => pbc.id } response.should redirect_to(admin_categories_path) PublicBodyCategory.count.should == n - 1 end - end - + it "destroys non-empty public body categories" do + authority = FactoryGirl.create(:public_body) + pbc = PublicBodyCategory.create(:title => "In-Use Category", :category_tag => "empty", :description => "-", :authorities => [authority]) + n = PublicBodyCategory.count + post :destroy, { :id => pbc.id } + response.should redirect_to(admin_categories_path) + PublicBodyCategory.count.should == n - 1 + end + end end |