Sha256: cdfa56aa6dd088fa533ea0e7b516bf8e85efac7af35bb21fc44cba484751358c

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

require 'spec_helper'

module Commontator
  describe Subscription do
    before do
      setup_model_spec
      @subscription = Subscription.new
      @subscription.thread = @thread
      @subscription.subscriber = @user
      @subscription.save!
    end
    
    it 'must count unread comments' do
      @subscription.unread_comments.count.must_equal 0
      
      comment = Comment.new
      comment.thread = @thread
      comment.creator = @user
      comment.body = 'Something'
      comment.save!
      
      @subscription.reload.unread_comments.count.must_equal 1
      
      comment = Comment.new
      comment.thread = @thread
      comment.creator = @user
      comment.body = 'Something else'
      comment.save!
      
      @subscription.reload.unread_comments.count.must_equal 2
      
      @subscription.touch
      
      @subscription.reload.unread_comments.count.must_equal 0
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
commontator-4.10.3 spec/app/models/commontator/subscription_spec.rb
commontator-4.10.2 spec/app/models/commontator/subscription_spec.rb
commontator-4.10.1 spec/app/models/commontator/subscription_spec.rb
commontator-4.10.0 spec/app/models/commontator/subscription_spec.rb
commontator-4.9.0 spec/app/models/commontator/subscription_spec.rb