test/unit/test_job.rb in cloud-crowd-0.6.2 vs test/unit/test_job.rb in cloud-crowd-0.7.0.pre
- old
+ new
@@ -3,19 +3,21 @@
class JobTest < Test::Unit::TestCase
context "A CloudCrowd Job" do
setup do
- @job = Job.make
+ @job = Job.make!
@unit = @job.work_units.first
end
subject { @job }
- should_have_many :work_units
+ should have_many(:work_units)
- should_validate_presence_of :status, :inputs, :action, :options
+ [:status, :inputs, :action, :options].each do |field|
+ should validate_presence_of(field)
+ end
should "create all of its work units as soon as the job is created" do
assert @job.work_units.count >= 1
assert @job.percent_complete == 0
assert @job.processing?
@@ -85,15 +87,13 @@
@job.update_attribute(:status, MERGING)
assert @job.display_status == 'merging'
end
should "be able to clean up jobs that have aged beyond their use" do
- count = Job.count
Job.cleanup_all
- assert count == Job.count
- Job.record_timestamps = false
- @job.update_attributes :status => SUCCEEDED, :updated_at => 10.days.ago
- Job.record_timestamps = true
+ count = Job.count
+ @job.update_attributes({:status => SUCCEEDED, :updated_at => 10.days.ago })
+ assert @job.status == SUCCEEDED
Job.cleanup_all
assert count > Job.count
assert !Job.find_by_id(@job.id)
end