aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-01-30 10:47:13 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-01-30 10:47:13 +0000
commitfd042ca3c96dcb454eddfdc423f68e233b2b3bab (patch)
tree6626d16cb9856fa3d104af86ee6409387883c20e
parent2d3524808fa36a26f85ae85403d58f7114630c3e (diff)
Make better wording at the top of the page listing subsets of public bodies. At the same time, cause the tests not to rely on WDTK data. Fixes #396
-rw-r--r--app/controllers/public_body_controller.rb12
-rw-r--r--lib/public_body_categories.rb7
-rw-r--r--spec/controllers/public_body_controller_spec.rb5
-rw-r--r--spec/spec_helper.rb8
4 files changed, 23 insertions, 9 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 659433c9e..00d1cc1e0 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# app/controllers/public_body_controller.rb:
# Show information about a public body.
#
@@ -117,14 +118,17 @@ class PublicBodyController < ApplicationController
and has_tag_string_tags.model = \'PublicBody\'
and has_tag_string_tags.name = ?) > 0', @query, @query, default_locale, @tag]
end
+
if @tag == "all"
@description = ""
elsif @tag.size == 1
- @description = _("beginning with") + " '" + @tag + "'"
+ @description = _("beginning with ‘{{first_letter}}’", :first_letter=>@tag)
else
- @description = PublicBodyCategories::get().by_tag()[@tag]
- if @description.nil?
- @description = @tag
+ category_name = PublicBodyCategories::get().by_tag()[@tag]
+ if category_name.nil?
+ @description = _("matching the tag ‘{{tag_name}}’", :tag_name=>@tag)
+ else
+ @description = _("in the category ‘{{category_name}}’", :category_name=>category_name)
end
end
PublicBody.with_locale(@locale) do
diff --git a/lib/public_body_categories.rb b/lib/public_body_categories.rb
index 21a021d39..796b1d53d 100644
--- a/lib/public_body_categories.rb
+++ b/lib/public_body_categories.rb
@@ -20,7 +20,7 @@ class PublicBodyCategories
end
def PublicBodyCategories.get
- load_categories() if @@CATEGORIES.nil?
+ load_categories if @@CATEGORIES.empty?
@@CATEGORIES[I18n.locale.to_s] || @@CATEGORIES[I18n.default_locale.to_s] || PublicBodyCategories.new([])
end
@@ -30,10 +30,9 @@ class PublicBodyCategories
end
private
- @@CATEGORIES = nil
+ @@CATEGORIES = {}
def PublicBodyCategories.load_categories()
- @@CATEGORIES = {} if @@CATEGORIES.nil?
I18n.available_locales.each do |locale|
begin
load "public_body_categories_#{locale}.rb"
@@ -41,4 +40,4 @@ class PublicBodyCategories
end
end
end
-end \ No newline at end of file
+end
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/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