ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
0001-441-Journals-should-touch-their-journaled-to-update-.patch
b/app/models/issue.rb | ||
---|---|---|
529 | 529 |
"#{tracker} ##{id}: #{subject}" |
530 | 530 |
end |
531 | 531 | |
532 |
# The number of "items" this issue spans in it's nested set |
|
533 |
# |
|
534 |
# A parent issue would span all of it's children + 1 left + 1 right (3) |
|
535 |
# |
|
536 |
# | parent | |
|
537 |
# || child || |
|
538 |
# |
|
539 |
# A child would span only itself (1) |
|
540 |
# |
|
541 |
# |child| |
|
542 |
def nested_set_span |
|
543 |
rgt - lft |
|
544 |
end |
|
545 |
|
|
532 | 546 |
# Returns a string of css classes that apply to the issue |
533 | 547 |
def css_classes |
534 | 548 |
s = "issue status-#{status.position} priority-#{priority.position}" |
b/app/models/journal.rb | ||
---|---|---|
23 | 23 | |
24 | 24 |
# Make sure each journaled model instance only has unique version ids |
25 | 25 |
validates_uniqueness_of :version, :scope => [:journaled_id, :type] |
26 |
belongs_to :journaled |
|
26 |
belongs_to :journaled, :touch => true
|
|
27 | 27 |
belongs_to :user |
28 | 28 | |
29 | 29 |
# ActiveRecord::Base#changes is an existing method, so before serializing the +changes+ column, |
b/test/unit/issue_nested_set_test.rb | ||
---|---|---|
30 | 30 |
issue1.reload |
31 | 31 |
issue2.reload |
32 | 32 | |
33 |
assert_equal [issue1.id, nil, 1, 2], [issue1.root_id, issue1.parent_id, issue1.lft, issue1.rgt] |
|
34 |
assert_equal [issue2.id, nil, 1, 2], [issue2.root_id, issue2.parent_id, issue2.lft, issue2.rgt] |
|
33 |
assert_equal issue1.id, issue1.root_id |
|
34 |
assert issue1.leaf? |
|
35 |
assert_equal issue2.id, issue2.root_id |
|
36 |
assert issue2.leaf? |
|
35 | 37 |
end |
36 | 38 | |
37 | 39 |
def test_create_child_issue |
... | ... | |
40 | 42 |
parent.reload |
41 | 43 |
child.reload |
42 | 44 | |
43 |
assert_equal [parent.id, nil, 1, 4], [parent.root_id, parent.parent_id, parent.lft, parent.rgt]
|
|
44 |
assert_equal [parent.id, parent.id, 2, 3], [child.root_id, child.parent_id, child.lft, child.rgt]
|
|
45 |
assert_equal [parent.id, nil, 3], [parent.root_id, parent.parent_id, parent.rgt - parent.lft]
|
|
46 |
assert_equal [parent.id, parent.id, 1], [child.root_id, child.parent_id, child.rgt - child.lft]
|
|
45 | 47 |
end |
46 | 48 | |
47 | 49 |
def test_creating_a_child_in_different_project_should_not_validate |
... | ... | |
62 | 64 |
parent1.reload |
63 | 65 |
parent2.reload |
64 | 66 | |
65 |
assert_equal [parent1.id, 1, 6], [parent1.root_id, parent1.lft, parent1.rgt]
|
|
66 |
assert_equal [parent1.id, 4, 5], [parent2.root_id, parent2.lft, parent2.rgt]
|
|
67 |
assert_equal [parent1.id, 2, 3], [child.root_id, child.lft, child.rgt]
|
|
67 |
assert_equal [parent1.id, 5], [parent1.root_id, parent1.nested_set_span]
|
|
68 |
assert_equal [parent1.id, 1], [parent2.root_id, parent2.nested_set_span]
|
|
69 |
assert_equal [parent1.id, 1], [child.root_id, child.nested_set_span]
|
|
68 | 70 |
end |
69 | 71 | |
70 | 72 |
def test_move_a_child_to_root |
... | ... | |
78 | 80 |
parent1.reload |
79 | 81 |
parent2.reload |
80 | 82 | |
81 |
assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt]
|
|
82 |
assert_equal [parent2.id, 1, 2], [parent2.root_id, parent2.lft, parent2.rgt]
|
|
83 |
assert_equal [child.id, 1, 2], [child.root_id, child.lft, child.rgt]
|
|
83 |
assert_equal [parent1.id, 1], [parent1.root_id, parent1.nested_set_span]
|
|
84 |
assert_equal [parent2.id, 1], [parent2.root_id, parent2.nested_set_span]
|
|
85 |
assert_equal [child.id, 1], [child.root_id, child.nested_set_span]
|
|
84 | 86 |
end |
85 | 87 | |
86 | 88 |
def test_move_a_child_to_another_issue |
... | ... | |
94 | 96 |
parent1.reload |
95 | 97 |
parent2.reload |
96 | 98 | |
97 |
assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt]
|
|
98 |
assert_equal [parent2.id, 1, 4], [parent2.root_id, parent2.lft, parent2.rgt]
|
|
99 |
assert_equal [parent2.id, 2, 3], [child.root_id, child.lft, child.rgt]
|
|
99 |
assert_equal [parent1.id, 1], [parent1.root_id, parent1.nested_set_span]
|
|
100 |
assert_equal [parent2.id, 3], [parent2.root_id, parent2.nested_set_span]
|
|
101 |
assert_equal [parent2.id, 1], [child.root_id, child.nested_set_span]
|
|
100 | 102 |
end |
101 | 103 | |
102 | 104 |
def test_move_a_child_with_descendants_to_another_issue |
... | ... | |
110 | 112 |
child.reload |
111 | 113 |
grandchild.reload |
112 | 114 | |
113 |
assert_equal [parent1.id, 1, 6], [parent1.root_id, parent1.lft, parent1.rgt]
|
|
114 |
assert_equal [parent2.id, 1, 2], [parent2.root_id, parent2.lft, parent2.rgt]
|
|
115 |
assert_equal [parent1.id, 2, 5], [child.root_id, child.lft, child.rgt]
|
|
116 |
assert_equal [parent1.id, 3, 4], [grandchild.root_id, grandchild.lft, grandchild.rgt]
|
|
115 |
assert_equal [parent1.id, 5], [parent1.root_id, parent1.nested_set_span]
|
|
116 |
assert_equal [parent2.id, 1], [parent2.root_id, parent2.nested_set_span]
|
|
117 |
assert_equal [parent1.id, 3], [child.root_id, child.nested_set_span]
|
|
118 |
assert_equal [parent1.id, 1], [grandchild.root_id, grandchild.nested_set_span]
|
|
117 | 119 | |
118 | 120 |
child.reload.parent_issue_id = parent2.id |
119 | 121 |
child.save! |
... | ... | |
122 | 124 |
parent1.reload |
123 | 125 |
parent2.reload |
124 | 126 | |
125 |
assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt]
|
|
126 |
assert_equal [parent2.id, 1, 6], [parent2.root_id, parent2.lft, parent2.rgt]
|
|
127 |
assert_equal [parent2.id, 2, 5], [child.root_id, child.lft, child.rgt]
|
|
128 |
assert_equal [parent2.id, 3, 4], [grandchild.root_id, grandchild.lft, grandchild.rgt]
|
|
127 |
assert_equal [parent1.id, 1], [parent1.root_id, parent1.nested_set_span]
|
|
128 |
assert_equal [parent2.id, 5], [parent2.root_id, parent2.nested_set_span]
|
|
129 |
assert_equal [parent2.id, 3], [child.root_id, child.nested_set_span]
|
|
130 |
assert_equal [parent2.id, 1], [grandchild.root_id, grandchild.nested_set_span]
|
|
129 | 131 |
end |
130 | 132 | |
131 | 133 |
def test_move_a_child_with_descendants_to_another_project |
... | ... | |
138 | 140 |
grandchild.reload |
139 | 141 |
parent1.reload |
140 | 142 | |
141 |
assert_equal [1, parent1.id, 1, 2], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
|
|
142 |
assert_equal [2, child.id, 1, 4], [child.project_id, child.root_id, child.lft, child.rgt]
|
|
143 |
assert_equal [2, child.id, 2, 3], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt]
|
|
143 |
assert_equal [1, parent1.id, 1], [parent1.project_id, parent1.root_id, parent1.nested_set_span]
|
|
144 |
assert_equal [2, child.id, 3], [child.project_id, child.root_id, child.nested_set_span]
|
|
145 |
assert_equal [2, child.id, 1], [grandchild.project_id, grandchild.root_id, grandchild.nested_set_span]
|
|
144 | 146 |
end |
145 | 147 | |
146 | 148 |
def test_invalid_move_to_another_project |
... | ... | |
150 | 152 |
Project.find(2).tracker_ids = [1] |
151 | 153 | |
152 | 154 |
parent1.reload |
153 |
assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
|
|
155 |
assert_equal [1, parent1.id, 5], [parent1.project_id, parent1.root_id, parent1.nested_set_span]
|
|
154 | 156 | |
155 | 157 |
# child can not be moved to Project 2 because its child is on a disabled tracker |
156 | 158 |
assert_equal false, Issue.find(child.id).move_to_project(Project.find(2)) |
... | ... | |
159 | 161 |
parent1.reload |
160 | 162 | |
161 | 163 |
# no change |
162 |
assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
|
|
163 |
assert_equal [1, parent1.id, 2, 5], [child.project_id, child.root_id, child.lft, child.rgt]
|
|
164 |
assert_equal [1, parent1.id, 3, 4], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt]
|
|
164 |
assert_equal [1, parent1.id, 5], [parent1.project_id, parent1.root_id, parent1.nested_set_span]
|
|
165 |
assert_equal [1, parent1.id, 3], [child.project_id, child.root_id, child.nested_set_span]
|
|
166 |
assert_equal [1, parent1.id, 1], [grandchild.project_id, grandchild.root_id, grandchild.nested_set_span]
|
|
165 | 167 |
end |
166 | 168 | |
167 | 169 |
def test_moving_an_issue_to_a_descendant_should_not_validate |
... | ... | |
212 | 214 |
issue4.reload |
213 | 215 |
assert !Issue.exists?(issue2.id) |
214 | 216 |
assert !Issue.exists?(issue3.id) |
215 |
assert_equal [issue1.id, 1, 4], [issue1.root_id, issue1.lft, issue1.rgt]
|
|
216 |
assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
|
|
217 |
assert_equal [issue1.id, 3], [issue1.root_id, issue1.nested_set_span]
|
|
218 |
assert_equal [issue1.id, 1], [issue4.root_id, issue4.nested_set_span]
|
|
217 | 219 |
end |
218 | 220 | |
219 | 221 |
def test_destroy_parent_issue_updated_during_children_destroy |
b/test/unit/issue_test.rb | ||
---|---|---|
372 | 372 |
def test_move_to_another_project_should_clear_fixed_version_when_not_shared |
373 | 373 |
issue = Issue.find(1) |
374 | 374 |
issue.update_attribute(:fixed_version_id, 1) |
375 |
issue.reload |
|
375 | 376 |
assert issue.move_to_project(Project.find(2)) |
376 | 377 |
issue.reload |
377 | 378 |
assert_equal 2, issue.project_id |
... | ... | |
382 | 383 |
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project |
383 | 384 |
issue = Issue.find(1) |
384 | 385 |
issue.update_attribute(:fixed_version_id, 4) |
386 |
issue.reload |
|
385 | 387 |
assert issue.move_to_project(Project.find(5)) |
386 | 388 |
issue.reload |
387 | 389 |
assert_equal 5, issue.project_id |
... | ... | |
392 | 394 |
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project |
393 | 395 |
issue = Issue.find(1) |
394 | 396 |
issue.update_attribute(:fixed_version_id, 1) |
397 |
issue.reload |
|
395 | 398 |
assert issue.move_to_project(Project.find(5)) |
396 | 399 |
issue.reload |
397 | 400 |
assert_equal 5, issue.project_id |
... | ... | |
402 | 405 |
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide |
403 | 406 |
issue = Issue.find(1) |
404 | 407 |
issue.update_attribute(:fixed_version_id, 7) |
408 |
issue.reload |
|
405 | 409 |
assert issue.move_to_project(Project.find(2)) |
406 | 410 |
issue.reload |
407 | 411 |
assert_equal 2, issue.project_id |
b/test/unit/journal_test.rb | ||
---|---|---|
36 | 36 |
ActionMailer::Base.deliveries.clear |
37 | 37 |
issue = Issue.find(:first) |
38 | 38 |
if issue.journals.empty? |
39 |
issue.init_journal(User.current, "This journal represents the creational journal version 1")
|
|
39 |
issue.init_journal(User.current, "This journal represents the creationa of journal version 1")
|
|
40 | 40 |
issue.save |
41 | 41 |
end |
42 | 42 |
user = User.find(:first) |
43 | 43 | |
44 | 44 |
assert_equal 0, ActionMailer::Base.deliveries.size |
45 |
issue.reload |
|
45 | 46 |
issue.update_attribute(:subject, "New subject to trigger automatic journal entry") |
46 | 47 |
assert_equal 1, ActionMailer::Base.deliveries.size |
47 | 48 |
end |
... | ... | |
58 | 59 |
end |
59 | 60 |
assert_equal 0, ActionMailer::Base.deliveries.size |
60 | 61 |
end |
62 | ||
63 |
test "creating a journal should update the updated_on value of the parent record (touch)" do |
|
64 |
@user = User.generate! |
|
65 |
@project = Project.generate! |
|
66 |
@issue = Issue.generate_for_project!(@project).reload |
|
67 |
start = @issue.updated_on |
|
68 | ||
69 |
assert_difference("Journal.count") do |
|
70 |
@issue.init_journal(@user, "A note") |
|
71 |
@issue.save |
|
72 |
end |
|
73 | ||
74 |
assert_not_equal start, @issue.reload.updated_on |
|
75 |
end |
|
61 | 76 |
end |
b/test/unit/mail_handler_test.rb | ||
---|---|---|
60 | 60 |
assert_equal Version.find_by_name('alpha'), issue.fixed_version |
61 | 61 |
assert_equal 2.5, issue.estimated_hours |
62 | 62 |
assert_equal 30, issue.done_ratio |
63 |
assert_equal [issue.id, 1, 2], [issue.root_id, issue.lft, issue.rgt] |
|
63 |
assert_equal issue.id, issue.root_id |
|
64 |
assert issue.leaf? |
|
64 | 65 |
# keywords should be removed from the email body |
65 | 66 |
assert !issue.description.match(/^Project:/i) |
66 | 67 |
assert !issue.description.match(/^Status:/i) |
... | ... | |
208 | 209 |
assert issue.is_a?(Issue) |
209 | 210 |
assert issue.author.anonymous? |
210 | 211 |
assert !issue.project.is_public? |
211 |
assert_equal [issue.id, 1, 2], [issue.root_id, issue.lft, issue.rgt] |
|
212 |
assert_equal issue.id, issue.root_id |
|
213 |
assert issue.leaf? |
|
212 | 214 |
end |
213 | 215 |
end |
214 | 216 |
end |
b/vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/reversion.rb | ||
---|---|---|
107 | 107 |
end |
108 | 108 |
end |
109 | 109 |
end |
110 |
end |
|
110 |
end |
|
111 |
- |