Sha256: 12b3f9721cbcb844503c809f2f12c0dc52d10d353bca6448102c5ec867c93d0d

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe ActsAsAmico do

  describe "non-pending" do
    before :each do
      @user = add_reciprocal_followers
    end

    it 'should page #following correctly' do
      @user.following(:page => 1, :page_size => 5).size.should be(5)
    end

    it 'should page #following correctly' do
      @user.followers(:page => 1, :page_size => 5).size.should be(5)
    end
    it 'should page #reciprocated correctly' do
      @user.reciprocated(:page => 1, :page_size => 5).size.should be(5)
    end
    it "should return all following" do
      @user.get_all(:following).size.should be(6)
    end
  end

  describe "pending operations" do
    before :each do
      Amico.pending_follow = true
      @user = add_reciprocal_followers
    end
    after :all do
      Amico.pending_follow = false
    end

    it 'should page correctly' do
      @user.pending(:page => 1, :page_size => 5).size.should be(5)
    end
    it 'should return the correct count' do
      @user.pending_page_count.should be(1)
      @user.pending_page_count(2).should be(3)
    end
  end

  describe "pending operations" do
    before :each do
      @user = add_reciprocal_followers 6, true
      Amico.pending_follow = true
    end
    after :all do
      Amico.pending_follow = false
    end
    it 'should page #blocked correctly' do
      @user.blocked(:page => 1, :page_size => 5).size.should be(5)
    end
  end

  private

  def add_reciprocal_followers(count = 6, block_relationship = false)
    user = Factory :user
    1.upto(count) do
      inner_user = Factory :user
      user.follow! inner_user
      inner_user.follow! user
      if block_relationship
        user.block! inner_user
        inner_user.block! user
      end
    end
    user
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts_as_amico-0.2.8 spec/reciprocal_followers.rb
acts_as_amico-0.2.7 spec/reciprocal_followers.rb
acts_as_amico-0.2.6 spec/reciprocal_followers.rb
acts_as_amico-0.2.4 spec/reciprocal_followers.rb