Commit 289ca9e2577efa8eea64e63319dfd791f4382ce9
1 parent
2978625c
Exists in
master
and in
22 other branches
rails3: fix html display for short format on articles
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
app/models/article.rb
@@ -262,7 +262,10 @@ class Article < ActiveRecord::Base | @@ -262,7 +262,10 @@ class Article < ActiveRecord::Base | ||
262 | # (To override short format representation, override the lead method) | 262 | # (To override short format representation, override the lead method) |
263 | def to_html(options = {}) | 263 | def to_html(options = {}) |
264 | if options[:format] == 'short' | 264 | if options[:format] == 'short' |
265 | - display_short_format(self) | 265 | + article = self |
266 | + proc do | ||
267 | + display_short_format(article) | ||
268 | + end | ||
266 | else | 269 | else |
267 | body || '' | 270 | body || '' |
268 | end | 271 | end |
test/unit/article_test.rb
@@ -100,7 +100,8 @@ class ArticleTest < ActiveSupport::TestCase | @@ -100,7 +100,8 @@ class ArticleTest < ActiveSupport::TestCase | ||
100 | 100 | ||
101 | should 'provide short html version' do | 101 | should 'provide short html version' do |
102 | a = fast_create(Article, :body => 'full body', :abstract => 'lead', :profile_id => profile.id) | 102 | a = fast_create(Article, :body => 'full body', :abstract => 'lead', :profile_id => profile.id) |
103 | - assert_match /lead/, a.to_html(:format=>'short') | 103 | + expects(:display_short_format).with(a).once |
104 | + instance_eval(&a.to_html(:format=>'short')) | ||
104 | end | 105 | end |
105 | 106 | ||
106 | should 'provide full html version' do | 107 | should 'provide full html version' do |