aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-07-26 08:59:24 +0100
committerFrancis Irving <francis@mysociety.org>2010-07-26 08:59:24 +0100
commit6c507b123109cb2c07e389aa7d88ddc169867332 (patch)
tree62ce622c195ffd543bbea283086fda95701026ba /spec/models
parent6326d10b6f6668300875c588945be8fb79620ef1 (diff)
Tests for normal tags.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/public_body_spec.rb48
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 5c58cdc54..d48079ba1 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -1,6 +1,52 @@
require File.dirname(__FILE__) + '/../spec_helper'
- describe PublicBody, "making up the URL name" do
+describe PublicBody, " using tags" do
+ before do
+ @public_body = PublicBody.new(:name => 'Aardvark Monitoring Service',
+ :short_name => 'AMS',
+ :request_email => 'foo@flourish.org',
+ :last_edit_editor => 'test',
+ :last_edit_comment => '')
+ end
+
+ it 'should correctly convert a tag string into tags' do
+ @public_body.tag_string = 'stilton emmental'
+ @public_body.tag_string.should == 'stilton emmental'
+
+ @public_body.has_tag?('stilton').should be_true
+ @public_body.has_tag?('emmental').should be_true
+ @public_body.has_tag?('jarlsberg').should be_false
+ end
+
+ it 'should strip spaces from tag strings' do
+ @public_body.tag_string = ' chesire lancashire'
+ @public_body.tag_string.should == 'chesire lancashire'
+ end
+
+ it 'should remove tags when changing them' do
+ @public_body.tag_string = 'stilton'
+ @public_body.tag_string.should == 'stilton'
+
+ @public_body.has_tag?('stilton').should be_true
+ @public_body.has_tag?('jarlsberg').should be_false
+
+ @public_body.tag_string = 'jarlsberg'
+
+ @public_body.has_tag?('stilton').should be_false
+ @public_body.has_tag?('jarlsberg').should be_true
+ end
+
+ it 'should be able to append tags' do
+ @public_body.tag_string.should == ''
+ @public_body.add_tag_if_not_already_present('cheddar')
+
+ @public_body.tag_string.should == 'cheddar'
+ @public_body.has_tag?('cheddar').should be_true
+ end
+
+end
+
+describe PublicBody, " when making up the URL name" do
before do
@public_body = PublicBody.new
end