aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlizconlan <liz@mysociety.org>2014-08-05 19:40:37 +0100
committerLouise Crow <louise.crow@gmail.com>2014-09-22 12:39:04 +0100
commitf9977d2d38ad6ddb1d6c897ebc4b9c9c0355dc89 (patch)
treee6b6689e5f50e7344a01022dba3107ccf774381c
parent7df6456d69d71e6dba34fbc0d7b3d262d2dc0d38 (diff)
Allow deletion of public body categories with associatied bodies
-rw-r--r--app/controllers/admin_public_body_category_controller.rb7
-rw-r--r--spec/controllers/admin_public_body_category_controller_spec.rb10
2 files changed, 1 insertions, 16 deletions
diff --git a/app/controllers/admin_public_body_category_controller.rb b/app/controllers/admin_public_body_category_controller.rb
index f814763ad..e22c5c572 100644
--- a/app/controllers/admin_public_body_category_controller.rb
+++ b/app/controllers/admin_public_body_category_controller.rb
@@ -71,13 +71,6 @@ class AdminPublicBodyCategoryController < AdminController
@locale = self.locale_from_params
I18n.with_locale(@locale) do
category = PublicBodyCategory.find(params[:id])
-
- if PublicBody.find_by_tag(category.category_tag).count > 0
- flash[:notice] = "There are authorities associated with this category, so can't destroy it"
- redirect_to admin_category_edit_url(category)
- return
- end
-
category.destroy
flash[:notice] = "Category was successfully destroyed."
redirect_to admin_category_index_url
diff --git a/spec/controllers/admin_public_body_category_controller_spec.rb b/spec/controllers/admin_public_body_category_controller_spec.rb
index d13ebcaaf..a5518e13c 100644
--- a/spec/controllers/admin_public_body_category_controller_spec.rb
+++ b/spec/controllers/admin_public_body_category_controller_spec.rb
@@ -156,15 +156,7 @@ describe AdminPublicBodyCategoryController do
PublicBodyCategory.load_categories
end
- it "does not destroy a public body category that has associated bodies" do
- category = PublicBodyCategory.find_by_title("Useless ministries")
- n = PublicBodyCategory.count
- post :destroy, { :id => category.id }
- response.should redirect_to(:controller=>'admin_public_body_category', :action=>'edit', :id => category.id)
- PublicBodyCategory.count.should == n
- end
-
- it "destroys an empty public body category" do
+ it "destroys a public body category" do
pbc = PublicBodyCategory.create(:title => "Empty Category", :category_tag => "empty", :description => "-")
n = PublicBodyCategory.count
post :destroy, { :id => pbc.id }