Skip to content

Commit

Permalink
Avoid parameter loss when sort issue_template (agileware-jp#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumojima authored Mar 20, 2023
1 parent 53fcf2a commit ebca97f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/concerns/issue_templates_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def builtin_fields_json
end

def valid_params
return template_params unless template_params.has_key?(:builtin_fields)
attributes = template_params.except(:builtin_fields)
attributes[:builtin_fields_json] = builtin_fields_json if builtin_fields_enabled?
attributes
Expand Down
10 changes: 10 additions & 0 deletions spec/controllers/issue_templates_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,15 @@
expect(issue_template.reload.title).to eq 'Issue Template updated title for update test'
end
end

context 'update position' do
let(:update_params) { { issue_template: { position: 10 } } }
let(:issue_template) { create :issue_template, builtin_fields_json: { key: "value" }}

it 'not updated builtin_fields' do
issue_template.reload
expect(issue_template.builtin_fields_json).to eq({ key: "value" })
end
end
end
end

0 comments on commit ebca97f

Please sign in to comment.