aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb12
-rw-r--r--spec/controllers/public_body_controller_spec.rb5
-rw-r--r--spec/fixtures/has_tag_string_tags.yml36
-rw-r--r--spec/spec_helper.rb8
4 files changed, 57 insertions, 4 deletions
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index a2f458025..08d465ca5 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -8,8 +8,14 @@ describe AdminPublicBodyController, "when administering public bodies" do
username = MySociety::Config.get('ADMIN_USERNAME', '')
password = MySociety::Config.get('ADMIN_PASSWORD', '')
basic_auth_login @request
+
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
+ end
it "shows the index page" do
get :index
@@ -78,7 +84,7 @@ describe AdminPublicBodyController, "when administering public bodies and paying
it "disallows non-authenticated users to do anything" do
@request.env["HTTP_AUTHORIZATION"] = ""
- n = PublicBody.count.should
+ n = PublicBody.count
post :destroy, { :id => 3 }
response.code.should == "401"
PublicBody.count.should == n
@@ -113,7 +119,7 @@ describe AdminPublicBodyController, "when administering public bodies and paying
config['ADMIN_USERNAME'] = 'biz'
config['ADMIN_PASSWORD'] = 'fuz'
@request.env["HTTP_AUTHORIZATION"] = ""
- n = PublicBody.count.should
+ n = PublicBody.count
basic_auth_login(@request, "baduser", "badpassword")
post :destroy, { :id => public_bodies(:forlorn_public_body).id }
response.code.should == "401"
@@ -206,11 +212,11 @@ describe AdminPublicBodyController, "when creating public bodies with i18n" do
@old_filters = ActionController::Routing::Routes.filters
ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
end
+
after do
ActionController::Routing::Routes.filters = @old_filters
end
-
it "creates a new public body in one locale" do
n = PublicBody.count
post :create, { :public_body => { :name => "New Quango", :short_name => "", :tag_string => "blah", :request_email => 'newquango@localhost', :last_edit_comment => 'From test code' } }
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 4d27ea3f5..06077ac60 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- coding: undecided -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'json'
@@ -138,13 +139,15 @@ describe PublicBodyController, "when listing bodies" do
end
it "should list a tagged thing on the appropriate list page, and others on the other page, and all still on the all page" do
+ load_test_categories
+
public_bodies(:humpadink_public_body).tag_string = "foo local_council"
get :list, :tag => "local_council"
response.should render_template('list')
assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ]
assigns[:tag].should == "local_council"
- assigns[:description].should == "Local councils"
+ assigns[:description].should == "in the category ‘Local councils’"
get :list, :tag => "other"
response.should render_template('list')
diff --git a/spec/fixtures/has_tag_string_tags.yml b/spec/fixtures/has_tag_string_tags.yml
new file mode 100644
index 000000000..fe3d4fd28
--- /dev/null
+++ b/spec/fixtures/has_tag_string_tags.yml
@@ -0,0 +1,36 @@
+lonely_tag:
+ name: lonely_agency
+ id: "1"
+ created_at: 2007-10-24 10:51:01.161639
+ model: PublicBody
+ model_id: 4
+useless_tag_1:
+ name: useless_agency
+ id: "2"
+ created_at: 2007-10-24 10:51:01.161639
+ model: PublicBody
+ model_id: 3
+useless_tag_2:
+ name: useless_agency
+ id: "3"
+ created_at: 2007-10-24 10:51:01.161639
+ model: PublicBody
+ model_id: 4
+useless_tag_3:
+ name: useless_agency
+ id: "4"
+ created_at: 2007-10-24 10:51:01.161639
+ model: PublicBody
+ model_id: 5
+popular_tag_1:
+ name: popular_agency
+ id: "5"
+ created_at: 2007-10-24 10:51:01.161639
+ model: PublicBody
+ model_id: 2
+popular_tag_2:
+ name: popular_agency
+ id: "6"
+ created_at: 2007-10-24 10:51:01.161639
+ model: PublicBody
+ model_id: 3
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 065d9d080..fbc115c38 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -190,3 +190,11 @@ end
def parse_all_incoming_messages
IncomingMessage.find(:all).each{|x| x.parse_raw_email!}
end
+
+def load_test_categories
+ PublicBodyCategories.add(:en, [
+ "Local and regional",
+ [ "local_council", "Local councils", "a local council" ],
+ "Miscellaneous",
+ [ "other", "Miscellaneous", "miscellaneous" ],])
+end