Sha256: 833bb22771a550f147f804e27453dc762191b32c76de7bb42fe544e5653a3ae6

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

describe 'activity feeds' do
  before(:each) do
    ChalkDust::ActivityItem.delete_all
  end

  describe '.activity_feed_for' do
    it 'returns activity feed for given object' do
      kris    = User.create!
      lindsey = User.create!
      hallie  = User.create!
      post    = Post.create!
      comment = Comment.create!

      activity_item_1 = ChalkDust::ActivityItem.create(:performer => kris,
                          :event     => 'editted',
                          :target    => post,
                          :owner     => hallie)

      activity_item_2 = ChalkDust::ActivityItem.create(:performer => lindsey,
                          :event     => 'added',
                          :target    => comment,
                          :owner     => hallie)

      activity_items = ChalkDust.activity_feed_for(hallie)
      activity_items.should == [activity_item_1, activity_item_2]
    end

    describe 'options' do
      it ':since limits to activities created since the given date' do
        kris    = User.create!
        lindsey = User.create!
        hallie  = User.create!
        post    = Post.create!
        comment = Comment.create!

        activity_item_1 = ChalkDust::ActivityItem.create(:performer => kris,
                            :event     => 'editted',
                            :target    => post,
                            :owner     => hallie,
                            :created_at => 2.months.ago)

        activity_item_2 = ChalkDust::ActivityItem.create(:performer => lindsey,
                            :event     => 'added',
                            :target    => comment,
                            :owner     => hallie)

        activity_items = ChalkDust.activity_feed_for(hallie, :since => Time.now - 1.week)
        activity_items.should == [activity_item_2]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chalk_dust-0.0.2 spec/lib/chalk_dust/activity_feeds_spec.rb
chalk_dust-0.0.1 spec/lib/chalk_dust/activity_feeds_spec.rb