提交 e256fa04 编写于 作者: P Patrick Derichs

Add max issue count to lists

Add spec for update of max_issue_count on lists

Failing spec

Rename migration file

Add max_issue_count to schema.rb

Add model validation for max_issue_count

Add license check for max_issue_count

Extract method create_list_attributes

Remove validation for max_issue_count

Add MR to changelog

Remove unnecessary comment

Remove unnecessary allow_null: false

Remove CE changelog entry

Remove possible null value for max_issue_count from schema definitions
上级 19289323
......@@ -64,12 +64,16 @@ module Boards
%i[label_id]
end
def list_update_attrs
%i[collapsed position]
end
def create_list_params
params.require(:list).permit(list_creation_attrs)
end
def update_list_params
params.require(:list).permit(:collapsed, :position)
params.require(:list).permit(list_update_attrs)
end
def serialize_as_json(resource)
......
......@@ -43,7 +43,11 @@ module Boards
end
def create_list(board, type, target, position)
board.lists.create(type => target, list_type: type, position: position)
board.lists.create(create_list_attributes(type, target, position))
end
def create_list_attributes(type, target, position)
{ type => target, list_type: type, position: position }
end
end
end
......
......@@ -5,15 +5,23 @@ module Boards
class UpdateService < Boards::BaseService
def execute(list)
return not_authorized if preferences? && !can_read?(list)
return not_authorized if position? && !can_admin?(list)
return not_authorized if list_properties? && !can_admin?(list)
if update_preferences(list) || update_position(list)
if execute_by_params(list)
success(list: list)
else
error(list.errors.messages, 422)
end
end
def execute_by_params(list)
update_preferences(list) || update_position(list)
end
def list_properties?
position?
end
def update_preferences(list)
return unless preferences?
......
# frozen_string_literal: true
class AddMaxIssueCountToList < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default :lists, :max_issue_count, :integer, default: 0
end
def down
remove_column :lists, :max_issue_count
end
end
......@@ -1972,6 +1972,7 @@ ActiveRecord::Schema.define(version: 2019_09_12_061145) do
t.datetime "updated_at", null: false
t.integer "milestone_id"
t.integer "user_id"
t.integer "max_issue_count", default: 0, null: false
t.index ["board_id", "label_id"], name: "index_lists_on_board_id_and_label_id", unique: true
t.index ["label_id"], name: "index_lists_on_label_id"
t.index ["list_type"], name: "index_lists_on_list_type"
......
......@@ -35,7 +35,8 @@
}
},
"title": { "type": "string" },
"position": { "type": ["integer", "null"] }
"position": { "type": ["integer", "null"] },
"max_issue_count": { "type": "integer" }
},
"additionalProperties": true
}
......@@ -76,7 +76,8 @@
"name": { "type": "string" }
}
},
"position": { "type": ["integer", "null"] }
"position": { "type": ["integer", "null"] },
"max_issue_count": { "type": "integer" }
},
"additionalProperties": false
}
......
......@@ -716,6 +716,7 @@ List:
- updated_at
- milestone_id
- user_id
- max_issue_count
ExternalPullRequest:
- id
- created_at
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册