Started migrating the tests from issue into workpackage #1754
Starting with the validations, we're moving everything out of issue into workpackage: Accompanying this, the tests are migrated into specs. This branch concentrates on moving the validations. * added shoulda for simplified testing of validations * added date_validator to simplify&fix date-validation * moved the basic-validations (presence_of, date-validations) into the workpackage_basics_spec.rbpull/384/head
parent
585507176c
commit
a70d8d4012
@ -0,0 +1,43 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# |
||||
# Copyright (C) 2012-2013 the OpenProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe WorkPackage do |
||||
|
||||
describe "validations" do |
||||
|
||||
# validations |
||||
[:subject, :priority, :project, :type, :author, :status].each do |field| |
||||
it{ should validate_presence_of field} |
||||
end |
||||
|
||||
it { should ensure_length_of(:subject).is_at_most 255 } |
||||
it { should ensure_inclusion_of(:done_ratio).in_range 0..100 } |
||||
it { should validate_numericality_of :estimated_hours} |
||||
|
||||
it "validate, that start-date is before end-date" do |
||||
wp = FactoryGirl.build(:work_package, start_date: 1.day.from_now, due_date: Time.now) |
||||
expect(wp).to have(1).errors_on(:due_date) |
||||
end |
||||
|
||||
it "validate, that correct formats are properly validated" do |
||||
wp = FactoryGirl.build(:work_package, start_date: "01/01/13", due_date: "31/01/13") |
||||
puts wp.valid? |
||||
puts wp.errors.full_messages |
||||
expect(wp).to have(0).errors_on(:start_date) |
||||
end |
||||
end |
||||
|
||||
|
||||
|
||||
|
||||
end |
Loading…
Reference in new issue