diff --git a/app/helpers/interim_stream_hackiness_helper.rb b/app/helpers/interim_stream_hackiness_helper.rb index b2c7056c7..cf5f547f9 100644 --- a/app/helpers/interim_stream_hackiness_helper.rb +++ b/app/helpers/interim_stream_hackiness_helper.rb @@ -1,17 +1,6 @@ # frozen_string_literal: true module InterimStreamHackinessHelper - def commenting_disabled?(post) - return true unless user_signed_in? - if defined?(@commenting_disabled) - @commenting_disabled - elsif defined?(@stream) - !@stream.can_comment?(post) - else - false - end - end - ##### These methods need to go away once we pass publisher object into the partial ###### def publisher_formatted_text if params[:prefill].present? diff --git a/app/views/posts/show.mobile.haml b/app/views/posts/show.mobile.haml index 61d8556e8..186105560 100644 --- a/app/views/posts/show.mobile.haml +++ b/app/views/posts/show.mobile.haml @@ -4,5 +4,5 @@ .stream = render partial: "shared/stream_element", - locals: {post: post, commenting_disabled: commenting_disabled?(post), expanded_info: true} + locals: {post: post, expanded_info: true} diff --git a/lib/stream/aspect.rb b/lib/stream/aspect.rb index af6972775..071854bf0 100644 --- a/lib/stream/aspect.rb +++ b/lib/stream/aspect.rb @@ -80,15 +80,6 @@ class Stream::Aspect < Stream::Base @all_aspects ||= aspects.size == user.aspects.size end - # This is perfomance optimization, as everyone in your aspect stream you have - # a contact. - # - # @param post [Post] - # @return [Boolean] - def can_comment?(post) - true - end - private def aspect_ids diff --git a/lib/stream/base.rb b/lib/stream/base.rb index 30ac2f92c..1e94b6441 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -17,12 +17,6 @@ class Stream::Base 'change me in lib/base_stream.rb!' end - # @return [Boolean] - def can_comment?(post) - return true if post.author.local? - post_is_from_contact?(post) - end - def post_from_group(post) [] end @@ -105,13 +99,4 @@ class Stream::Base def contacts_in_stream @contacts_in_stream ||= Contact.where(:user_id => user.id, :person_id => people.map(&:id)).load end - - # @param post [Post] - # @return [Boolean] - def post_is_from_contact?(post) - @can_comment_cache ||= {} - @can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present? - @can_comment_cache[post.id] ||= (user.person_id == post.author_id) - @can_comment_cache[post.id] - end end diff --git a/lib/stream/public.rb b/lib/stream/public.rb index de6484b0e..a60fcb9d8 100644 --- a/lib/stream/public.rb +++ b/lib/stream/public.rb @@ -18,10 +18,6 @@ class Stream::Public < Stream::Base @posts ||= Post.all_public end - def can_comment?(post) - post.author.local? - end - # Override base class method def aspects ["public"] diff --git a/spec/helpers/interim_stream_hackiness_helper_spec.rb b/spec/helpers/interim_stream_hackiness_helper_spec.rb index 69bb04509..4230518bf 100644 --- a/spec/helpers/interim_stream_hackiness_helper_spec.rb +++ b/spec/helpers/interim_stream_hackiness_helper_spec.rb @@ -1,41 +1,6 @@ # frozen_string_literal: true describe InterimStreamHackinessHelper, type: :helper do - describe "commenting_disabled?" do - include Devise::Test::ControllerHelpers - - before do - sign_in alice - def user_signed_in? - true - end - end - - it 'returns true if no user is signed in' do - def user_signed_in? - false - end - expect(commenting_disabled?(double)).to eq(true) - end - - it 'returns true if @commenting_disabled is set' do - @commenting_disabled = true - expect(commenting_disabled?(double)).to eq(true) - @commenting_disabled = false - expect(commenting_disabled?(double)).to eq(false) - end - - it 'returns @stream.can_comment? if @stream is set' do - post = double - @stream = double - expect(@stream).to receive(:can_comment?).with(post).and_return(true) - expect(commenting_disabled?(post)).to eq(false) - - expect(@stream).to receive(:can_comment?).with(post).and_return(false) - expect(commenting_disabled?(post)).to eq(true) - end - end - describe "#publisher_formatted_text" do it "returns the prefill text from the stream" do @stream = double(publisher: Publisher.new(alice, prefill: "hello world")) diff --git a/spec/lib/stream/base_spec.rb b/spec/lib/stream/base_spec.rb index 08fa3d89c..9bd8549ac 100644 --- a/spec/lib/stream/base_spec.rb +++ b/spec/lib/stream/base_spec.rb @@ -30,39 +30,6 @@ describe Stream::Base do end end - describe '.can_comment?' do - before do - @person = FactoryGirl.create(:person) - allow(@stream).to receive(:people).and_return([bob.person, eve.person, @person]) - end - - it 'allows me to comment on my local contacts post' do - post = FactoryGirl.create(:status_message, :author => bob.person) - expect(@stream.can_comment?(post)).to be true - end - - it 'allows me to comment on my own post' do - post = FactoryGirl.create(:status_message, :author => alice.person) - expect(@stream.can_comment?(post)).to be true - end - - it 'allows me to comment on any local public post' do - post = FactoryGirl.create(:status_message, :author => eve.person) - expect(@stream.can_comment?(post)).to be true - end - - it 'allows me to comment on a remote contacts post' do - Contact.create!(:user => @stream.user, :person => @person) - post = FactoryGirl.create(:status_message, :author => @person) - expect(@stream.can_comment?(post)).to be true - end - - it 'returns false if person is remote and not a contact' do - post = FactoryGirl.create(:status_message, :author => @person) - expect(@stream.can_comment?(post)).to be false - end - end - describe '#people' do it 'excludes blocked people' do expect(@stream).to receive(:stream_posts).and_return(double.as_null_object)