Project

General

Profile

Defect #36318 » 36318.patch

Yuichi HARADA, 2021-12-15 03:10

View differences:

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

  
(2-2/3)