diff options
-rw-r--r-- | app/helpers/public_body_helper.rb | 18 | ||||
-rw-r--r-- | spec/views/public_body/show.html.erb_spec.rb | 1 |
2 files changed, 11 insertions, 8 deletions
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb index 54aa82d3a..e871ea1bc 100644 --- a/app/helpers/public_body_helper.rb +++ b/app/helpers/public_body_helper.rb @@ -40,15 +40,17 @@ module PublicBodyHelper # Returns a String def type_of_authority(public_body) first = true - types = public_body.tags.each.map do |tag| - if PublicBodyCategory.get.by_tag.include?(tag.name) - desc = PublicBodyCategory.get.singular_by_tag[tag.name] - if first - desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } - first = false - end - link_to(desc, list_public_bodies_path(tag.name)) + + categories = PublicBodyCategory. + where(:category_tag => public_body.tag_string.split) + + types = categories.map do |category| + desc = category.description + if first + desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } + first = false end + link_to(desc, list_public_bodies_path(category.category_tag)) end types.compact! diff --git a/spec/views/public_body/show.html.erb_spec.rb b/spec/views/public_body/show.html.erb_spec.rb index a4edcfc22..c20d8483c 100644 --- a/spec/views/public_body/show.html.erb_spec.rb +++ b/spec/views/public_body/show.html.erb_spec.rb @@ -18,6 +18,7 @@ describe "public_body/show" do @pb.stub!(:special_not_requestable_reason?).and_return(false) @pb.stub!(:has_notes?).and_return(false) @pb.stub!(:has_tag?).and_return(false) + @pb.stub!(:tag_string).and_return('') @xap = mock(ActsAsXapian::Search, :matches_estimated => 2) @xap.stub!(:results).and_return([ { :model => mock_event }, |