summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2013-05-19 02:09:39 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2013-05-19 02:09:39 +0000
commit1f9e1ca3181b77388e88456354c72b2d85c080a3 (patch)
tree4bb47d64b792759dfa553e8e5210c32c7f6943b4 /test/unit
parente5e73a56a76d1da8cd5455f29e48ded7c0581e5f (diff)
downloadredmine-1f9e1ca3181b77388e88456354c72b2d85c080a3.tar.gz
redmine-1f9e1ca3181b77388e88456354c72b2d85c080a3.zip
add journal after creating/deleting issue relation (#1005)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11885 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/helpers/issues_helper_test.rb32
-rw-r--r--test/unit/issue_relation_test.rb45
2 files changed, 77 insertions, 0 deletions
diff --git a/test/unit/helpers/issues_helper_test.rb b/test/unit/helpers/issues_helper_test.rb
index 327ca0710..c775bc865 100644
--- a/test/unit/helpers/issues_helper_test.rb
+++ b/test/unit/helpers/issues_helper_test.rb
@@ -210,4 +210,36 @@ class IssuesHelperTest < ActionView::TestCase
:old_value => 'error281.txt', :value => nil)
assert_match 'error281.txt', show_detail(detail, true)
end
+
+ def test_show_detail_create_relation
+ detail = JournalDetail.new(:property => 'relation',
+ :prop_key => 'label_precedes',
+ :value => 1)
+ assert_equal "Precedes Bug #1: Can't print recipes added", show_detail(detail, true)
+ assert_match %r{<strong>Precedes</strong> <i><a href="/issues/1" class=".+">Bug #1</a>: Can&#x27;t print recipes</i> added},
+ show_detail(detail, false)
+ non_existed_issue_number = 9999
+ assert_nil Issue.find_by_id(non_existed_issue_number)
+ detail = JournalDetail.new(:property => 'relation',
+ :prop_key => 'label_precedes',
+ :value => non_existed_issue_number)
+ assert_equal "Precedes Issue #{non_existed_issue_number} added", show_detail(detail, true)
+ assert_equal "<strong>Precedes</strong> <i>Issue #{non_existed_issue_number}</i> added", show_detail(detail, false)
+ end
+
+ def test_show_detail_delete_relation
+ detail = JournalDetail.new(:property => 'relation',
+ :prop_key => 'label_precedes',
+ :old_value => 1)
+ assert_equal "Precedes deleted (Bug #1: Can't print recipes)", show_detail(detail, true)
+ assert_match %r{<strong>Precedes</strong> deleted \(<del><i><a href="/issues/1" class=".+">Bug #1</a>: Can&#x27;t print recipes</i></del>\)},
+ show_detail(detail, false)
+ non_existed_issue_number = 9999
+ assert_nil Issue.find_by_id(non_existed_issue_number)
+ detail = JournalDetail.new(:property => 'relation',
+ :prop_key => 'label_precedes',
+ :old_value => non_existed_issue_number)
+ assert_equal "Precedes deleted (Issue 9999)", show_detail(detail, true)
+ assert_equal "<strong>Precedes</strong> deleted (<del><i>Issue 9999</i></del>)", show_detail(detail, false)
+ end
end
diff --git a/test/unit/issue_relation_test.rb b/test/unit/issue_relation_test.rb
index f0e74faf7..1b76056ee 100644
--- a/test/unit/issue_relation_test.rb
+++ b/test/unit/issue_relation_test.rb
@@ -167,4 +167,49 @@ class IssueRelationTest < ActiveSupport::TestCase
assert !r.save
assert_not_nil r.errors[:base]
end
+
+ def test_create_should_make_journal_entry
+ from = Issue.find(1)
+ to = Issue.find(2)
+ from_journals = from.journals.size
+ to_journals = to.journals.size
+ relation = IssueRelation.new(:issue_from => from, :issue_to => to,
+ :relation_type => IssueRelation::TYPE_PRECEDES)
+ assert relation.save
+ from.reload
+ to.reload
+ relation.reload
+ assert_equal from.journals.size, (from_journals + 1)
+ assert_equal to.journals.size, (to_journals + 1)
+ assert_equal 'relation', from.journals.last.details.last.property
+ assert_equal 'label_precedes', from.journals.last.details.last.prop_key
+ assert_equal '2', from.journals.last.details.last.value
+ assert_nil from.journals.last.details.last.old_value
+ assert_equal 'relation', to.journals.last.details.last.property
+ assert_equal 'label_follows', to.journals.last.details.last.prop_key
+ assert_equal '1', to.journals.last.details.last.value
+ assert_nil to.journals.last.details.last.old_value
+ end
+
+ def test_delete_should_make_journal_entry
+ relation = IssueRelation.find(1)
+ id = relation.id
+ from = relation.issue_from
+ to = relation.issue_to
+ from_journals = from.journals.size
+ to_journals = to.journals.size
+ assert relation.destroy
+ from.reload
+ to.reload
+ assert_equal from.journals.size, (from_journals + 1)
+ assert_equal to.journals.size, (to_journals + 1)
+ assert_equal 'relation', from.journals.last.details.last.property
+ assert_equal 'label_blocks', from.journals.last.details.last.prop_key
+ assert_equal '9', from.journals.last.details.last.old_value
+ assert_nil from.journals.last.details.last.value
+ assert_equal 'relation', to.journals.last.details.last.property
+ assert_equal 'label_blocked_by', to.journals.last.details.last.prop_key
+ assert_equal '10', to.journals.last.details.last.old_value
+ assert_nil to.journals.last.details.last.value
+ end
end