Commit b31f8719348417053797237a27583c54cf976294

Authored by Victor Costa
1 parent 49d1e301

rails3: fix comment_helper_test

Mocha default behavior changes to not allow stubbing on nil.
Showing 1 changed file with 5 additions and 4 deletions   Show diff stats
test/unit/comment_helper_test.rb
@@ -12,6 +12,7 @@ class CommentHelperTest < ActiveSupport::TestCase @@ -12,6 +12,7 @@ class CommentHelperTest < ActiveSupport::TestCase
12 self.stubs(:logged_in?).returns(true) 12 self.stubs(:logged_in?).returns(true)
13 self.stubs(:report_abuse).returns('<a href="#">link</a>') 13 self.stubs(:report_abuse).returns('<a href="#">link</a>')
14 self.stubs(:expirable_comment_link).returns('<a href="#">link</a>') 14 self.stubs(:expirable_comment_link).returns('<a href="#">link</a>')
  15 + @plugins = []
15 @plugins.stubs(:dispatch).returns([]) 16 @plugins.stubs(:dispatch).returns([])
16 end 17 end
17 18
@@ -19,7 +20,7 @@ class CommentHelperTest &lt; ActiveSupport::TestCase @@ -19,7 +20,7 @@ class CommentHelperTest &lt; ActiveSupport::TestCase
19 20
20 should 'show menu if it has links for actions' do 21 should 'show menu if it has links for actions' do
21 article = Article.new(:profile => profile) 22 article = Article.new(:profile => profile)
22 - comment = Comment.new(:article => article) 23 + comment = build(Comment, :article => article)
23 menu = comment_actions(comment) 24 menu = comment_actions(comment)
24 assert menu 25 assert menu
25 end 26 end
@@ -43,7 +44,7 @@ class CommentHelperTest &lt; ActiveSupport::TestCase @@ -43,7 +44,7 @@ class CommentHelperTest &lt; ActiveSupport::TestCase
43 44
44 should 'include actions of plugins in menu' do 45 should 'include actions of plugins in menu' do
45 article = Article.new(:profile => profile) 46 article = Article.new(:profile => profile)
46 - comment = Comment.new(:article => article) 47 + comment = build(Comment, :article => article)
47 plugin_action = {:link => 'plugin_action'} 48 plugin_action = {:link => 'plugin_action'}
48 @plugins.stubs(:dispatch).returns([plugin_action]) 49 @plugins.stubs(:dispatch).returns([plugin_action])
49 links = links_for_comment_actions(comment) 50 links = links_for_comment_actions(comment)
@@ -52,8 +53,8 @@ class CommentHelperTest &lt; ActiveSupport::TestCase @@ -52,8 +53,8 @@ class CommentHelperTest &lt; ActiveSupport::TestCase
52 53
53 should 'include lambda actions of plugins in menu' do 54 should 'include lambda actions of plugins in menu' do
54 article = Article.new(:profile => profile) 55 article = Article.new(:profile => profile)
55 - comment = Comment.new(:article => article)  
56 - plugin_action = lambda{[{:link => 'plugin_action'}, {:link => 'plugin_action2'}]} 56 + comment = build(Comment, :article => article)
  57 + plugin_action = proc{[{:link => 'plugin_action'}, {:link => 'plugin_action2'}]}
57 @plugins.stubs(:dispatch).returns([plugin_action]) 58 @plugins.stubs(:dispatch).returns([plugin_action])
58 links = links_for_comment_actions(comment) 59 links = links_for_comment_actions(comment)
59 assert_includes links, {:link => 'plugin_action'} 60 assert_includes links, {:link => 'plugin_action'}