Sha256: 0bf00ee2c8ced5677569f81a493fe7de419eb48e2b537899af516c5e27a8ace3

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

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

class FollowTest < Test::Unit::TestCase
  def setup
    @u_john  = User.create :name => 'John Doe'
    @u_jane  = User.create :name => 'Jane Doe'
    @c_chuck = Celebrity.create :name => 'Chuck Norris'
    @c_uma   = Celebrity.create :name => 'Uma Thurman'
    @c_rick  = Celebrity.create :name => 'Rick Astley'
  end

  def test_the_world
    assert @u_john.is_follower?
    assert @c_chuck.is_followable?

    assert @u_john.follow!(@c_rick)
    assert @u_john.follow!(@c_chuck)
    assert @u_jane.follow!(@c_rick)

    assert_equal true, @u_john.follows?(@c_chuck)
    assert_equal true, @u_john.follows?(@c_rick)
    assert_equal true, @c_chuck.followed_by?(@u_john)

    assert @c_uma.followers.empty?

    # can't have duplicate follows
    assert_raise ActiveRecord::RecordInvalid do
      @u_john.follow!(@c_rick)
    end
  end

  def test_user_following_user
    @u_john.follow!(@u_jane)
    assert_equal true,  @u_john.follows?(@u_jane)
    assert_equal false, @u_jane.follows?(@u_john)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socialization-0.2.0 test/follow_test.rb