Skip to content
Extraits de code Groupes Projets
Valider 6252436b rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

tests for commentshelper shim

parent 772d0241
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter