IZ MS refactor commenting disabled

This commit is contained in:
Maxwell Salzberg 2011-10-03 15:20:21 -07:00
parent 70d9dcf3b7
commit 0f073387ac
10 changed files with 27 additions and 50 deletions

View file

@ -30,4 +30,13 @@ module CommentsHelper
nil nil
end end
end end
def commenting_disabled?
return true unless user_signed_in?
if defined?(@commenting_disabled)
return @commenting_disabled
else
false
end
end
end end

View file

@ -22,7 +22,7 @@
.likes_container .likes_container
= render "likes/likes_container", :target_id => comment.id, :likes_count => comment.likes_count, :target_type => "Comment" = render "likes/likes_container", :target_id => comment.id, :likes_count => comment.likes_count, :target_type => "Comment"
- unless !user_signed_in? || @commenting_disabled - unless commenting_disabled?
%span.like_action %span.like_action
= like_action(comment, current_user) = like_action(comment, current_user)

View file

@ -13,6 +13,6 @@
-else -else
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post} = render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
- unless !user_signed_in? || @commenting_disabled - unless commenting_disabled?
.new_comment_form_wrapper{:class => comment_form_wrapper_class(post)} .new_comment_form_wrapper{:class => comment_form_wrapper_class(post)}
= new_comment_form(post.id, current_user) = new_comment_form(post.id, current_user)

View file

@ -31,7 +31,7 @@
= render 'photos/index', :photos => @posts = render 'photos/index', :photos => @posts
- else - else
#main_stream.stream #main_stream.stream
= render 'shared/stream', :posts => @posts, :commenting_disabled => @commenting_disabled = render 'shared/stream', :posts => @posts, :commenting_disabled => commenting_disabled?
#pagination #pagination
=link_to(t('more'), next_page_path, :class => 'paginate') =link_to(t('more'), next_page_path, :class => 'paginate')

View file

@ -8,7 +8,7 @@
- if @post.is_a?(Photo) - if @post.is_a?(Photo)
= render 'posts/photo', :post => @post = render 'posts/photo', :post => @post
- else - else
= render 'shared/stream_element', :post => @post, :commenting_disabled => defined?(@commenting_disabled) = render 'shared/stream_element', :post => @post, :commenting_disabled => commenting_disabled?
%br %br
%br %br
%br %br

View file

@ -4,5 +4,4 @@
.stream .stream
= render :partial => 'shared/stream_element', = render :partial => 'shared/stream_element',
:locals => {:post => @post, :commenting_disabled => defined?(@commenting_disabled), :locals => {:post => @post, :commenting_disabled => commenting_disabled?, :expanded_info => true}
:expanded_info => true}

View file

@ -5,5 +5,5 @@
= render :partial => 'shared/stream_element', = render :partial => 'shared/stream_element',
:collection => posts, :collection => posts,
:as => :post, :as => :post,
:locals => { :commenting_disabled => defined?(@commenting_disabled)} :locals => { :commenting_disabled => commenting_disabled?}

View file

@ -68,21 +68,20 @@
– –
- if user_signed_in? - unless commenting_disabled?
- unless @commenting_disabled %span.like_action
%span.like_action = like_action(post, current_user)
= like_action(post, current_user)
- if (post.author_id != current_user.person.id) && (post.public?) - if (post.author_id != current_user.person.id) && (post.public?)
·
%span.reshare_action
= reshare_link(post)
· ·
%span.reshare_action
= reshare_link(post)
·
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea' = link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
.likes.on_post .likes.on_post
.likes_container .likes_container
= render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user, :target_type => "Post" = render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user, :target_type => "Post"
= render "comments/comments", :post => post, :current_user => current_user, :commenting_disabled => @commenting_disabled = render "comments/comments", :post => post, :current_user => current_user, :commenting_disabled => commenting_disabled?

View file

@ -11,21 +11,8 @@ Feature: infinite scroll
And I wait for the ajax to finish And I wait for the ajax to finish
Scenario: on the main stream by activity Scenario: on the main stream by activity
Then I should see 15 posts And I follow "commented on"
And I should see "alice - 26 - #seeded" And I wait for the ajax to finish
When I scroll down
Then I should see 30 posts
And I should see "alice - 11 - #seeded"
When I scroll down
Then I should see 40 posts
And I should see "alice - 1 - #seeded"
When I scroll down
Then I should see "No more"
When I follow "generic"
Then I should see 15 posts Then I should see 15 posts
And I should see "alice - 26 - #seeded" And I should see "alice - 26 - #seeded"
@ -41,7 +28,6 @@ Feature: infinite scroll
Then I should see "No more" Then I should see "No more"
Scenario: on the main stream post created time Scenario: on the main stream post created time
And I follow "posted"
And I go to the home page And I go to the home page
And I wait for the ajax to finish And I wait for the ajax to finish
Then I should see 15 posts Then I should see 15 posts
@ -58,22 +44,6 @@ Feature: infinite scroll
When I scroll down When I scroll down
Then I should see "No more" Then I should see "No more"
When I follow "generic"
And I wait for the ajax to finish
Then I should see 15 posts
And I should see "alice - 15 - #seeded"
When I scroll down
Then I should see 30 posts
And I should see "alice - 30 - #seeded"
When I scroll down
Then I should see 40 posts
And I should see "alice - 40 - #seeded"
When I scroll down
Then I should see "No more"
Scenario: On a tag page Scenario: On a tag page
When I go to the tag page for "seeded" When I go to the tag page for "seeded"
Then I should see 15 posts Then I should see 15 posts

View file

@ -69,7 +69,7 @@ describe StatusMessage do
it 'should require status messages to be less than 10000 characters' do it 'should require status messages to be less than 10000 characters' do
message = '' message = ''
10001.times do message = message +'1';end 10001.times{message = message +'1'}
status = Factory.build(:status_message, :text => message) status = Factory.build(:status_message, :text => message)
status.should_not be_valid status.should_not be_valid