blocked users works for multi stream, cuke passes
fixed scoping stuff
This commit is contained in:
parent
16e76886d9
commit
0eb33b371b
6 changed files with 26 additions and 17 deletions
|
|
@ -1,7 +1,7 @@
|
|||
module StreamElementHelper
|
||||
def block_user_control(author)
|
||||
if user_signed_in?
|
||||
link_to block_path(author), :class => "block_button"
|
||||
button_to "block a mofo", blocks_path(:block => {:person_id => author.id}), :class => "block_button"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -26,7 +26,11 @@ class Post < ActiveRecord::Base
|
|||
def self.excluding_blocks(user)
|
||||
people = user.blocks.map { |x| x.person_id }
|
||||
|
||||
if people.present?
|
||||
where("posts.author_id NOT IN (?)", people)
|
||||
else
|
||||
scoped
|
||||
end
|
||||
end
|
||||
|
||||
def self.for_a_stream(max_time, order, user=nil)
|
||||
|
|
|
|||
|
|
@ -1,20 +1,17 @@
|
|||
@javascript
|
||||
Feature: Blocking a user from the stream
|
||||
Background:
|
||||
Given a user with username "bob"
|
||||
And a user with username "alice"
|
||||
And a user with username "alice" is connected with "bob"
|
||||
|
||||
When I sign in as "bob@bob.bob"
|
||||
And I post a status with the text "I am da #boss"
|
||||
And I am on the home page
|
||||
When I go to the destroy user session page
|
||||
Given a user named "Bob Jones" with email "bob@bob.bob"
|
||||
And a user named "Alice Smith" with email "alice@alice.alice"
|
||||
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
||||
And Alice has a post mentioning Bob
|
||||
|
||||
|
||||
Scenario: Blocking a user
|
||||
When I sign in as "alice@alice.alice"
|
||||
When I sign in as "bob@bob.bob"
|
||||
And I am on the home page
|
||||
Then I should see "I am da #boss"
|
||||
When I click on bob's block button
|
||||
And I wait for the ajax to finish
|
||||
When I click on the first block button
|
||||
And I am on the home page
|
||||
Then I should not see "I am da #boss"
|
||||
And I wait for the ajax to finish
|
||||
Then I should not see any posts in my stream
|
||||
|
|
@ -13,6 +13,10 @@ Then /^I should not see an uploaded image within the photo drop zone$/ do
|
|||
find("#photodropzone img").should be_nil
|
||||
end
|
||||
|
||||
Then /^I should not see any posts in my stream$/ do
|
||||
find(".stream_element").should be_nil
|
||||
end
|
||||
|
||||
Given /^"([^"]*)" has a public post with text "([^"]*)"$/ do |email, text|
|
||||
user = User.find_by_email(email)
|
||||
user.post(:status_message, :text => text, :public => true, :to => user.aspects)
|
||||
|
|
@ -27,6 +31,6 @@ When /^The user deletes their first post$/ do
|
|||
@me.posts.first.destroy
|
||||
end
|
||||
|
||||
When /^I click on bob's block button/ do
|
||||
find(".block_button").first.click
|
||||
When /^I click on the first block button/ do
|
||||
find(".block_button").click
|
||||
end
|
||||
|
|
@ -19,7 +19,7 @@ class Stream::Multi < Stream::Base
|
|||
@posts ||= lambda do
|
||||
post_ids = aspects_post_ids + followed_tags_post_ids + mentioned_post_ids
|
||||
post_ids += community_spotlight_post_ids if include_community_spotlight?
|
||||
Post.where(:id => post_ids).for_a_stream(max_time, order)
|
||||
Post.where(:id => post_ids).for_a_stream(max_time, order, user)
|
||||
end.call
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@ describe Post do
|
|||
it 'includes not blocked users posts' do
|
||||
Post.excluding_blocks(bob).should include(@other_post)
|
||||
end
|
||||
|
||||
it 'returns posts if you dont have any blocks' do
|
||||
Post.excluding_blocks(alice).count.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
context 'having some posts' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue