Sha256: 9db61117ef2855bfc02d50306babdbb31f67ddd820725bba8242fba58864dad0

Contents?: true

Size: 1.6 KB

Versions: 9

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'

describe Socialization::Mentionable do
  before(:all) do
    use_ar_store
    @mentioner = ImAMentioner.new
    @mentionable = ImAMentionable.create
  end

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

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

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

    it "calls $Mention.mentions?" do
      expect($Mention).to receive(:mentions?).with(@mentioner, @mentionable).once
      @mentionable.mentioned_by?(@mentioner)
    end
  end

  describe "#mentioners" do
    it "calls $Mention.mentioners" do
      expect($Mention).to receive(:mentioners).with(@mentionable, @mentioner.class, { :foo => :bar })
      @mentionable.mentioners(@mentioner.class, { :foo => :bar })
    end
  end

  describe "#mentioners_relation" do
    it "calls $Mention.mentioners" do
      expect($Mention).to receive(:mentioners_relation).with(@mentionable, @mentioner.class, { :foo => :bar })
      @mentionable.mentioners_relation(@mentioner.class, { :foo => :bar })
    end
  end

  describe "deleting a mentionable" do
    before(:all) do
      @mentioner = ImAMentioner.create
      @mentioner.mention!(@mentionable)
    end

    it "removes mention relationships" do
      expect(Socialization.mention_model).to receive(:remove_mentioners).with(@mentionable)
      @mentionable.destroy
    end
  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

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