This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,67 @@ | ||
require 'spec_helper' | ||
|
||
describe "Actor" do | ||
|
||
let(:enquiry) { Enquiry.create(:comment => "I'm interested") } | ||
let(:listing) { Listing.create(:title => "A test listing") } | ||
let(:user) { User.create(:full_name => "Christos") } | ||
|
||
|
||
new_activities = [:new_enquiry, :new_enquiry_without_cache] | ||
|
||
before :all do | ||
Activity.activity :new_comment do | ||
actor :user, :cache => [:full_name] | ||
object :listing, :cache => [:title] | ||
target :listing, :cache => [:title] | ||
end | ||
end | ||
|
||
describe "#publish_activity" do | ||
|
||
before :each do | ||
5.times { |n| User.create(:full_name => "Receiver #{n}") } | ||
end | ||
|
||
it "pushes activity to receivers" do | ||
activity = user.publish_activity(:new_enquiry, :object => enquiry, :target => listing) | ||
activity.receivers.size == 6 | ||
end | ||
|
||
it "pushes to a defined stream" do | ||
activity = user.publish_activity(:new_enquiry, :object => enquiry, :target => listing, :receivers => :friends) | ||
activity.receivers.size == 6 | ||
|
||
Activity.activity :new_enquiry_without_cache do | ||
actor :user | ||
object :enquiry | ||
object :listing | ||
target :listing | ||
end | ||
|
||
end | ||
|
||
describe "#activity_stream" do | ||
|
||
before :each do | ||
5.times { |n| User.create(:full_name => "Receiver #{n}") } | ||
user.publish_activity(:new_enquiry, :object => enquiry, :target => listing) | ||
user.publish_activity(:new_comment, :object => listing) | ||
end | ||
|
||
it "retrieves the stream for an actor" do | ||
user.activity_stream.size.should eq 2 | ||
|
||
new_activities.each do |new_activity| | ||
describe "#publish_activity" do | ||
before :each do | ||
5.times { |n| User.create(:full_name => "Receiver #{n}") } | ||
end | ||
|
||
it "pushes activity to receivers" do | ||
activity = user.publish_activity(new_activity, :object => enquiry, :target => listing) | ||
activity.receivers.size == 6 | ||
end | ||
|
||
it "pushes to a defined stream" do | ||
activity = user.publish_activity(new_activity, :object => enquiry, :target => listing, :receivers => :friends) | ||
activity.receivers.size == 6 | ||
end | ||
end | ||
|
||
it "retrieves the stream and filters to a particular activity type" do | ||
user.activity_stream(:type => :new_comment).size.should eq 1 | ||
|
||
end | ||
|
||
new_activities.each do |new_activity| | ||
describe "#activity_stream" do | ||
|
||
before :each do | ||
5.times { |n| User.create(:full_name => "Receiver #{n}") } | ||
user.publish_activity(new_activity, :object => enquiry, :target => listing) | ||
user.publish_activity(:new_comment, :object => listing) | ||
end | ||
|
||
it "retrieves the stream for an actor" do | ||
user.activity_stream.size.should eq 2 | ||
end | ||
|
||
it "retrieves the stream and filters to a particular activity type" do | ||
user.activity_stream(:type => :new_comment).size.should eq 1 | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
|
||
|
||
end |