Sha256: f6182635e9b93fb68866461397daa24280f0dcb0216bad1d6d4bddd1489a62cd

Contents?: true

Size: 827 Bytes

Versions: 4

Compression:

Stored size: 827 Bytes

Contents

require 'isolation/abstract_unit'
require 'rails-observers'

class ConsoleTest < ActiveSupport::TestCase
  include ActiveSupport::Testing::Isolation

  def setup
    build_app
    boot_rails
  end

  def teardown
    teardown_app
  end

  def load_environment
    require "#{rails_root}/config/environment"
    Rails.application.sandbox = false
    Rails.application.load_console
  end

  def test_active_record_does_not_panic_when_referencing_an_observed_constant
    add_to_config "config.active_record.observers = :user_observer"

    app_file "app/models/user.rb", <<-MODEL
      class User < ActiveRecord::Base
      end
    MODEL

    app_file "app/models/user_observer.rb", <<-MODEL
      class UserObserver < ActiveRecord::Observer
      end
    MODEL

    load_environment
    assert_nothing_raised { User }
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rails-observers-0.1.2/test/console_test.rb
rails-observers-0.1.2 test/console_test.rb
rails-observers-0.1.1 test/console_test.rb
rails-observers-0.1.0 test/console_test.rb