Add rspec test for public stream

This commit is contained in:
Steffen van Bergerem 2016-03-05 20:34:40 +01:00
parent 79d53f2f59
commit e4f8023b91
3 changed files with 31 additions and 19 deletions

View file

@ -5,26 +5,10 @@ Feature: The public stream
| username | email | | username | email |
| Alice Smith | alice@alice.alice | | Alice Smith | alice@alice.alice |
| Bob Jones | bob@bob.bob | | 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 "Bobs public post" And "bob@bob.bob" has a public post with text "Bobs public post"
And "bob@bob.bob" has a non public post with text "Bobs private post"
And "eve@eve.eve" has a public post with text "Eves 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 "Eves public post"
When I am on the public stream page
Then I should see "Eves public post"
Scenario: seeing public posts of someone you follow Scenario: seeing public posts
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I am on the public stream page
Then I should see "Bobs public post" Then I should see "Bobs public post"
When I am on the public stream page
Then I should see "Bobs public post"
Scenario: not seeing private posts of someone you follow
When I sign in as "alice@alice.alice"
Then I should see "Bobs private post"
When I am on the public stream page
Then I should not see "Bobs private post"

View file

@ -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

View file

@ -9,4 +9,11 @@ describe Stream::Public do
describe 'shared behaviors' do describe 'shared behaviors' do
it_should_behave_like 'it is a stream' it_should_behave_like 'it is a stream'
end end
describe "#posts" do
it "calls Post#all_public" do
expect(Post).to receive(:all_public)
@stream.posts
end
end
end end