Skip to content
Extraits de code Groupes Projets
Valider 0eb33b37 rédigé par Dan Hansen & Maxwell Salzberg's avatar Dan Hansen & Maxwell Salzberg Validation de danielgrippi
Parcourir les fichiers

blocked users works for multi stream, cuke passes

fixed scoping stuff
parent 16e76886
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
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
\ No newline at end of file
......@@ -26,7 +26,11 @@ class Post < ActiveRecord::Base
def self.excluding_blocks(user)
people = user.blocks.map { |x| x.person_id }
where("posts.author_id NOT IN (?)", people)
if people.present?
where("posts.author_id NOT IN (?)", people)
else
scoped
end
end
def self.for_a_stream(max_time, order, user=nil)
......
@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"
\ No newline at end of file
And I wait for the ajax to finish
Then I should not see any posts in my stream
\ No newline at end of file
......@@ -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
\ No newline at end of file
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter