Sha256: cfdb5230c533cf0bd61d367bb9c0e6d6cf99ab26a62d166682c4515ec31b8f83

Contents?: true

Size: 1.44 KB

Versions: 104

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Like do

  describe "activity" do
    before do
      @like_activity = Factory(:like_activity)
      @activity = @like_activity.parent
    end

    it "should recognize the user who likes it" do
      assert @activity.liked_by?(@like_activity.sender)
    end

    it "should not recognize the user who does not like it" do
      assert ! @activity.liked_by?(Factory(:user))
    end
  end

  describe "actor" do
    shared_examples_for "creates activity" do
      it "should recognize the user who likes it" do
        Like.build(@sender, @sender, @receiver).save

        assert @receiver.liked_by?(@sender)
      end

      it "should increment like count" do
        count = @receiver.like_count

        Like.build(@sender, @sender, @receiver).save

        @receiver.like_count.should eq(count + 1)
      end

      it "should decrement like count" do
        @like = Like.build(@sender, @sender, @receiver)
        @like.save

        count = @receiver.like_count

        @like.destroy

        @receiver.like_count.should eq(count - 1)
      end
    end

    context "friend" do
      before do
        tie = Factory(:friend)
        @sender = tie.sender
        @receiver = tie.receiver
      end

      it_should_behave_like "creates activity"
    end

    context "alien" do
      before do
        @sender, @receiver = 2.times.map{ Factory(:user) }
      end

      it_should_behave_like "creates activity"
    end
  end
end


Version data entries

104 entries across 104 versions & 2 rubygems

Version Path
social_stream-1.1.12 base/spec/models/like_spec.rb
social_stream-base-1.1.11 spec/models/like_spec.rb
social_stream-1.1.11 base/spec/models/like_spec.rb
social_stream-base-1.1.10 spec/models/like_spec.rb
social_stream-1.1.10 base/spec/models/like_spec.rb
social_stream-base-1.1.9 spec/models/like_spec.rb
social_stream-1.1.9 base/spec/models/like_spec.rb
social_stream-base-1.1.8 spec/models/like_spec.rb
social_stream-1.1.8 base/spec/models/like_spec.rb
social_stream-base-1.1.7 spec/models/like_spec.rb
social_stream-1.1.7 base/spec/models/like_spec.rb
social_stream-base-1.1.6 spec/models/like_spec.rb
social_stream-1.1.6 base/spec/models/like_spec.rb
social_stream-base-1.1.5 spec/models/like_spec.rb
social_stream-1.1.5 base/spec/models/like_spec.rb
social_stream-base-1.1.4 spec/models/like_spec.rb
social_stream-1.1.4 base/spec/models/like_spec.rb
social_stream-1.1.3 base/spec/models/like_spec.rb
social_stream-base-1.1.3 spec/models/like_spec.rb
social_stream-1.1.2 base/spec/models/like_spec.rb