forked from amanikids/kituo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate steps that create records.
- Loading branch information
1 parent
885e02b
commit 98a71ef
Showing
5 changed files
with
71 additions
and
71 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
Given /^the following children exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
child = Child.make(:name => hash['Child']) | ||
end | ||
end | ||
|
||
Given /^the following children with no headshot exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
child = Child.make(:name => hash['Child'], :headshot => nil) | ||
end | ||
end | ||
|
||
Given /^the following children with no social worker exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
child = Child.make(:name => hash['Child'], :social_worker => nil) | ||
end | ||
end | ||
|
||
Given /^the following events exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
child = Child.find_by_name!(hash['Child']) | ||
hash['Event'].constantize.make( | ||
:child => child, | ||
:happened_on => parse_date(hash['Date']) | ||
) | ||
child.recalculate_state! | ||
end | ||
end | ||
|
||
Given /^the following users exist:$/ do |table| | ||
table.hashes.each do |user_hash| | ||
Caregiver.make( | ||
:name => user_hash['Name'], | ||
:role => user_hash['Role'].downcase.tr(' ', '_') | ||
) | ||
end | ||
end | ||
|
||
Given /^the following scheduled visits exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
social_worker = Caregiver.find_by_name(hash['Social Worker']) | ||
ScheduledVisit.make( | ||
:scheduled_for => parse_date(hash['Date']), | ||
:child => Child.make( | ||
:name => hash['Child'], | ||
:location => hash['Location'] || "Moshi", | ||
:social_worker => social_worker)) | ||
end | ||
end | ||
|
||
Given /^the following recommended visits exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
social_worker = Caregiver.find_by_name(hash['Social Worker']) | ||
Child.make( | ||
:name => hash['Child'], | ||
:social_worker => social_worker, | ||
:state => 'on_site') | ||
end | ||
end | ||
|
||
Given /^the following non-recommended children exist:$/ do |table| | ||
table.hashes.each do |hash| | ||
social_worker = Caregiver.find_by_name(hash['Social Worker']) | ||
child = Child.make( | ||
:name => hash['Child'], | ||
:social_worker => social_worker, | ||
:state => 'on_site') | ||
child.home_visits.make | ||
end | ||
end | ||
|
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
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
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
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