Sha256: 5677ed73c13753649328a0ca4af929ccf862036a3438a8623979fd4b77321856

Contents?: true

Size: 1.99 KB

Versions: 15

Compression:

Stored size: 1.99 KB

Contents

defined?(TEST_HELPER_LOADED) ? raise("can not load #{__FILE__} twice") : TEST_HELPER_LOADED = true

def rails_root
  dir = File.expand_path(File.dirname(__FILE__) + "/../..")
  while dir = File.dirname(dir) and dir != '/' do
    return dir if File.exists?("#{dir}/config/environment.rb")
  end
end

ENV["RAILS_ENV"] = "test"
dir = File.dirname(__FILE__)
require "#{rails_root}/config/environment.rb"

require 'matchy'
require 'test_help'
require 'action_view/test_case'
require 'with'
require 'with-sugar'

require 'globalize/i18n/missing_translations_raise_handler'
I18n.exception_handler = :missing_translations_raise_handler

class ActiveSupport::TestCase
  include RR::Adapters::TestUnit

  setup :start_db_transaction!
  setup :setup_page_caching!
  setup :set_locale!
  setup :ensure_single_site_mode!

  teardown :rollback_db_transaction!
  teardown :clear_cache_dir!
  teardown :rollback_multi_site_mode!
  
  setup do
    @default_permissions = Rbac::Context.default_permissions.dup
  end

  teardown do
    Rbac::Context.default_permissions = @default_permissions
  end
  
  
  def set_locale!
    I18n.locale = nil
    I18n.default_locale = :en
  end

  def stub_paperclip_post_processing!
    stub.proxy(Paperclip::Attachment).new { |attachment| stub(attachment).post_process }
  end
end

# include this line to test adva-cms with url_history installed
# require dir + '/plugins/url_history/init_url_history'

# reset locales in case client apps set them in the environment
I18n.default_locale = :en
I18n.locale = nil

require_all dir + "/contexts.rb",
            dir + "/test_helper/**/*.rb"
require_all dir + "/../../*/test/contexts.rb",
            dir + "/../../*/test/test_helper/**/*.rb"

if DO_PREPARE_DATABASE
  puts 'Preparing the database ...'
  # load "#{Rails.root}/db/schema.rb"
  require_all dir + "/fixtures.rb"
  require_all dir + "/../../*/test/fixtures.rb"
  
  ActiveSupport::TestCase.setup :clear_tmp_dir!
end

require "#{Rails.root}/test/test_helper.rb" if File.exists?("#{Rails.root}/test/test_helper.rb")

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
adva-0.3.2 test/test_helper.rb
adva-0.3.1 test/test_helper.rb
adva-0.3.0 test/test_helper.rb
adva-0.2.4 test/test_helper.rb
adva-0.2.3 test/test_helper.rb
adva-0.2.2 test/test_helper.rb
adva-0.2.1 test/test_helper.rb
adva-0.2.0 test/test_helper.rb
adva-0.1.4 test/test_helper.rb
adva-0.1.3 test/test_helper.rb
adva-0.1.2 test/test_helper.rb
adva-0.1.1 test/test_helper.rb
adva-0.1.0 test/test_helper.rb
adva_cms-0.0.1 test/test_helper.rb
adva-0.0.1 adva_cms/test/test_helper.rb