Sha256: b3237bc35fa2ab2067de74bf8a90641be7a37797083859e9407c6329d1e51c60

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

require 'test_setup'

class CompanyTest < MiniTest::Unit::TestCase

  include InterTest

  Company = IntercomRails::Proxy::Company
  DUMMY_COMPANY = dummy_company

  def test_finds_current_company
    IntercomRails.config.company.current = Proc.new { @app }
    object_with_app_instance_var = Object.new 
    object_with_app_instance_var.instance_variable_set(:@app, DUMMY_COMPANY)

    c = Company.current_in_context(object_with_app_instance_var)
    assert_equal true, c.valid?
    expected_hash = {:id => '6', :name => 'Intercom'}
    assert_equal expected_hash, c.to_hash
  end

  def test_whiny_nil
    NilClass.class_eval do
      def id
        raise ArgumentError, "boo"
      end
    end

    search_object = nil 
    assert_equal false, Company.new(search_object).valid?
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
intercom-rails-0.2.2 test/intercom-rails/proxy/company_test.rb
intercom-rails-0.2.1 test/intercom-rails/proxy/company_test.rb