131 |
131 |
assert_include activity, project.activities
|
132 |
132 |
assert_include TimeEntryActivity.find(9), project.activities
|
133 |
133 |
end
|
|
134 |
|
|
135 |
def test_project_activity_should_have_the_same_position_as_the_position_of_the_parent_activity
|
|
136 |
project = Project.find(1)
|
|
137 |
|
|
138 |
parent_activity = TimeEntryActivity.find_by(position: 3, parent_id: nil)
|
|
139 |
project.update_or_create_time_entry_activities({parent_activity.id.to_s => {'parent_id' => parent_activity.id.to_s, 'active' => '0', 'custom_field_values' => {'7' => ''}}})
|
|
140 |
project_activity = TimeEntryActivity.find_by(position: 3, parent_id: parent_activity.id, project_id: 1)
|
|
141 |
assert_equal parent_activity.position, project_activity.position
|
|
142 |
|
|
143 |
# Changing the position of the parent activity also changes the position of the activity in each project.
|
|
144 |
other_parent_activity = TimeEntryActivity.find_by(position: 4, parent_id: nil)
|
|
145 |
project.update_or_create_time_entry_activities({other_parent_activity.id.to_s => {'parent_id' => other_parent_activity.id.to_s, 'active' => '0', 'custom_field_values' => {'7' => ''}}})
|
|
146 |
other_project_activity = TimeEntryActivity.find_by(position: 4, parent_id: other_parent_activity.id, project_id: 1)
|
|
147 |
|
|
148 |
parent_activity.update(position: 4)
|
|
149 |
assert_equal 4, parent_activity.reload.position
|
|
150 |
assert_equal parent_activity.position, project_activity.reload.position
|
|
151 |
assert_equal 3, other_parent_activity.reload.position
|
|
152 |
assert_equal other_parent_activity.position, other_project_activity.reload.position
|
|
153 |
end
|
134 |
154 |
end
|