Sha256: 9f46c9003e34c5c29452b266b91a1f4f24e76ddfa388d6be87cc42e3b1775f1a

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

# Copyright 2011-2012 Rice University. Licensed under the Affero General Public 
# License version 3 or later.  See the COPYRIGHT file for details.

require 'test_helper'

class CommentThreadTest < ActiveSupport::TestCase

  test 'cannot mass-assign commentable, comments and comment_thread_subscriptions' do
    sq = FactoryGirl.create(:simple_question)
    c = [FactoryGirl.create(:comment)]
    cts = [FactoryGirl.create(:comment_thread_subscription)]
    ct = CommentThread.new(:commentable => sq,
                           :comments => c,
                           :comment_thread_subscriptions => cts)
    assert ct.commentable != sq
    assert ct.comments != c
    assert ct.comment_thread_subscriptions != cts
  end

  test 'clear' do
    u = FactoryGirl.create(:user)
    q = FactoryGirl.create(:simple_question)
    ct = q.comment_thread
    c = Comment.new
    c.comment_thread = ct
    c.creator = u
    c.save!

    assert !q.comment_thread.comments.empty?
    assert_equal q.comment_thread, ct

    ct.clear!
    q.reload

    assert q.comment_thread.comments.empty?
    assert q.comment_thread != ct
  end

  test 'subscribe' do
    u = FactoryGirl.create(:user)
    ct = FactoryGirl.create(:comment_thread)

    assert !ct.subscription_for(u)
    assert ct.subscribe!(u)
    assert ct.subscription_for(u)
    assert ct.subscribe!(u)
  end

  test 'unsubscribe' do
    u = FactoryGirl.create(:user)
    ct = FactoryGirl.create(:comment_thread)

    assert !ct.unsubscribe!(u)
    assert ct.subscribe!(u)
    assert ct.subscription_for(u)
    assert ct.unsubscribe!(u)
    assert !ct.subscription_for(u)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
commontator-0.4.1 test/unit/comment_thread_test.rb~
commontator-0.3.10 test/unit/comment_thread_test.rb~
commontator-0.2.4 test/unit/comment_thread_test.rb~
commontator-0.2.0 test/unit/comment_thread_test.rb~
commontator-0.1.46 test/unit/comment_thread_test.rb~