From 57d1382013c85a7b11ac8ce5e683f6006b12b328 Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 14 Jan 2010 22:21:43 +0100 Subject: Updated globalize2 to latest version. Modified existing code accoringly --- vendor/plugins/globalize2/test/test_helper.rb | 70 +++++++++++++++++++++------ 1 file changed, 55 insertions(+), 15 deletions(-) (limited to 'vendor/plugins/globalize2/test/test_helper.rb') diff --git a/vendor/plugins/globalize2/test/test_helper.rb b/vendor/plugins/globalize2/test/test_helper.rb index 3a1c8c46..195907df 100644 --- a/vendor/plugins/globalize2/test/test_helper.rb +++ b/vendor/plugins/globalize2/test/test_helper.rb @@ -1,28 +1,41 @@ +$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' ) + require 'rubygems' require 'test/unit' +require 'active_record' require 'active_support' require 'active_support/test_case' require 'mocha' +require 'globalize' +require 'validation_reflection' -$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' ) +config = { :adapter => 'sqlite3', :database => ':memory:' } +ActiveRecord::Base.establish_connection(config) class ActiveSupport::TestCase - def reset_db!( schema_path ) - ::ActiveRecord::Migration.verbose = false # Quiet down the migration engine - ::ActiveRecord::Base.establish_connection({ - :adapter => 'sqlite3', - :database => ':memory:' - }) - ::ActiveRecord::Base.silence do - load schema_path - end + def reset_db!(schema_path = nil) + schema_path ||= File.expand_path(File.dirname(__FILE__) + '/data/schema.rb') + ActiveRecord::Migration.verbose = false + ActiveRecord::Base.silence { load(schema_path) } end - - def assert_member(item, arr) - assert_block "Item #{item} is not in array #{arr}" do - arr.member? item + + def assert_member(item, array) + assert_block "Item #{item} is not in array #{array}" do + array.member?(item) end end + + def assert_belongs_to(model, associated) + assert model.reflect_on_all_associations(:belongs_to).detect { |association| + association.name.to_s == associated.to_s + } + end + + def assert_has_many(model, associated) + assert model.reflect_on_all_associations(:has_many).detect { |association| + association.name.to_s == associated.to_s + } + end end module ActiveRecord @@ -33,4 +46,31 @@ module ActiveRecord end end end -end \ No newline at end of file +end + +# module ActiveRecord +# class BaseWithoutTable < Base +# self.abstract_class = true +# +# def create_or_update +# errors.empty? +# end +# +# class << self +# def columns() +# @columns ||= [] +# end +# +# def column(name, sql_type = nil, default = nil, null = true) +# columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) +# reset_column_information +# end +# +# # Do not reset @columns +# def reset_column_information +# read_methods.each { |name| undef_method(name) } +# @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil +# end +# end +# end +# end \ No newline at end of file -- cgit v1.3