Sha256: 827c04e9145ee1127921b4b5489fd16d0aedcf7fa7213065719b927f31facb06

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class ActivityTest < ActiveSupport::TestCase

  context 'An Activity' do
    
    should_validate_presence_of :source
    
    should_belong_to :item
    should_belong_to :source
    should_have_many :activity_feeds
    
    should_have_named_scope :since
    should_have_named_scope :before
    should_have_named_scope :recent
    should_have_named_scope :only_public

  end

  should "require template or item" do
    activity = Factory.build(:activity, :template => nil, :item => nil)
    assert !activity.valid?
  end

  should "get the partial from the template" do
    template = 'status_update'
    activity = Factory(:activity, :template => template, :item => nil)
    assert activity.partial == template, "The activity partial was not set to the specified template"
  end

  should "get the partial from the item" do
    user = Factory(:user)
    activity = Factory(:activity, :item => user, :template => nil)
    assert activity.partial == user.class.name.underscore
  end

  should "be able to edit the activity" do
    user = Factory(:user)
    activity = Factory(:activity, :source => user)
    assert activity.can_edit?(user)
  end
  
  should "not be able to edit the activity" do
    user = Factory(:user)
    activity = Factory(:activity)
    assert !activity.can_edit?(user)
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muck-activity-0.1.2 test/unit/activity_test.rb
muck-activity-0.1.1 test/unit/activity_test.rb