diff --git a/app/models/article.rb b/app/models/article.rb index 4dac0b5..4b30751 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -262,7 +262,10 @@ class Article < ActiveRecord::Base # (To override short format representation, override the lead method) def to_html(options = {}) if options[:format] == 'short' - display_short_format(self) + article = self + proc do + display_short_format(article) + end else body || '' end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 00e75b6..bf48d0c 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -100,7 +100,8 @@ class ArticleTest < ActiveSupport::TestCase should 'provide short html version' do a = fast_create(Article, :body => 'full body', :abstract => 'lead', :profile_id => profile.id) - assert_match /lead/, a.to_html(:format=>'short') + expects(:display_short_format).with(a).once + instance_eval(&a.to_html(:format=>'short')) end should 'provide full html version' do -- libgit2 0.21.2