From 605b418d424e3384476d97f3b07c694a63e70da3 Mon Sep 17 00:00:00 2001 From: Steven Hancock Date: Tue, 8 May 2012 03:02:07 -0700 Subject: [PATCH] Reshares delegate nsfw to the root post fixes #3120 --- app/models/reshare.rb | 4 ++++ features/not_safe_for_work.feature | 15 +++++++++++++++ spec/models/reshare_spec.rb | 14 ++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 8de96bcf3..f1eee1a7d 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -61,6 +61,10 @@ class Reshare < Post Notifications::Reshared if root.author == user.person end + def nsfw + root.nsfw + end + private def after_parse diff --git a/features/not_safe_for_work.feature b/features/not_safe_for_work.feature index 7f7604d74..3ef831782 100644 --- a/features/not_safe_for_work.feature +++ b/features/not_safe_for_work.feature @@ -41,3 +41,18 @@ Scenario: Toggling nsfw state When I toggle nsfw posts Then I should not see "I love 0bj3ction4bl3 c0nt3nt!" And I should not see "Sexy Senators Gone Wild!" + +Scenario: Resharing an nsfw post + Given a nsfw user with email "tommy@pr0nking.com" + And a user with email "laura@officeworkers.com" + And a user with email "laura@officeworkers.com" is connected with "tommy@pr0nking.com" + And "tommy@pr0nking.com" has a public post with text "Sexy Senators Gone Wild!" + And I sign in as "laura@officeworkers.com" + And I toggle nsfw posts + And I preemptively confirm the alert + And I follow "Reshare" + And I wait for the ajax to finish + And I follow "Stream" + And I wait for the ajax to finish + Then I should have 2 nsfw posts + And I should not see "Sexy Senators Gone Wild!" diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 28fe156b8..b8311a3ca 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -53,6 +53,20 @@ describe Reshare do end end + describe '#nsfw' do + before do + sfw = Factory(:status_message, :author => alice.person, :public => true) + nsfw = Factory(:status_message, :author => alice.person, :public => true, :text => "This is #nsfw") + @sfw_reshare = Factory(:reshare, :root => sfw) + @nsfw_reshare = Factory(:reshare, :root => nsfw) + end + + it 'deletates #nsfw to the root post' do + @sfw_reshare.nsfw.should_not be_true + @nsfw_reshare.nsfw.should be_true + end + end + describe '#notification_type' do before do sm = Factory(:status_message, :author => alice.person, :public => true)