summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 15:38:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 15:38:11 +0000
commit32b79b6fd4e3a523ee393d7a3e2bb60dbeed77c3 (patch)
tree5050ce8fcb138d88180d9c3d61e34c05dc03a4d8 /test
parent43f6914f520f9a79220414cdd5d54d6fa2cc0720 (diff)
downloadredmine-32b79b6fd4e3a523ee393d7a3e2bb60dbeed77c3.tar.gz
redmine-32b79b6fd4e3a523ee393d7a3e2bb60dbeed77c3.zip
Fixed that IssueRelation should not be responsible for calling Issue#init_journal (#18237).
git-svn-id: http://svn.redmine.org/redmine/trunk@13534 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/issue_relation_test.rb6
-rw-r--r--test/unit/journal_test.rb12
-rw-r--r--test/unit/mailer_test.rb1
3 files changed, 10 insertions, 9 deletions
diff --git a/test/unit/issue_relation_test.rb b/test/unit/issue_relation_test.rb
index 27a47fcfe..086373bd2 100644
--- a/test/unit/issue_relation_test.rb
+++ b/test/unit/issue_relation_test.rb
@@ -169,13 +169,14 @@ class IssueRelationTest < ActiveSupport::TestCase
assert_not_equal [], r.errors[:base]
end
- def test_create_should_make_journal_entry
+ def test_create_with_initialized_journals_should_create_journals
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)
+ relation.init_journals User.find(1)
assert relation.save
from.reload
to.reload
@@ -192,12 +193,13 @@ class IssueRelationTest < ActiveSupport::TestCase
assert_nil to.journals.last.details.last.old_value
end
- def test_delete_should_make_journal_entry
+ def test_destroy_with_initialized_journals_should_create_journals
relation = IssueRelation.find(1)
from = relation.issue_from
to = relation.issue_to
from_journals = from.journals.size
to_journals = to.journals.size
+ relation.init_journals User.find(1)
assert relation.destroy
from.reload
to.reload
diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb
index 36f494807..37ca413c4 100644
--- a/test/unit/journal_test.rb
+++ b/test/unit/journal_test.rb
@@ -207,17 +207,15 @@ class JournalTest < ActiveSupport::TestCase
def test_visible_details_should_include_relations_to_visible_issues_only
issue = Issue.generate!
visible_issue = Issue.generate!
- IssueRelation.create!(:issue_from => issue, :issue_to => visible_issue, :relation_type => 'relates')
hidden_issue = Issue.generate!(:is_private => true)
- IssueRelation.create!(:issue_from => issue, :issue_to => hidden_issue, :relation_type => 'relates')
- issue.reload
- assert_equal 1, issue.journals.size
- journal = issue.journals.first
- assert_equal 2, journal.details.size
+
+ journal = Journal.new
+ journal.details << JournalDetail.new(:property => 'relation', :prop_key => 'relates', :value => visible_issue.id)
+ journal.details << JournalDetail.new(:property => 'relation', :prop_key => 'relates', :value => hidden_issue.id)
visible_details = journal.visible_details(User.anonymous)
assert_equal 1, visible_details.size
- assert_equal visible_issue.id.to_s, visible_details.first.value
+ assert_equal visible_issue.id.to_s, visible_details.first.value.to_s
visible_details = journal.visible_details(User.find(2))
assert_equal 2, visible_details.size
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index b3678ebb5..e9ffbaeb8 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -410,6 +410,7 @@ class MailerTest < ActiveSupport::TestCase
def test_issue_edit_with_relation_should_notify_users_who_can_see_the_related_issue
issue = Issue.generate!
+ issue.init_journal(User.find(1))
private_issue = Issue.generate!(:is_private => true)
IssueRelation.create!(:issue_from => issue, :issue_to => private_issue, :relation_type => 'relates')
issue.reload