Defect #36318 » 36318-v2.patch
| app/models/enumeration.rb | ||
|---|---|---|
| 117 | 117 |
# Does the +new+ Hash have the same custom values as the previous Enumeration? |
| 118 | 118 |
def self.same_custom_values?(new, previous) |
| 119 | 119 |
previous.custom_field_values.each do |custom_value| |
| 120 |
if custom_value.value != new["custom_field_values"][custom_value.custom_field_id.to_s]
|
|
| 120 |
if custom_value.to_s != new["custom_field_values"][custom_value.custom_field_id.to_s].to_s
|
|
| 121 | 121 |
return false |
| 122 | 122 |
end |
| 123 | 123 |
end |
| test/functional/project_enumerations_controller_test.rb | ||
|---|---|---|
| 93 | 93 |
assert_nil project.time_entry_activities.find_by_name("QA"), "Custom QA activity created when it wasn't modified"
|
| 94 | 94 |
end |
| 95 | 95 | |
| 96 |
def test_update_should_not_create_project_specific_activities_when_setting_empty_value_in_custom_field_with_default_value_of_nil |
|
| 97 |
system_activity = TimeEntryActivity.find(9) # Design |
|
| 98 |
custom_field_value = system_activity.custom_field_values.detect{|cfv| cfv.custom_field.id == 7}
|
|
| 99 |
assert_nil custom_field_value.value |
|
| 100 | ||
| 101 |
assert_no_difference 'TimeEntryActivity.count' do |
|
| 102 |
@request.session[:user_id] = 2 # manager |
|
| 103 |
put( |
|
| 104 |
:update, |
|
| 105 |
:params => {
|
|
| 106 |
:project_id => 1, |
|
| 107 |
:enumerations => {
|
|
| 108 |
"9" => {"parent_id" => "9", "custom_field_values" => {"7" => ""}, "active" => "1"}
|
|
| 109 |
} |
|
| 110 |
} |
|
| 111 |
) |
|
| 112 |
assert_response :redirect |
|
| 113 |
end |
|
| 114 |
end |
|
| 115 | ||
| 96 | 116 |
def test_update_will_update_project_specific_activities |
| 97 | 117 |
@request.session[:user_id] = 2 # manager |
| 98 | 118 | |
| test/unit/time_entry_activity_test.rb | ||
|---|---|---|
| 144 | 144 |
parent_activity.id.to_s => {
|
| 145 | 145 |
'parent_id' => parent_activity.id.to_s, |
| 146 | 146 |
'active' => '0', |
| 147 |
'custom_field_values' => {'7' => ''}
|
|
| 147 |
'custom_field_values' => {'7' => '1'}
|
|
| 148 | 148 |
} |
| 149 | 149 |
} |
| 150 | 150 |
) |
| ... | ... | |
| 158 | 158 |
other_parent_activity.id.to_s => {
|
| 159 | 159 |
'parent_id' => other_parent_activity.id.to_s, |
| 160 | 160 |
'active' => '0', |
| 161 |
'custom_field_values' => {'7' => ''}
|
|
| 161 |
'custom_field_values' => {'7' => '1'}
|
|
| 162 | 162 |
} |
| 163 | 163 |
} |
| 164 | 164 |
) |
| ... | ... | |
| 179 | 179 |
parent_activity.id.to_s => {
|
| 180 | 180 |
'parent_id' => parent_activity.id.to_s, |
| 181 | 181 |
'active' => '0', |
| 182 |
'custom_field_values' => {'7' => ''}
|
|
| 182 |
'custom_field_values' => {'7' => '1'}
|
|
| 183 | 183 |
} |
| 184 | 184 |
} |
| 185 | 185 |
) |
| ... | ... | |
| 196 | 196 |
assert_equal 'Design2', project_activity.reload.name |
| 197 | 197 |
assert_equal 'Design3', parent_activity.reload.name |
| 198 | 198 |
end |
| 199 | ||
| 200 |
def test_project_activity_should_not_create_with_same_value_as_system_activity |
|
| 201 |
system_activity = TimeEntryActivity.find(9) # Design |
|
| 202 |
assert_equal true, system_activity.active |
|
| 203 | ||
| 204 |
custom_field_value = system_activity.custom_field_values.detect{|cfv| cfv.custom_field.id == 7}
|
|
| 205 |
assert_nil custom_field_value.value |
|
| 206 | ||
| 207 |
project = Project.find(1) |
|
| 208 |
assert_equal 0, project.time_entry_activities.count |
|
| 209 | ||
| 210 |
assert_no_difference 'TimeEntryActivity.count' do |
|
| 211 |
project.update_or_create_time_entry_activities( |
|
| 212 |
{
|
|
| 213 |
'9' => {
|
|
| 214 |
'parent_id' => '9', |
|
| 215 |
'active' => '1', |
|
| 216 |
'custom_field_values' => {'7' => ''}
|
|
| 217 |
} |
|
| 218 |
} |
|
| 219 |
) |
|
| 220 |
end |
|
| 221 |
end |
|
| 199 | 222 |
end |
- « Previous
- 1
- 2
- 3
- Next »