From 0f073387ac1d499bbf97962d3b4adf4487ec511e Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Mon, 3 Oct 2011 15:20:21 -0700 Subject: [PATCH] IZ MS refactor commenting disabled --- app/helpers/comments_helper.rb | 9 ++++++ app/views/comments/_comment.html.haml | 2 +- app/views/comments/_comments.html.haml | 2 +- app/views/people/show.html.haml | 2 +- app/views/posts/show.html.haml | 2 +- app/views/posts/show.mobile.haml | 3 +- app/views/shared/_stream.haml | 2 +- app/views/shared/_stream_element.html.haml | 19 ++++++------ features/infinite_scroll.feature | 34 ++-------------------- spec/models/status_message_spec.rb | 2 +- 10 files changed, 27 insertions(+), 50 deletions(-) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 3b90b80ac..1551aa41d 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -30,4 +30,13 @@ module CommentsHelper nil end end + + def commenting_disabled? + return true unless user_signed_in? + if defined?(@commenting_disabled) + return @commenting_disabled + else + false + end + end end diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 09d880aca..365f57c36 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -22,7 +22,7 @@ .likes_container = 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 = like_action(comment, current_user) diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index f1c261983..857c8f796 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -13,6 +13,6 @@ -else = 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(post.id, current_user) diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 9fd117dc4..27887dd22 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -31,7 +31,7 @@ = render 'photos/index', :photos => @posts - else #main_stream.stream - = render 'shared/stream', :posts => @posts, :commenting_disabled => @commenting_disabled + = render 'shared/stream', :posts => @posts, :commenting_disabled => commenting_disabled? #pagination =link_to(t('more'), next_page_path, :class => 'paginate') diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index b4fb6fc80..bed2cdd68 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -8,7 +8,7 @@ - if @post.is_a?(Photo) = render 'posts/photo', :post => @post - 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 diff --git a/app/views/posts/show.mobile.haml b/app/views/posts/show.mobile.haml index 0dda0b357..767952d8d 100644 --- a/app/views/posts/show.mobile.haml +++ b/app/views/posts/show.mobile.haml @@ -4,5 +4,4 @@ .stream = render :partial => 'shared/stream_element', - :locals => {:post => @post, :commenting_disabled => defined?(@commenting_disabled), - :expanded_info => true} + :locals => {:post => @post, :commenting_disabled => commenting_disabled?, :expanded_info => true} diff --git a/app/views/shared/_stream.haml b/app/views/shared/_stream.haml index ac71ad100..ee849ca11 100644 --- a/app/views/shared/_stream.haml +++ b/app/views/shared/_stream.haml @@ -5,5 +5,5 @@ = render :partial => 'shared/stream_element', :collection => posts, :as => :post, - :locals => { :commenting_disabled => defined?(@commenting_disabled)} + :locals => { :commenting_disabled => commenting_disabled?} diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 5321f0fd4..38ddc9079 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -68,21 +68,20 @@ – - - if user_signed_in? - - unless @commenting_disabled - %span.like_action - = like_action(post, current_user) + - unless commenting_disabled? + %span.like_action + = like_action(post, current_user) - - if (post.author_id != current_user.person.id) && (post.public?) - · - %span.reshare_action - = reshare_link(post) + - if (post.author_id != current_user.person.id) && (post.public?) · + %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_container = 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? diff --git a/features/infinite_scroll.feature b/features/infinite_scroll.feature index 147b465e8..6cdf774e3 100644 --- a/features/infinite_scroll.feature +++ b/features/infinite_scroll.feature @@ -11,21 +11,8 @@ Feature: infinite scroll And I wait for the ajax to finish Scenario: on the main stream by activity - Then I should see 15 posts - And I should see "alice - 26 - #seeded" - - 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" + And I follow "commented on" + And I wait for the ajax to finish Then I should see 15 posts And I should see "alice - 26 - #seeded" @@ -41,7 +28,6 @@ Feature: infinite scroll Then I should see "No more" Scenario: on the main stream post created time - And I follow "posted" And I go to the home page And I wait for the ajax to finish Then I should see 15 posts @@ -58,22 +44,6 @@ Feature: infinite scroll When I scroll down 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 When I go to the tag page for "seeded" Then I should see 15 posts diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index e123d5cd3..826dcd4e8 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -69,7 +69,7 @@ describe StatusMessage do it 'should require status messages to be less than 10000 characters' do message = '' - 10001.times do message = message +'1';end + 10001.times{message = message +'1'} status = Factory.build(:status_message, :text => message) status.should_not be_valid