Created
May 6, 2011 01:15
-
-
Save DylanLacey/958286 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Job < ActiveRecord::Base | |
has_many :waypoints | |
has_many :pickup_addresses, :class_name => "Waypoint", :conditions => {:purpose => "PICK UP"} | |
has_many :setdown_addresses, :class_name => "Waypoint", :conditions => {:purpose => "SET DOWN"} | |
accepts_nested_attributes_for :waypoints | |
accepts_nested_attributes_for :pickup_addresses | |
accepts_nested_attributes_for :pickup_addresses | |
end | |
==== | |
Jobs.yml | |
no_setdown: | |
name: Test1 | |
phone: 04040404 | |
date: 2011-05-03 | |
time: 2001-05-03 10:34:34 | |
passengers: 2 | |
==== | |
Waypoints.yml | |
single_pickup: | |
purpose: PICK UP | |
street_number: 1 | |
location_name: Location | |
suburb: Suburb | |
friendly_name: bees | |
street_type: pde | |
job: no_setdown | |
==== | |
class JobTest < ActiveSupport::TestCase | |
test "must have a pickup address" do | |
job = Job.new | |
assert !job.save, "Saved a job without a pickup address" | |
end | |
test "must have a setdown address" do | |
job = Job.new(jobs(:no_setdown)) | |
assert_equal(1, job.waypoints.count, job.waypoints) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment