@@ -56,6 +56,10 class Version < ActiveRecord::Base | |||||
56 | effective_date |
|
56 | effective_date | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
|
59 | def due_date=(arg) | |||
|
60 | self.effective_date=(arg) | |||
|
61 | end | |||
|
62 | ||||
59 | # Returns the total estimated time for this version |
|
63 | # Returns the total estimated time for this version | |
60 | # (sum of leaves estimated_hours) |
|
64 | # (sum of leaves estimated_hours) | |
61 | def estimated_hours |
|
65 | def estimated_hours |
@@ -69,6 +69,20 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||||
69 | assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s} |
|
69 | assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s} | |
70 | end |
|
70 | end | |
71 |
|
71 | |||
|
72 | should "create the version with due date" do | |||
|
73 | assert_difference 'Version.count' do | |||
|
74 | post '/projects/1/versions.xml', {:version => {:name => 'API test', :due_date => '2012-01-24'}}, credentials('jsmith') | |||
|
75 | end | |||
|
76 | ||||
|
77 | version = Version.first(:order => 'id DESC') | |||
|
78 | assert_equal 'API test', version.name | |||
|
79 | assert_equal Date.parse('2012-01-24'), version.due_date | |||
|
80 | ||||
|
81 | assert_response :created | |||
|
82 | assert_equal 'application/xml', @response.content_type | |||
|
83 | assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s} | |||
|
84 | end | |||
|
85 | ||||
72 | context "with failure" do |
|
86 | context "with failure" do | |
73 | should "return the errors" do |
|
87 | should "return the errors" do | |
74 | assert_no_difference('Version.count') do |
|
88 | assert_no_difference('Version.count') do |
General Comments 0
You need to be logged in to leave comments.
Login now