Sha256: 5cba5572f72a6c219cc9b28e2cb6f6d2ee574254f234c253ce37ea8f17ffe2e3

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe Socialization::Followable do
  before(:all) do
    use_ar_store
    @follower = ImAFollower.new
    @followable = ImAFollowable.create
  end

  describe "#is_followable?" do
    it "returns true" do
      expect(@followable.is_followable?).to be true
    end
  end

  describe "#followable?" do
    it "returns true" do
      expect(@followable.followable?).to be true
    end
  end

  describe "#followed_by?" do
    it "does not accept non-followers" do
      expect { @followable.followed_by?(:foo) }.to raise_error(Socialization::ArgumentError)
    end

    it "calls $Follow.follows?" do
      expect($Follow).to receive(:follows?).with(@follower, @followable).once
      @followable.followed_by?(@follower)
    end
  end

  describe "#followers" do
    it "calls $Follow.followers" do
      expect($Follow).to receive(:followers).with(@followable, @follower.class, { :foo => :bar })
      @followable.followers(@follower.class, { :foo => :bar })
    end
  end

  describe "#followers_relation" do
    it "calls $Follow.followers_relation" do
      expect($Follow).to receive(:followers_relation).with(@followable, @follower.class, { :foo => :bar })
      @followable.followers_relation(@follower.class, { :foo => :bar })
    end
  end

  describe "deleting a followable" do
    before(:all) do
      @follower = ImAFollower.create
      @follower.follow!(@followable)
    end

    it "removes follow relationships" do
      expect(Socialization.follow_model).to receive(:remove_followers).with(@followable)
      @followable.destroy
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
socialization-2.0.2 spec/victims/followable_spec.rb
socialization-2.0.1 spec/victims/followable_spec.rb
socialization-2.0.0 spec/victims/followable_spec.rb
socialization-1.2.3 spec/victims/followable_spec.rb
socialization-1.2.2 spec/victims/followable_spec.rb
socialization-1.2.1 spec/victims/followable_spec.rb
twrk-socialization-1.2.0 spec/victims/followable_spec.rb
twrk-socialization-0.0.1 spec/victims/followable_spec.rb
socialization-1.2.0 spec/victims/followable_spec.rb