Add schema tests
This commit is contained in:
parent
ddb1d326e0
commit
199a4db2c4
|
@ -12,7 +12,7 @@ class IssuableSidebarEntity < Grape::Entity
|
||||||
expose :project_id do |issuable|
|
expose :project_id do |issuable|
|
||||||
issuable.project.id
|
issuable.project.id
|
||||||
end
|
end
|
||||||
expose :discussion_locked?, as: :discussion_locked
|
expose :discussion_locked
|
||||||
expose :reference do |issuable|
|
expose :reference do |issuable|
|
||||||
issuable.to_reference(issuable.project, full: true)
|
issuable.to_reference(issuable.project, full: true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties" : {
|
||||||
|
"id": { "type": "integer" },
|
||||||
|
"delete_path": { "type": "string" }
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
|
@ -2,20 +2,49 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"id": { "type": "integer" },
|
"id": { "type": "integer" },
|
||||||
"iid": { "type": "integer" },
|
"type": { "type": "string" },
|
||||||
"subscribed": { "type": "boolean" },
|
"author_id": { "type": "integer" },
|
||||||
"time_estimate": { "type": "integer" },
|
"project_id": { "type": "integer" },
|
||||||
"total_time_spent": { "type": "integer" },
|
"discussion_locked": { "type": ["boolean", "null"] },
|
||||||
"human_time_estimate": { "type": ["integer", "null"] },
|
"due_date": { "type": "date" },
|
||||||
"human_total_time_spent": { "type": ["integer", "null"] },
|
"confidential": { "type": "boolean" },
|
||||||
"participants": {
|
"reference": { "type": "string" },
|
||||||
"type": "array",
|
"current_user": {
|
||||||
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
"oneOf": [
|
||||||
|
{ "type": "null" },
|
||||||
|
{ "$ref": "user.json" }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"assignees": {
|
"todo": {
|
||||||
|
"oneOf": [
|
||||||
|
{ "type": "null" },
|
||||||
|
{ "$ref": "issuable_sidebar_todo.json" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"milestone": {
|
||||||
|
"oneOf": [
|
||||||
|
{ "type": "null" },
|
||||||
|
{ "$ref": "../public_api/v4/milestone.json" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
"items": { "$ref": "label.json" }
|
||||||
}
|
},
|
||||||
},
|
"signed_in": { "type": "boolean" },
|
||||||
"additionalProperties": false
|
"can_edit": { "type": "boolean" },
|
||||||
|
"can_move": { "type": "boolean" },
|
||||||
|
"can_admin_label": { "type": "boolean" },
|
||||||
|
"issuable_json_path": { "type": "string" },
|
||||||
|
"namespace_path": { "type": "string" },
|
||||||
|
"project_path": { "type": "string" },
|
||||||
|
"project_full_path": { "type": "string" },
|
||||||
|
"project_issuables_path": { "type": "string" },
|
||||||
|
"create_todo_path": { "type": "string" },
|
||||||
|
"project_milestones_path": { "type": "string" },
|
||||||
|
"project_labels_path": { "type": "string" },
|
||||||
|
"toggle_subscription_path": { "type": "string" },
|
||||||
|
"move_issue_path": { "type": "string" },
|
||||||
|
"projects_autocomplete_path": { "type": "string" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties" : {
|
||||||
|
"subscribed": { "type": "boolean" },
|
||||||
|
"time_estimate": { "type": "integer" },
|
||||||
|
"total_time_spent": { "type": "integer" },
|
||||||
|
"human_time_estimate": { "type": ["integer", "null"] },
|
||||||
|
"human_total_time_spent": { "type": ["integer", "null"] },
|
||||||
|
"participants": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
||||||
|
},
|
||||||
|
"assignees": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,20 +2,52 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"id": { "type": "integer" },
|
"id": { "type": "integer" },
|
||||||
"iid": { "type": "integer" },
|
"type": { "type": "string" },
|
||||||
"subscribed": { "type": "boolean" },
|
"author_id": { "type": "integer" },
|
||||||
"time_estimate": { "type": "integer" },
|
"project_id": { "type": "integer" },
|
||||||
"total_time_spent": { "type": "integer" },
|
"discussion_locked": { "type": ["boolean", "null"] },
|
||||||
"human_time_estimate": { "type": ["integer", "null"] },
|
"reference": { "type": "string" },
|
||||||
"human_total_time_spent": { "type": ["integer", "null"] },
|
"current_user": {
|
||||||
"participants": {
|
"oneOf": [
|
||||||
"type": "array",
|
{ "type": "null" },
|
||||||
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
{ "$ref": "user.json" }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"assignees": {
|
"todo": {
|
||||||
|
"oneOf": [
|
||||||
|
{ "type": "null" },
|
||||||
|
{ "$ref": "issuable_sidebar_todo.json" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"milestone": {
|
||||||
|
"oneOf": [
|
||||||
|
{ "type": "null" },
|
||||||
|
{ "$ref": "../public_api/v4/milestones.json" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
"items": { "$ref": "label.json" }
|
||||||
}
|
},
|
||||||
|
"assignee": {
|
||||||
|
"$ref": "../public_api/v4/user/basic.json"
|
||||||
|
},
|
||||||
|
"signed_in": { "type": "boolean" },
|
||||||
|
"can_edit": { "type": "boolean" },
|
||||||
|
"can_move": { "type": "boolean" },
|
||||||
|
"can_admin_label": { "type": "boolean" },
|
||||||
|
"can_merge": { "type": ["boolean", "null"] },
|
||||||
|
"issuable_json_path": { "type": "string" },
|
||||||
|
"namespace_path": { "type": "string" },
|
||||||
|
"project_path": { "type": "string" },
|
||||||
|
"project_full_path": { "type": "string" },
|
||||||
|
"project_issuables_path": { "type": "string" },
|
||||||
|
"create_todo_path": { "type": "string" },
|
||||||
|
"project_milestones_path": { "type": "string" },
|
||||||
|
"project_labels_path": { "type": "string" },
|
||||||
|
"toggle_subscription_path": { "type": "string" },
|
||||||
|
"move_issue_path": { "type": "string" },
|
||||||
|
"projects_autocomplete_path": { "type": "string" }
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties" : {
|
||||||
|
"id": { "type": "integer" },
|
||||||
|
"iid": { "type": "integer" },
|
||||||
|
"subscribed": { "type": "boolean" },
|
||||||
|
"time_estimate": { "type": "integer" },
|
||||||
|
"total_time_spent": { "type": "integer" },
|
||||||
|
"human_time_estimate": { "type": ["integer", "null"] },
|
||||||
|
"human_total_time_spent": { "type": ["integer", "null"] },
|
||||||
|
"participants": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
||||||
|
},
|
||||||
|
"assignees": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "../public_api/v4/user/basic.json" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties" : {
|
||||||
|
"id": { "type": "integer" },
|
||||||
|
"iid": { "type": "integer" },
|
||||||
|
"project_id": { "type": ["integer", "null"] },
|
||||||
|
"group_id": { "type": ["integer", "null"] },
|
||||||
|
"title": { "type": "string" },
|
||||||
|
"description": { "type": ["string", "null"] },
|
||||||
|
"state": { "type": "string" },
|
||||||
|
"created_at": { "type": "date" },
|
||||||
|
"updated_at": { "type": "date" },
|
||||||
|
"start_date": { "type": "date" },
|
||||||
|
"due_date": { "type": "date" },
|
||||||
|
"web_url": { "type": "string" }
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id", "iid", "title", "description", "state",
|
||||||
|
"state", "created_at", "updated_at", "start_date", "due_date"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
|
@ -1,25 +1,6 @@
|
||||||
{
|
{
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"$ref": "./milestone.json"
|
||||||
"properties" : {
|
|
||||||
"id": { "type": "integer" },
|
|
||||||
"iid": { "type": "integer" },
|
|
||||||
"project_id": { "type": ["integer", "null"] },
|
|
||||||
"group_id": { "type": ["integer", "null"] },
|
|
||||||
"title": { "type": "string" },
|
|
||||||
"description": { "type": ["string", "null"] },
|
|
||||||
"state": { "type": "string" },
|
|
||||||
"created_at": { "type": "date" },
|
|
||||||
"updated_at": { "type": "date" },
|
|
||||||
"start_date": { "type": "date" },
|
|
||||||
"due_date": { "type": "date" },
|
|
||||||
"web_url": { "type": "string" }
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"id", "iid", "title", "description", "state",
|
|
||||||
"state", "created_at", "updated_at", "start_date", "due_date"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,18 @@ describe IssueSerializer do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'sidebar issue serialization' do
|
context 'sidebar issue serialization' do
|
||||||
|
let(:serializer) { 'sidebar' }
|
||||||
|
|
||||||
|
it 'matches issue_sidebar json schema' do
|
||||||
|
expect(json_entity).to match_schema('entities/issue_sidebar')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'sidebar extras issue serialization' do
|
||||||
let(:serializer) { 'sidebar_extras' }
|
let(:serializer) { 'sidebar_extras' }
|
||||||
|
|
||||||
it 'matches sidebar issue json schema' do
|
it 'matches issue_sidebar_extras json schema' do
|
||||||
expect(json_entity).to match_schema('entities/issue_sidebar')
|
expect(json_entity).to match_schema('entities/issue_sidebar_extras')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,18 @@ describe MergeRequestSerializer do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'sidebar merge request serialization' do
|
context 'sidebar merge request serialization' do
|
||||||
|
let(:serializer) { 'sidebar' }
|
||||||
|
|
||||||
|
it 'matches merge_request_sidebar json schema' do
|
||||||
|
expect(json_entity).to match_schema('entities/merge_request_sidebar')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'sidebar_extras merge request serialization' do
|
||||||
let(:serializer) { 'sidebar_extras' }
|
let(:serializer) { 'sidebar_extras' }
|
||||||
|
|
||||||
it 'matches sidebar merge request json schema' do
|
it 'matches merge_request_sidebar_extras json schema' do
|
||||||
expect(json_entity).to match_schema('entities/merge_request_sidebar')
|
expect(json_entity).to match_schema('entities/merge_request_sidebar_extras')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue