Activity stream keeping retracted participations
This commit is contained in:
parent
5481ddb540
commit
5fb328864e
5 changed files with 124 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ class Comment < ActiveRecord::Base
|
||||||
belongs_to :commentable, :touch => true, :polymorphic => true
|
belongs_to :commentable, :touch => true, :polymorphic => true
|
||||||
alias_attribute :post, :commentable
|
alias_attribute :post, :commentable
|
||||||
belongs_to :author, :class_name => 'Person'
|
belongs_to :author, :class_name => 'Person'
|
||||||
|
has_one :participation, :dependent => :destroy, :foreign_key => :target_id, :primary_key => :commentable_id
|
||||||
|
|
||||||
delegate :name, to: :author, prefix: true
|
delegate :name, to: :author, prefix: true
|
||||||
delegate :comment_email_subject, to: :parent
|
delegate :comment_email_subject, to: :parent
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ class Like < Federated::Relayable
|
||||||
{:target => @target, :positive => true}
|
{:target => @target, :positive => true}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
has_one :participation, :dependent => :destroy, :foreign_key => :target_id, :primary_key => :target_id
|
||||||
|
|
||||||
after_commit :on => :create do
|
after_commit :on => :create do
|
||||||
self.parent.update_likes_counter
|
self.parent.update_likes_counter
|
||||||
|
|
|
||||||
108
features/activity_stream.feature
Normal file
108
features/activity_stream.feature
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
@javascript
|
||||||
|
Feature: The activity stream
|
||||||
|
Background:
|
||||||
|
Given following users exist:
|
||||||
|
| username | email |
|
||||||
|
| Bob Jones | bob@bob.bob |
|
||||||
|
| Alice Smith | alice@alice.alice |
|
||||||
|
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
||||||
|
When "alice@alice.alice" has posted a status message with a photo
|
||||||
|
|
||||||
|
Scenario: Sorting
|
||||||
|
When I sign in as "bob@bob.bob"
|
||||||
|
|
||||||
|
And I post "A- I like turtles"
|
||||||
|
And I wait for 1 second
|
||||||
|
And I post "B- barack obama is your new bicycle"
|
||||||
|
And I wait for 1 second
|
||||||
|
And I post "C- barack obama is a square"
|
||||||
|
And I wait for 1 second
|
||||||
|
|
||||||
|
When I go to the activity stream page
|
||||||
|
Then "C- barack obama is a square" should be post 1
|
||||||
|
And "B- barack obama is your new bicycle" should be post 2
|
||||||
|
And "A- I like turtles" should be post 3
|
||||||
|
|
||||||
|
When I like the post "A- I like turtles"
|
||||||
|
And I wait for 1 second
|
||||||
|
And I comment "Sassy sawfish" on "C- barack obama is a square"
|
||||||
|
And I wait for 1 second
|
||||||
|
And I like the post "B- barack obama is your new bicycle"
|
||||||
|
And I wait for 1 second
|
||||||
|
|
||||||
|
When I go to the activity stream page
|
||||||
|
Then "B- barack obama is your new bicycle" should be post 1
|
||||||
|
And "C- barack obama is a square" should be post 2
|
||||||
|
And "A- I like turtles" should be post 3
|
||||||
|
|
||||||
|
Scenario: delete a comment
|
||||||
|
When I sign in as "bob@bob.bob"
|
||||||
|
And I am on "alice@alice.alice"'s page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
When I focus the comment field
|
||||||
|
And I fill in the following:
|
||||||
|
| text | is that a poodle? |
|
||||||
|
And I press "Comment"
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
|
When I go to the activity stream page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
And I should see "is that a poodle?"
|
||||||
|
|
||||||
|
When I am on "alice@alice.alice"'s page
|
||||||
|
And I hover over the ".comment"
|
||||||
|
And I preemptively confirm the alert
|
||||||
|
And I click to delete the first comment
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should not see "Look at this dog"
|
||||||
|
|
||||||
|
Scenario: unliking a post
|
||||||
|
When I sign in as "bob@bob.bob"
|
||||||
|
And I am on "alice@alice.alice"'s page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I like the post "Look at this dog"
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I am on "alice@alice.alice"'s page
|
||||||
|
And I unlike the post "Look at this dog"
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should not see "Look at this dog"
|
||||||
|
|
||||||
|
Scenario: multiple participations
|
||||||
|
When I sign in as "bob@bob.bob"
|
||||||
|
And I am on "alice@alice.alice"'s page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I like the post "Look at this dog"
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I am on "alice@alice.alice"'s page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I focus the comment field
|
||||||
|
And I fill in the following:
|
||||||
|
| text | is that a poodle? |
|
||||||
|
And I press "Comment"
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I am on "alice@alice.alice"'s page
|
||||||
|
And I unlike the post "Look at this dog"
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should see "Look at this dog"
|
||||||
|
|
||||||
|
When I am on "alice@alice.alice"'s page
|
||||||
|
And I hover over the ".comment"
|
||||||
|
And I preemptively confirm the alert
|
||||||
|
And I click to delete the first comment
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
|
And I go to the activity stream page
|
||||||
|
Then I should not see "Look at this dog"
|
||||||
|
|
@ -2,6 +2,14 @@ When /^I (?:like|unlike) the post "([^"]*)" in the stream$/ do |post_text|
|
||||||
like_stream_post(post_text)
|
like_stream_post(post_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I should see an image in the publisher$/ do
|
||||||
|
photo_in_publisher.should be_present
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I (un)?like the post "([^"]*)"$/ do |negate, post_text|
|
||||||
|
negate ? unlike_post(post_text) : like_post(post_text)
|
||||||
|
end
|
||||||
|
|
||||||
Then /^"([^"]*)" should be post (\d+)$/ do |post_text, position|
|
Then /^"([^"]*)" should be post (\d+)$/ do |post_text, position|
|
||||||
stream_element_numbers_content(position).should have_content(post_text)
|
stream_element_numbers_content(position).should have_content(post_text)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,12 @@ module PublishingCukeHelpers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unlike_post(post_text)
|
||||||
|
within_post(post_text) do
|
||||||
|
find(:css, 'a.unlike').click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def stream_posts
|
def stream_posts
|
||||||
all('.stream_element')
|
all('.stream_element')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue