Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/api/.database_consistency.todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ AttribValue:
id:
PrimaryKeyTypeChecker:
enabled: false
position:
NullConstraintChecker:
enabled: false
value:
LengthConstraintChecker:
enabled: false
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/source_attribute_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def update
attrib_type = AttribType.find_by_namespace_and_name!(attr.value('namespace'), attr.value('name'))
attrib = Attrib.new(attrib_type: attrib_type)

attr.elements('value') do |value|
attrib.values.new(value: value)
attr.elements('value').zip(attr.elements('position')).each do |(value, position)|
attrib.values.new(value: value, position: position)
end

attrib.container = @attribute_container
Expand Down
2 changes: 2 additions & 0 deletions src/api/app/models/attrib_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class AttribValue < ApplicationRecord
acts_as_list scope: :attrib
belongs_to :attrib, optional: false

validates :position, presence: true

after_initialize :set_default_value
before_validation :universal_newlines

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<<~XMLATTRIB
<attributes>
<attribute namespace='#{update_project_attrib.namespace}' name='#{update_project_attrib.name}'>
<position>1</position>
<value>1111112</value>
</attribute>
</attributes>
Expand Down
3 changes: 3 additions & 0 deletions src/api/test/functional/request_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3737,6 +3737,7 @@ def test_ordering_of_requests
login_king
post '/source/BaseDistro2.0/_attribute', params: "<attributes><attribute namespace='OBS' name='IncidentPriority' >
<value>100</value>
<position>1</position>
</attribute></attributes>"
assert_response :success
get '/search/request', params: { match: "target/@project = 'home:Iggy'" }
Expand All @@ -3749,6 +3750,7 @@ def test_ordering_of_requests
# make the low and important request equal high prio
post '/source/BaseDistro/_attribute', params: "<attributes><attribute namespace='OBS' name='IncidentPriority' >
<value>100</value>
<position>1</position>
</attribute></attributes>"
assert_response :success
get '/search/request', params: { match: "target/@project = 'home:Iggy'" }
Expand All @@ -3763,6 +3765,7 @@ def test_ordering_of_requests
# make the low most important
post '/source/BaseDistro/_attribute', params: "<attributes><attribute namespace='OBS' name='IncidentPriority' >
<value>101</value>
<position>1</position>
</attribute></attributes>"
assert_response :success
get '/search/request', params: { match: "target/@project = 'home:Iggy'" }
Expand Down