search for: accounttest

Displaying 2 results from an estimated 2 matches for "accounttest".

Did you mean: account_test
2008 Jun 29
2
How to write test about validates_associated
...esence_of :name_native validates_presence_of :email validates_presence_of :phone validates_associated :currency validates_associated :coursecodeformat validates_associated :vouchertypes end and here is my test: require File.dirname(__FILE__) + ''/../test_helper'' class AccountTest < Test::Unit::TestCase def test_validate_present account = Account.new assert !account.valid? assert account.errors.invalid?(:name_native) assert !account.errors.invalid?(:code) assert account.errors.invalid?(:email) assert account.errors.invalid?(:phone) assert ac...
2009 May 25
4
after_create and has_one association bug?
...lidates_presence_of, so the contact should not get saved, but it in fact does. class Account < ActiveRecord::Base has_one :contact def after_create create_contact end end class Contact < ActiveRecord::Base belongs_to :account validates_presence_of :name end The test... class AccountTest < ActiveSupport::TestCase test "this ain''t right" do a = Account.create p a.contact p a.new_record? end end produces... #<Contact id: 996332878, name: nil, account_id: 1, created_at: "2009-05-25 05:40:40", updated_at: "2009-05-25 05:40:40&qu...