Sha256: d4c3c22956f0771e81b474f49ab5c64cdabe223924ca65760019064b83ed473a

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Tie do
  describe "follower_count" do
    it "should be incremented" do
      sender, receiver = 2.times.map{ Factory(:user) }

      count = receiver.follower_count

      follower_relation = sender.
                          relation_customs.
                          joins(:permissions).
                          merge(Permission.follow).
                          first

      Tie.create :contact_id => sender.contact_to!(receiver).id,
                 :relation_id => follower_relation.id

      receiver.reload.follower_count.should eq(count + 1)
    end
    
    it "should be decremented" do
      tie = Factory(:friend)
      contact = tie.contact
      receiver = tie.receiver
      count = receiver.follower_count

      contact.reload.relation_ids = []

      receiver.reload.follower_count.should eq(count - 1)
    end
  end

  describe "friend" do
    before do
      @tie = Factory(:friend)
    end

    it "should create pending" do
      @tie.receiver.received_contacts.pending.should be_present
    end
  end

  describe "with public relation" do
    it "should not create activity" do
      count = Activity.count

      Factory(:public)

      Activity.count.should eq(count)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
social_stream-base-0.7.2 spec/models/tie_spec.rb
social_stream-base-0.7.1 spec/models/tie_spec.rb
social_stream-base-0.7.0 spec/models/tie_spec.rb