diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-16 09:38:01 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-16 09:38:01 +0000 |
commit | a45c0dc55057e8c10c2d17f8dc26be5d9b771f8d (patch) | |
tree | 93fa80fd96d6c404515d23d3ce1662c2ef7ee517 /test | |
parent | 723e21243e8df3cbb8937c32410797fa84c9cb79 (diff) | |
download | redmine-a45c0dc55057e8c10c2d17f8dc26be5d9b771f8d.tar.gz redmine-a45c0dc55057e8c10c2d17f8dc26be5d9b771f8d.zip |
Adds closed_on column that stores the time of the last closing (#824).
The value is preserved when reopening the issue.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11402 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/issues.yml | 3 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 54 |
2 files changed, 57 insertions, 0 deletions
diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml index 531089de0..8eb8ae1a5 100644 --- a/test/fixtures/issues.yml +++ b/test/fixtures/issues.yml @@ -152,6 +152,7 @@ issues_008: root_id: 8 lft: 1 rgt: 2 + closed_on: <%= 3.days.ago.to_s(:db) %> issues_009: created_on: <%= 1.minute.ago.to_s(:db) %> project_id: 5 @@ -209,6 +210,7 @@ issues_011: root_id: 11 lft: 1 rgt: 2 + closed_on: <%= 1.day.ago.to_s(:db) %> issues_012: created_on: <%= 3.days.ago.to_s(:db) %> project_id: 1 @@ -228,6 +230,7 @@ issues_012: root_id: 12 lft: 1 rgt: 2 + closed_on: <%= 1.day.ago.to_s(:db) %> issues_013: created_on: <%= 5.days.ago.to_s(:db) %> project_id: 3 diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 1ffc24dd5..ad88933e5 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1917,4 +1917,58 @@ class IssueTest < ActiveSupport::TestCase assert_equal 3, issue.reload.attachments.count assert_equal %w(upload foo bar), issue.attachments.map(&:filename) end + + def test_closed_on_should_be_nil_when_creating_an_open_issue + issue = Issue.generate!(:status_id => 1).reload + assert !issue.closed? + assert_nil issue.closed_on + end + + def test_closed_on_should_be_set_when_creating_a_closed_issue + issue = Issue.generate!(:status_id => 5).reload + assert issue.closed? + assert_not_nil issue.closed_on + assert_equal issue.updated_on, issue.closed_on + assert_equal issue.created_on, issue.closed_on + end + + def test_closed_on_should_be_nil_when_updating_an_open_issue + issue = Issue.find(1) + issue.subject = 'Not closed yet' + issue.save! + issue.reload + assert_nil issue.closed_on + end + + def test_closed_on_should_be_set_when_closing_an_open_issue + issue = Issue.find(1) + issue.subject = 'Now closed' + issue.status_id = 5 + issue.save! + issue.reload + assert_not_nil issue.closed_on + assert_equal issue.updated_on, issue.closed_on + end + + def test_closed_on_should_not_be_updated_when_updating_a_closed_issue + issue = Issue.open(false).first + was_closed_on = issue.closed_on + assert_not_nil was_closed_on + issue.subject = 'Updating a closed issue' + issue.save! + issue.reload + assert_equal was_closed_on, issue.closed_on + end + + def test_closed_on_should_be_preserved_when_reopening_a_closed_issue + issue = Issue.open(false).first + was_closed_on = issue.closed_on + assert_not_nil was_closed_on + issue.subject = 'Reopening a closed issue' + issue.status_id = 1 + issue.save! + issue.reload + assert !issue.closed? + assert_equal was_closed_on, issue.closed_on + end end |