summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Derichs <pderichs@gitlab.com>2019-09-11 14:49:08 +0200
committerPatrick Derichs <pderichs@gitlab.com>2019-09-12 15:35:50 +0200
commite256fa0448ab191f754ccc2aed02d63736106fe5 (patch)
treecadd39eb4abe272c4a8ab0e1baf8f5bf85f79811
parent1928932388f063b064dde9d235b6474121a726c0 (diff)
downloadgitlab-ce-11403-max-issue-count-on-lists-ce.tar.gz
Add max issue count to lists11403-max-issue-count-on-lists-ce
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
-rw-r--r--app/controllers/boards/lists_controller.rb6
-rw-r--r--app/services/boards/lists/create_service.rb6
-rw-r--r--app/services/boards/lists/update_service.rb12
-rw-r--r--db/migrate/20190901174200_add_max_issue_count_to_list.rb16
-rw-r--r--db/schema.rb1
-rw-r--r--spec/fixtures/api/schemas/list.json3
-rw-r--r--spec/fixtures/api/schemas/public_api/v4/board.json3
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml1
8 files changed, 42 insertions, 6 deletions
diff --git a/app/controllers/boards/lists_controller.rb b/app/controllers/boards/lists_controller.rb
index 08b4748d7e1..f9c30c95455 100644
--- a/app/controllers/boards/lists_controller.rb
+++ b/app/controllers/boards/lists_controller.rb
@@ -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)
diff --git a/app/services/boards/lists/create_service.rb b/app/services/boards/lists/create_service.rb
index 48d2d5abaec..695981fbabf 100644
--- a/app/services/boards/lists/create_service.rb
+++ b/app/services/boards/lists/create_service.rb
@@ -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
diff --git a/app/services/boards/lists/update_service.rb b/app/services/boards/lists/update_service.rb
index 2ddeb6f0bd8..35ce81d9968 100644
--- a/app/services/boards/lists/update_service.rb
+++ b/app/services/boards/lists/update_service.rb
@@ -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?
diff --git a/db/migrate/20190901174200_add_max_issue_count_to_list.rb b/db/migrate/20190901174200_add_max_issue_count_to_list.rb
new file mode 100644
index 00000000000..59359f28d6a
--- /dev/null
+++ b/db/migrate/20190901174200_add_max_issue_count_to_list.rb
@@ -0,0 +1,16 @@
+# 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
diff --git a/db/schema.rb b/db/schema.rb
index 39faf1e651e..8b4a5caf2c9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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"
diff --git a/spec/fixtures/api/schemas/list.json b/spec/fixtures/api/schemas/list.json
index b76ec115293..7603892e198 100644
--- a/spec/fixtures/api/schemas/list.json
+++ b/spec/fixtures/api/schemas/list.json
@@ -35,7 +35,8 @@
}
},
"title": { "type": "string" },
- "position": { "type": ["integer", "null"] }
+ "position": { "type": ["integer", "null"] },
+ "max_issue_count": { "type": "integer" }
},
"additionalProperties": true
}
diff --git a/spec/fixtures/api/schemas/public_api/v4/board.json b/spec/fixtures/api/schemas/public_api/v4/board.json
index d667f1d631c..8dc3999baa2 100644
--- a/spec/fixtures/api/schemas/public_api/v4/board.json
+++ b/spec/fixtures/api/schemas/public_api/v4/board.json
@@ -76,7 +76,8 @@
"name": { "type": "string" }
}
},
- "position": { "type": ["integer", "null"] }
+ "position": { "type": ["integer", "null"] },
+ "max_issue_count": { "type": "integer" }
},
"additionalProperties": false
}
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index e9750d23c53..51b8cffb85e 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -716,6 +716,7 @@ List:
- updated_at
- milestone_id
- user_id
+- max_issue_count
ExternalPullRequest:
- id
- created_at