Commit d7c39b573b7dddb3ad6f2669db0891d838db049c
1 parent
84df5586
Exists in
master
and in
27 other branches
Fix TagsBlock unit test
Showing
4 changed files
with
18 additions
and
12 deletions
Show diff stats
app/models/article.rb
@@ -2,7 +2,7 @@ require 'hpricot' | @@ -2,7 +2,7 @@ require 'hpricot' | ||
2 | 2 | ||
3 | class Article < ActiveRecord::Base | 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 | SEARCHABLE_FIELDS = { | 7 | SEARCHABLE_FIELDS = { |
8 | :name => 10, | 8 | :name => 10, |
test/unit/tags_block_test.rb
@@ -8,8 +8,12 @@ class TagsBlockTest < ActiveSupport::TestCase | @@ -8,8 +8,12 @@ class TagsBlockTest < ActiveSupport::TestCase | ||
8 | @user.articles.build(:name => 'article 2', :tag_list => 'first-tag, second-tag').save! | 8 | @user.articles.build(:name => 'article 2', :tag_list => 'first-tag, second-tag').save! |
9 | @user.articles.build(:name => 'article 3', :tag_list => 'first-tag, second-tag, third-tag').save! | 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 | end | 17 | end |
14 | attr_reader :block | 18 | attr_reader :block |
15 | 19 |
vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb
vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb
@@ -40,19 +40,19 @@ class TagList | @@ -40,19 +40,19 @@ class TagList | ||
40 | end | 40 | end |
41 | 41 | ||
42 | class << self | 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 | end | 51 | end |
52 | end | 52 | end |
53 | 53 | ||
54 | def parse(string) | 54 | def parse(string) |
55 | - returning [] do |names| | 55 | + [].tap do |names| |
56 | string = string.to_s.dup | 56 | string = string.to_s.dup |
57 | 57 | ||
58 | # Parse the quoted tags | 58 | # Parse the quoted tags |