test/rails_root/test/unit/activity_test.rb in muck-activities-0.1.16 vs test/rails_root/test/unit/activity_test.rb in muck-activities-0.1.17
- old
+ new
@@ -21,10 +21,12 @@
setup do
@old_activity = Factory(:activity, :created_at => 6.weeks.ago)
@new_activity = Factory(:activity)
@status_activity = Factory(:activity, :template => 'status')
@other_activity = Factory(:activity, :template => 'other')
+ @private_activity = Factory(:activity, :is_public => false)
+ @public_activity = Factory(:activity, :is_public => true)
end
context "before" do
should "only find old activity" do
activities = Activity.before(1.week.ago)
assert activities.include?(@old_activity), "since didn't find older activity"
@@ -43,10 +45,17 @@
activities = Activity.filter_by_template('status')
assert activities.include?(@status_activity), "since didn't find status activity"
assert !activities.include?(@other_activity), "since found other activity"
end
end
+ context "public" do
+ should "only find public activities" do
+ activities = Activity.only_public
+ assert activities.include?(@public_activity), "only_public didn't find public activity"
+ assert !activities.include?(@private_activity), "only_public found private activity"
+ end
+ end
end
should "require template or item" do
activity = Factory.build(:activity, :template => nil, :item => nil)
assert !activity.valid?
@@ -94,8 +103,25 @@
user2.activities << activity2
assert user.activities.created_by(user).include?(activity)
assert !user.activities.created_by(user).include?(activity2)
+ end
+
+ context "comments" do
+ setup do
+ @user = Factory(:user)
+ @activity = Factory(:activity)
+ @comment = @activity.comments.build(:body => 'a test comment')
+ @comment.user = @user
+ @comment.save!
+ end
+ should "have comments" do
+ assert_equal 1, @activity.comments.length
+ end
+ should "have comment cache" do
+ @activity.reload
+ assert_equal 1, @activity.comment_count
+ end
end
end
\ No newline at end of file