test/test_helper.rb in delocalize-0.3.1 vs test/test_helper.rb in delocalize-0.3.2

- old
+ new

@@ -3,10 +3,12 @@ require 'rubygems' require 'bundler' Bundler.require(:default, :development) +require 'rails/all' + require 'test/unit' require 'delocalize/rails_ext/action_view' require 'delocalize/rails_ext/active_record' require 'delocalize/rails_ext/time_zone' @@ -45,10 +47,17 @@ :format => { :precision => 2, :separator => ',', :delimiter => '.' } + }, + :activerecord => { + :errors => { + :messages => { + :not_a_number => 'is not a number' + } + } } } # deeply clone the hash for a fantasy language called tt tt = Marshal.load(Marshal.dump(de)) @@ -71,10 +80,18 @@ class ProductWithValidation < Product validates_numericality_of :price validates_presence_of :price end +class ProductWithBusinessValidation < Product + validate do |record| + if record.price > 10 + record.errors.add(:price, :invalid) + end + end +end + config = YAML.load_file(File.dirname(__FILE__) + '/database.yml') ActiveRecord::Base.establish_connection(config['test']) ActiveRecord::Base.connection.create_table :products do |t| t.string :name @@ -84,5 +101,6 @@ t.decimal :price t.float :weight t.integer :times_sold t.decimal :some_value_with_default, :default => 0, :precision => 20, :scale => 2 end +