diff --git a/features/desktop/public_stream.feature b/features/desktop/public_stream.feature index 7d9c27f5d..02449b93c 100644 --- a/features/desktop/public_stream.feature +++ b/features/desktop/public_stream.feature @@ -5,26 +5,10 @@ Feature: The public stream | username | email | | Alice Smith | alice@alice.alice | | Bob Jones | bob@bob.bob | - | Eve Doe | eve@eve.eve | - And a user with email "alice@alice.alice" is connected with "bob@bob.bob" + And "bob@bob.bob" has a public post with text "Bob’s public post" - And "bob@bob.bob" has a non public post with text "Bob’s private post" - And "eve@eve.eve" has a public post with text "Eve’s public post" - - Scenario: seeing public posts of someone you don't follow - When I sign in as "alice@alice.alice" - Then I should not see "Eve’s public post" - When I am on the public stream page - Then I should see "Eve’s public post" - Scenario: seeing public posts of someone you follow + Scenario: seeing public posts When I sign in as "alice@alice.alice" + And I am on the public stream page Then I should see "Bob’s public post" - When I am on the public stream page - Then I should see "Bob’s public post" - - Scenario: not seeing private posts of someone you follow - When I sign in as "alice@alice.alice" - Then I should see "Bob’s private post" - When I am on the public stream page - Then I should not see "Bob’s private post" diff --git a/spec/lib/diaspora/shareable_spec.rb b/spec/lib/diaspora/shareable_spec.rb new file mode 100644 index 000000000..da3916524 --- /dev/null +++ b/spec/lib/diaspora/shareable_spec.rb @@ -0,0 +1,21 @@ +require "spec_helper" + +describe Diaspora::Shareable do + describe "scopes" do + describe ".all_public" do + it "includes all public posts" do + post1 = FactoryGirl.create(:status_message, author: alice.person, public: true) + post2 = FactoryGirl.create(:status_message, author: bob.person, public: true) + post3 = FactoryGirl.create(:status_message, author: eve.person, public: true) + expect(Post.all_public.map(&:id)).to eq([post1.id, post2.id, post3.id]) + end + + it "doesn't include any private posts" do + FactoryGirl.create(:status_message, author: alice.person, public: false) + FactoryGirl.create(:status_message, author: bob.person, public: false) + FactoryGirl.create(:status_message, author: eve.person, public: false) + expect(Post.all_public.map(&:id)).to eq([]) + end + end + end +end diff --git a/spec/lib/stream/public_spec.rb b/spec/lib/stream/public_spec.rb index 976a9439b..a17348cef 100644 --- a/spec/lib/stream/public_spec.rb +++ b/spec/lib/stream/public_spec.rb @@ -9,4 +9,11 @@ describe Stream::Public do describe 'shared behaviors' do it_should_behave_like 'it is a stream' end + + describe "#posts" do + it "calls Post#all_public" do + expect(Post).to receive(:all_public) + @stream.posts + end + end end