Sha256: 57a1d36f61ca3007108b153bfb61d71dc9b499ceeae533e09fd4d839f0eb603f

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

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

class FollowableTest < Test::Unit::TestCase
  context "Followable" do
    setup do
      @follower = ImAFollower.new
      @followable = ImAFollowable.create
    end

    context "#is_followable?" do
      should "return true" do
        assert_true @followable.is_followable?
      end
    end

    context "#followable?" do
      should "return true" do
        assert_true @followable.followable?
      end
    end

    context "#followed_by?" do
      should "not accept non-followers" do
        assert_raise(Socialization::ArgumentError) { @followable.followed_by?(:foo) }
      end

      should "call $Follow.follows?" do
        $Follow.expects(:follows?).with(@follower, @followable).once
        @followable.followed_by?(@follower)
      end
    end

    context "#followers" do
      should "call $Follow.followers" do
        $Follow.expects(:followers).with(@followable, @follower.class, { :foo => :bar })
        @followable.followers(@follower.class, { :foo => :bar })
      end
    end

    context "#followers_relation" do
      should "call $Follow.followers_relation" do
        $Follow.expects(:followers_relation).with(@followable, @follower.class, { :foo => :bar })
        @followable.followers_relation(@follower.class, { :foo => :bar })
      end
    end

    context "deleting a followable" do
      setup do
        @follower = ImAFollower.create
        @follower.follow!(@followable)
      end

      should "remove follow relationships" do
        Socialization.follow_model.expects(:remove_followers).with(@followable)
        @followable.destroy
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
socialization-1.1.0 test/victims/followable_test.rb
socialization-1.0.0 test/victims/followable_test.rb