Commit d7c39b573b7dddb3ad6f2669db0891d838db049c

Authored by Leandro Santos
1 parent 84df5586

Fix TagsBlock unit test

app/models/article.rb
... ... @@ -2,7 +2,7 @@ require 'hpricot'
2 2  
3 3 class Article < ActiveRecord::Base
4 4  
5   - attr_accessible :name, :body, :abstract, :profile
  5 + attr_accessible :name, :body, :abstract, :profile, :tag_list
6 6  
7 7 SEARCHABLE_FIELDS = {
8 8 :name => 10,
... ...
test/unit/tags_block_test.rb
... ... @@ -8,8 +8,12 @@ class TagsBlockTest &lt; ActiveSupport::TestCase
8 8 @user.articles.build(:name => 'article 2', :tag_list => 'first-tag, second-tag').save!
9 9 @user.articles.build(:name => 'article 3', :tag_list => 'first-tag, second-tag, third-tag').save!
10 10  
11   - box = Box.create!(:owner => @user)
12   - @block = TagsBlock.create!(:box => box)
  11 + box = Box.new
  12 + box.owner = @user
  13 + box.save!
  14 + @block = TagsBlock.new
  15 + @block.box = box
  16 + @block.save
13 17 end
14 18 attr_reader :block
15 19  
... ...
vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb
1 1 class Tag < ActiveRecord::Base
2 2 has_many :taggings
  3 +
  4 + attr_accessible :name
3 5  
4 6 validates_presence_of :name
5 7 validates_uniqueness_of :name
... ...
vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb
... ... @@ -40,19 +40,19 @@ class TagList
40 40 end
41 41  
42 42 class << self
43   - def from(tags)
44   - case tags
45   - when String
46   - new(parse(tags))
47   - when Array
48   - new(tags.map(&:to_s))
49   - else
50   - new([])
  43 + def from(tags)
  44 + case tags
  45 + when String
  46 + new(parse(tags))
  47 + when Array
  48 + new(tags.map(&:to_s))
  49 + else
  50 + new([])
51 51 end
52 52 end
53 53  
54 54 def parse(string)
55   - returning [] do |names|
  55 + [].tap do |names|
56 56 string = string.to_s.dup
57 57  
58 58 # Parse the quoted tags
... ...