Sha256: 107015f9a2c0366816a34b38cc93920098959502e64dd84d1dd7b6115a1cf2eb

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

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

class MentionableTest < Test::Unit::TestCase
  context "Mentionable" do
    setup do
      @mentioner = ImAMentioner.new
      @mentionable = ImAMentionable.create
    end

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

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

    context "#mentioned_by?" do
      should "not accept non-mentioners" do
        assert_raise(ArgumentError) { @mentionable.mentioned_by?(:foo) }
      end

      should "call $Mention.mentions?" do
        $Mention.expects(:mentions?).with(@mentioner, @mentionable).once
        @mentionable.mentioned_by?(@mentioner)
      end
    end

    context "#mentioners" do
      should "call $Mention.mentioners" do
        $Mention.expects(:mentioners).with(@mentionable, @mentioner.class, { :foo => :bar })
        @mentionable.mentioners(@mentioner.class, { :foo => :bar })
      end
    end

    context "#mentioners_relation" do
      should "call $Mention.mentioners" do
        $Mention.expects(:mentioners_relation).with(@mentionable, @mentioner.class, { :foo => :bar })
        @mentionable.mentioners_relation(@mentioner.class, { :foo => :bar })
      end
    end

    context "deleting a mentionable" do
      setup do
        @mentioner = ImAMentioner.create
        @mentioner.mention!(@mentionable)
      end

      should "remove mention relationships" do
        Socialization.mention_model.expects(:remove_mentioners).with(@mentionable)
        @mentionable.destroy
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socialization-0.5.0.beta4 test/victims/mentionable_test.rb