aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/has_tag_string_tag_spec.rb15
-rw-r--r--spec/models/public_body_spec.rb21
-rw-r--r--spec/models/public_body_tag_spec.rb14
3 files changed, 36 insertions, 14 deletions
diff --git a/spec/models/has_tag_string_tag_spec.rb b/spec/models/has_tag_string_tag_spec.rb
new file mode 100644
index 000000000..9dfcf3daf
--- /dev/null
+++ b/spec/models/has_tag_string_tag_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe HasTagString::HasTagStringTag, " when fiddling with tag strings " do
+ fixtures :public_bodies
+
+ it "should be able to make a new tag and save it" do
+ @tag = HasTagString::HasTagStringTag.new
+ @tag.model = 'PublicBody'
+ @tag.model_id = public_bodies(:geraldine_public_body).id
+ @tag.name = "moo"
+ @tag.save
+ end
+
+end
+
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
diff --git a/spec/models/public_body_tag_spec.rb b/spec/models/public_body_tag_spec.rb
deleted file mode 100644
index 09a597bd0..000000000
--- a/spec/models/public_body_tag_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-
-describe PublicBodyTag, " when fiddling with public body tags " do
- fixtures :public_bodies
-
- it "should be able to make a new tag and save it" do
- @tag = PublicBodyTag.new
- @tag.public_body = public_bodies(:geraldine_public_body)
- @tag.name = "moo"
- @tag.save
- end
-
-end
-