aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/public_body.rb2
-rw-r--r--db/migrate/036_add_public_body_tags.rb1
-rw-r--r--spec/models/public_body_spec.rb5
3 files changed, 5 insertions, 3 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 6537af7c1..65acb407b 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -192,9 +192,9 @@ class PublicBody < ActiveRecord::Base
ActiveRecord::Base.transaction do
for public_body_tag in self.public_body_tags
- # STDERR.puts("destroying tag " + public_body_tag.name)
public_body_tag.destroy
end
+ self.public_body_tags = []
for tag in tags
public_body_tag = PublicBodyTag.new(:name => tag)
self.public_body_tags << public_body_tag
diff --git a/db/migrate/036_add_public_body_tags.rb b/db/migrate/036_add_public_body_tags.rb
index 9790f9c0b..99a507f13 100644
--- a/db/migrate/036_add_public_body_tags.rb
+++ b/db/migrate/036_add_public_body_tags.rb
@@ -11,6 +11,7 @@ class AddPublicBodyTags < ActiveRecord::Migration
end
# MySQL cannot index text blobs like this
+ # XXX perhaps should change :name to be a :string
if ActiveRecord::Base.connection.adapter_name != "MySQL"
add_index :public_body_tags, [:public_body_id, :name], :unique => true
end
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 0a0b95041..b03954373 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -23,12 +23,12 @@ describe PublicBody, " using tags" do
@public_body.tag_string.should == 'chesire lancashire'
end
- it 'should work with other white space' do
+ it 'should work with other white space, such as tabs and new lines' do
@public_body.tag_string = "chesire\n\tlancashire"
@public_body.tag_string.should == 'chesire lancashire'
end
- it 'should remove tags when changing them' do
+ it 'changing tags should remove presence of the old ones' do
@public_body.tag_string = 'stilton'
@public_body.tag_string.should == 'stilton'
@@ -36,6 +36,7 @@ describe PublicBody, " using tags" do
@public_body.has_tag?('jarlsberg').should be_false
@public_body.tag_string = 'jarlsberg'
+ @public_body.tag_string.should == 'jarlsberg'
@public_body.has_tag?('stilton').should be_false
@public_body.has_tag?('jarlsberg').should be_true