Commit b31f8719348417053797237a27583c54cf976294
1 parent
49d1e301
Exists in
master
and in
29 other branches
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 | 12 | self.stubs(:logged_in?).returns(true) |
13 | 13 | self.stubs(:report_abuse).returns('<a href="#">link</a>') |
14 | 14 | self.stubs(:expirable_comment_link).returns('<a href="#">link</a>') |
15 | + @plugins = [] | |
15 | 16 | @plugins.stubs(:dispatch).returns([]) |
16 | 17 | end |
17 | 18 | |
... | ... | @@ -19,7 +20,7 @@ class CommentHelperTest < ActiveSupport::TestCase |
19 | 20 | |
20 | 21 | should 'show menu if it has links for actions' do |
21 | 22 | article = Article.new(:profile => profile) |
22 | - comment = Comment.new(:article => article) | |
23 | + comment = build(Comment, :article => article) | |
23 | 24 | menu = comment_actions(comment) |
24 | 25 | assert menu |
25 | 26 | end |
... | ... | @@ -43,7 +44,7 @@ class CommentHelperTest < ActiveSupport::TestCase |
43 | 44 | |
44 | 45 | should 'include actions of plugins in menu' do |
45 | 46 | article = Article.new(:profile => profile) |
46 | - comment = Comment.new(:article => article) | |
47 | + comment = build(Comment, :article => article) | |
47 | 48 | plugin_action = {:link => 'plugin_action'} |
48 | 49 | @plugins.stubs(:dispatch).returns([plugin_action]) |
49 | 50 | links = links_for_comment_actions(comment) |
... | ... | @@ -52,8 +53,8 @@ class CommentHelperTest < ActiveSupport::TestCase |
52 | 53 | |
53 | 54 | should 'include lambda actions of plugins in menu' do |
54 | 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 | 58 | @plugins.stubs(:dispatch).returns([plugin_action]) |
58 | 59 | links = links_for_comment_actions(comment) |
59 | 60 | assert_includes links, {:link => 'plugin_action'} | ... | ... |