Sha256: c86889e8db62a7679b133bf25c8d807c48b72b6ff6210f47ee485b745587c516
Contents?: true
Size: 1.68 KB
Versions: 8
Compression:
Stored size: 1.68 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 should_have_named_scope :filter_by_template 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 should "filter the activities by template" do @template_name = 'test_template' user = Factory(:user) activity = Factory(:activity, :source => user, :template => @template_name) user.activities << activity assert user.activities.filter_by_template(@template_name).include?(activity) end end
Version data entries
8 entries across 8 versions & 2 rubygems