Add rspec test for public stream
This commit is contained in:
parent
79d53f2f59
commit
e4f8023b91
3 changed files with 31 additions and 19 deletions
|
|
@ -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 "Bob’s public post"
|
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"
|
When I sign in as "alice@alice.alice"
|
||||||
|
And I am on the public stream page
|
||||||
Then I should see "Bob’s public post"
|
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"
|
|
||||||
|
|
|
||||||
21
spec/lib/diaspora/shareable_spec.rb
Normal file
21
spec/lib/diaspora/shareable_spec.rb
Normal 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
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue