tests for commentshelper shim
This commit is contained in:
parent
772d0241d9
commit
6252436b34
1 changed files with 36 additions and 15 deletions
|
|
@ -1,21 +1,42 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe CommentsHelper do
|
describe CommentsHelper do
|
||||||
before do
|
describe '.new_comment_form' do
|
||||||
@user = alice
|
before do
|
||||||
@aspect = @user.aspects.first
|
@user = alice
|
||||||
@post = @user.post(:status_message, :text => "hi", :to => @aspect.id)
|
@aspect = @user.aspects.first
|
||||||
end
|
@post = @user.post(:status_message, :text => "hi", :to => @aspect.id)
|
||||||
it 'renders a new comment form' do
|
end
|
||||||
new_comment_form(@post.id, @user).should ==
|
it 'renders a new comment form' do
|
||||||
@controller.render_to_string(:partial => 'comments/new_comment',
|
new_comment_form(@post.id, @user).should ==
|
||||||
:locals => {:post_id => @post.id, :current_user => @user})
|
@controller.render_to_string(:partial => 'comments/new_comment',
|
||||||
end
|
:locals => {:post_id => @post.id, :current_user => @user})
|
||||||
it 'renders it fast the second time' do
|
end
|
||||||
new_comment_form(@post.id, @user)
|
it 'renders it fast the second time' do
|
||||||
time = Benchmark.realtime{
|
|
||||||
new_comment_form(@post.id, @user)
|
new_comment_form(@post.id, @user)
|
||||||
}
|
time = Benchmark.realtime{
|
||||||
(time*1000).should < 1
|
new_comment_form(@post.id, @user)
|
||||||
|
}
|
||||||
|
(time*1000).should < 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'commenting_disabled?' do
|
||||||
|
it 'returns true if @commenting_disabled is set' do
|
||||||
|
@commenting_disabled = true
|
||||||
|
commenting_disabled?(stub).should_be true
|
||||||
|
@commenting_disabled = false
|
||||||
|
commenting_disabled?(stub).should_be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns @stream.can_comment? if @stream is set' do
|
||||||
|
post = stub
|
||||||
|
@stream = stub
|
||||||
|
@stream.should_receive(:can_comment?).with(post).and_return(true)
|
||||||
|
commenting_disabled?(post).should_be true
|
||||||
|
|
||||||
|
@stream.should_receive(:can_comment?).with(post).and_return(false)
|
||||||
|
commenting_disabled?(post).should_be false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue