diff options
Diffstat (limited to 'spec/models/public_body_spec.rb')
-rw-r--r-- | spec/models/public_body_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index ff4a78bdf..f00138ab3 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -94,6 +94,27 @@ describe PublicBody, " using machine tags" do end end +describe PublicBody, "when finding_by_tags" do + fixtures :public_bodies + + before do + @geraldine = public_bodies(:geraldine_public_body) + @geraldine.tag_string = 'rabbit' + @humpadink = public_bodies(:humpadink_public_body) + @humpadink.tag_string = 'coney:5678 coney:1234' + end + + it 'should be able to find bodies by string' do + found = PublicBody.find_by_tag('rabbit') + found.should == [ @geraldine ] + end + + it 'should be able to find when there are multiple tags in one body, without returning duplicates' do + found = PublicBody.find_by_tag('coney') + found.should == [ @humpadink ] + end +end + describe PublicBody, " when making up the URL name" do before do @public_body = PublicBody.new |