From a5ef5f599948581b453eabd23200a6d51dbdc378 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 17 Jun 2010 15:16:11 -0700 Subject: [PATCH] [#4177] Added generators for Contract. --- app/models/contract.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/models/contract.rb b/app/models/contract.rb index 5f42667..39c7178 100644 --- a/app/models/contract.rb +++ b/app/models/contract.rb @@ -39,4 +39,18 @@ class Contract < ActiveRecord::Base errors.add :end_date, :greater_than_start_date end end + + if Rails.env.test? + generator_for :name, :method => :next_name + generator_for :executed => true + generator_for(:start_date) { Date.yesterday } + generator_for(:end_date) { Date.tomorrow } + + def self.next_name + @last_name ||= 'Contract 0000' + @last_name.succ! + end + + end + end