Sha256: 1efb8dc37aac906b26292fc894d0f8e3560e03876ce91a084b02cb759b49a2d0

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe 'ActivityFeed::Item' do
  it 'should allow you to create a new Item' do
    item = Fabricate.build(ActivityFeed.persistence)
    item.save.should be_true
  end
  
  it 'should allow for a large amount of text' do
    item = Fabricate.build(ActivityFeed.persistence, :text => '*' * 8192)
    item.text.should eql('*' * 8192)
  end
  
  it 'should add the feed item ID to redis' do
    item = Fabricate.build(ActivityFeed.persistence)
          
    ActivityFeed.redis.zcard("#{ActivityFeed.namespace}:#{ActivityFeed.key}:#{item.user_id}").should be(0)
    item.save
    ActivityFeed.redis.zcard("#{ActivityFeed.namespace}:#{ActivityFeed.key}:#{item.user_id}").should be(1)
  end
  
  it 'should have default attributes for .title .url .icon and .sticky' do
    item = Fabricate.build(ActivityFeed.persistence)
    
    item.title.should eql('item title')
    item.url.should eql('http://url')
    item.icon.should eql('http://icon')
    item.sticky.should be_false
  end
  
  it 'should not create a new item in Redis after saving, only on create' do
    item = Fabricate.build(ActivityFeed::Memory::Item)
    
    ActivityFeed.redis.zcard("#{ActivityFeed.namespace}:#{ActivityFeed.key}:#{item.user_id}").should be(0)
    item.save
    ActivityFeed.redis.zcard("#{ActivityFeed.namespace}:#{ActivityFeed.key}:#{item.user_id}").should be(1)
    
    item.text = 'updated text'
    item.save
    ActivityFeed.redis.zcard("#{ActivityFeed.namespace}:#{ActivityFeed.key}:#{item.user_id}").should be(1)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activity_feed-1.1.1 spec/item_spec.rb
activity_feed-1.1.0 spec/item_spec.rb
activity_feed-1.0.0 spec/item_spec.rb