Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
8ccbb53e68
commit
3159925155
|
@ -13,7 +13,7 @@
|
|||
],
|
||||
"rules":{
|
||||
"max-nesting-depth": [
|
||||
6,
|
||||
5,
|
||||
{
|
||||
"ignoreAtRules":[
|
||||
"each",
|
||||
|
|
|
@ -2,10 +2,8 @@ import initAdminStatisticsPanel from '../../admin/statistics_panel/index';
|
|||
import initVueAlerts from '../../vue_alerts';
|
||||
import initAdmin from './admin';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initVueAlerts);
|
||||
initVueAlerts();
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const statisticsPanelContainer = document.getElementById('js-admin-statistics-container');
|
||||
initAdmin();
|
||||
initAdminStatisticsPanel(statisticsPanelContainer);
|
||||
});
|
||||
const statisticsPanelContainer = document.getElementById('js-admin-statistics-container');
|
||||
initAdmin();
|
||||
initAdminStatisticsPanel(statisticsPanelContainer);
|
||||
|
|
|
@ -45,8 +45,7 @@
|
|||
|
||||
a {
|
||||
font-family: $monospace-font;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
display: block;
|
||||
font-size: $code-font-size !important;
|
||||
white-space: nowrap;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ module Mutations
|
|||
response = ::Boards::CreateService.new(board_parent, current_user, args).execute
|
||||
|
||||
{
|
||||
board: response.success? ? response.payload : nil,
|
||||
board: response.payload,
|
||||
errors: response.errors
|
||||
}
|
||||
end
|
||||
|
|
|
@ -19,7 +19,14 @@ end
|
|||
module Types
|
||||
class GlobalIDType < BaseScalar
|
||||
graphql_name 'GlobalID'
|
||||
description 'A global identifier'
|
||||
description <<~DESC
|
||||
A global identifier.
|
||||
|
||||
A global identifier represents an object uniquely across the application.
|
||||
An example of such an identifier is "gid://gitlab/User/1".
|
||||
|
||||
Global identifiers are encoded as strings.
|
||||
DESC
|
||||
|
||||
# @param value [GID]
|
||||
# @return [String]
|
||||
|
@ -46,38 +53,40 @@ module Types
|
|||
|
||||
@id_types[model_class] ||= Class.new(self) do
|
||||
graphql_name "#{model_class.name.gsub(/::/, '')}ID"
|
||||
description "Identifier of #{model_class.name}."
|
||||
description <<~MD
|
||||
A `#{graphql_name}` is a global ID. It is encoded as a string.
|
||||
|
||||
self.define_singleton_method(:to_s) do
|
||||
An example `#{graphql_name}` is: `"#{::Gitlab::GlobalId.build(model_name: model_class.name, id: 1)}"`.
|
||||
MD
|
||||
|
||||
define_singleton_method(:to_s) do
|
||||
graphql_name
|
||||
end
|
||||
|
||||
self.define_singleton_method(:inspect) do
|
||||
define_singleton_method(:inspect) do
|
||||
graphql_name
|
||||
end
|
||||
|
||||
self.define_singleton_method(:coerce_result) do |gid, ctx|
|
||||
define_singleton_method(:coerce_result) do |gid, ctx|
|
||||
global_id = ::Gitlab::GlobalId.as_global_id(gid, model_name: model_class.name)
|
||||
|
||||
if suitable?(global_id)
|
||||
global_id.to_s
|
||||
else
|
||||
raise GraphQL::CoercionError, "Expected a #{model_class.name} ID, got #{global_id}"
|
||||
end
|
||||
next global_id.to_s if suitable?(global_id)
|
||||
|
||||
raise GraphQL::CoercionError, "Expected a #{model_class.name} ID, got #{global_id}"
|
||||
end
|
||||
|
||||
self.define_singleton_method(:suitable?) do |gid|
|
||||
define_singleton_method(:suitable?) do |gid|
|
||||
next false if gid.nil?
|
||||
|
||||
gid.model_name.safe_constantize.present? &&
|
||||
gid.model_class.ancestors.include?(model_class)
|
||||
end
|
||||
|
||||
self.define_singleton_method(:coerce_input) do |string, ctx|
|
||||
define_singleton_method(:coerce_input) do |string, ctx|
|
||||
gid = super(string, ctx)
|
||||
raise GraphQL::CoercionError, "#{string.inspect} does not represent an instance of #{model_class.name}" unless suitable?(gid)
|
||||
next gid if suitable?(gid)
|
||||
|
||||
gid
|
||||
raise GraphQL::CoercionError, "#{string.inspect} does not represent an instance of #{model_class.name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,13 @@
|
|||
module Types
|
||||
class TimeType < BaseScalar
|
||||
graphql_name 'Time'
|
||||
description 'Time represented in ISO 8601'
|
||||
description <<~DESC
|
||||
Time represented in ISO 8601.
|
||||
|
||||
For example: "2021-03-09T14:58:50+00:00".
|
||||
|
||||
See `https://www.iso.org/iso-8601-date-and-time-format.html`.
|
||||
DESC
|
||||
|
||||
def self.coerce_input(value, ctx)
|
||||
Time.parse(value)
|
||||
|
|
|
@ -27,6 +27,7 @@ module AlertManagement
|
|||
before_validation :prevent_token_assignment
|
||||
before_validation :prevent_endpoint_identifier_assignment
|
||||
before_validation :ensure_token
|
||||
before_validation :ensure_payload_example_not_nil
|
||||
|
||||
scope :for_endpoint_identifier, -> (endpoint_identifier) { where(endpoint_identifier: endpoint_identifier) }
|
||||
scope :active, -> { where(active: true) }
|
||||
|
@ -74,5 +75,9 @@ module AlertManagement
|
|||
self.endpoint_identifier = endpoint_identifier_was
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_payload_example_not_nil
|
||||
self.payload_example ||= {}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,7 +42,11 @@ module Packages
|
|||
created_at: package_file.created_at,
|
||||
download_path: package_file.download_path,
|
||||
file_name: package_file.file_name,
|
||||
size: package_file.size
|
||||
size: package_file.size,
|
||||
file_md5: package_file.file_md5,
|
||||
file_sha1: package_file.file_sha1,
|
||||
file_sha256: package_file.file_sha256
|
||||
|
||||
}
|
||||
|
||||
file_view[:pipelines] = build_pipeline_infos(package_file.pipelines) if package_file.pipelines.present?
|
||||
|
|
|
@ -2,26 +2,23 @@
|
|||
|
||||
.form-group
|
||||
%b= s_('ProjectSettings|Merge checks')
|
||||
%p.text-secondary= s_('ProjectSettings|These checks must pass before merge requests can be merged')
|
||||
%p.text-secondary= s_('ProjectSettings|These checks must pass before merge requests can be merged.')
|
||||
.form-check.mb-2.builds-feature
|
||||
= form.check_box :only_allow_merge_if_pipeline_succeeds, class: 'form-check-input'
|
||||
= form.label :only_allow_merge_if_pipeline_succeeds, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|Pipelines must succeed')
|
||||
.text-secondary
|
||||
= s_('ProjectSettings|Pipelines need to be configured to enable this feature.')
|
||||
= link_to sprite_icon('question-o'),
|
||||
help_page_path('ci/merge_request_pipelines/index.md',
|
||||
anchor: 'pipelines-for-merge-requests'),
|
||||
target: '_blank'
|
||||
- configuring_pipelines_for_merge_requests_help_link_url = help_page_path('ci/merge_request_pipelines/index.md', anchor: 'configuring-pipelines-for-merge-requests')
|
||||
- configuring_pipelines_for_merge_requests_help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: configuring_pipelines_for_merge_requests_help_link_url }
|
||||
= s_('ProjectSettings|To enable this feature, configure pipelines. %{link_start}How to configure pipelines for merge requests?%{link_end}').html_safe % { link_start: configuring_pipelines_for_merge_requests_help_link_start, link_end: '</a>'.html_safe }
|
||||
.form-check.mb-2
|
||||
.gl-pl-6
|
||||
= form.check_box :allow_merge_on_skipped_pipeline, class: 'form-check-input'
|
||||
= form.label :allow_merge_on_skipped_pipeline, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|Skipped pipelines are considered successful')
|
||||
.text-secondary
|
||||
= s_('ProjectSettings|This introduces the risk of merging changes that will not pass the pipeline.')
|
||||
= s_('ProjectSettings|Introduces the risk of merging changes that do not pass the pipeline.')
|
||||
.form-check.mb-2
|
||||
= form.check_box :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-input', data: { qa_selector: 'allow_merge_if_all_discussions_are_resolved_checkbox' }
|
||||
= form.label :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|All discussions must be resolved')
|
||||
= render_if_exists 'projects/merge_request_merge_checks_jira_enforcement', form: form, project: @project
|
||||
|
|
|
@ -2,32 +2,32 @@
|
|||
|
||||
.form-group
|
||||
%b= s_('ProjectSettings|Merge method')
|
||||
%p.text-secondary= s_('ProjectSettings|This will dictate the commit history when you merge a merge request')
|
||||
%p.text-secondary= s_('ProjectSettings|Determine what happens to the commit history when you merge a merge request.')
|
||||
.form-check.mb-2
|
||||
= form.radio_button :merge_method, :merge, class: "js-merge-method-radio form-check-input"
|
||||
= label_tag :project_merge_method_merge, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|Merge commit')
|
||||
.text-secondary
|
||||
= s_('ProjectSettings|Every merge creates a merge commit')
|
||||
= s_('ProjectSettings|Every merge creates a merge commit.')
|
||||
|
||||
.form-check.mb-2
|
||||
= form.radio_button :merge_method, :rebase_merge, class: "js-merge-method-radio form-check-input"
|
||||
= label_tag :project_merge_method_rebase_merge, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|Merge commit with semi-linear history')
|
||||
.text-secondary
|
||||
= s_('ProjectSettings|Every merge creates a merge commit')
|
||||
= s_('ProjectSettings|Every merge creates a merge commit.')
|
||||
%br
|
||||
= s_('ProjectSettings|Fast-forward merges only')
|
||||
= s_('ProjectSettings|Fast-forward merges only.')
|
||||
%br
|
||||
= s_('ProjectSettings|When conflicts arise the user is given the option to rebase')
|
||||
= s_('ProjectSettings|When there is a merge conflict, the user is given the option to rebase.')
|
||||
|
||||
.form-check.mb-2
|
||||
= form.radio_button :merge_method, :ff, class: "js-merge-method-radio form-check-input", data: { qa_selector: 'merge_ff_radio_button' }
|
||||
= label_tag :project_merge_method_ff, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|Fast-forward merge')
|
||||
.text-secondary
|
||||
= s_('ProjectSettings|No merge commits are created')
|
||||
= s_('ProjectSettings|No merge commits are created.')
|
||||
%br
|
||||
= s_('ProjectSettings|Fast-forward merges only')
|
||||
= s_('ProjectSettings|Fast-forward merges only.')
|
||||
%br
|
||||
= s_('ProjectSettings|When conflicts arise the user is given the option to rebase')
|
||||
= s_('ProjectSettings|When there is a merge conflict, the user is given the option to rebase.')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
.form-group#project-merge-options{ data: { project_full_path: @project.full_path } }
|
||||
%b= s_('ProjectSettings|Merge options')
|
||||
%p.text-secondary= s_('ProjectSettings|Additional merge request capabilities that influence how and when merges will be performed')
|
||||
%p.text-secondary= s_('ProjectSettings|Additional settings that influence how and when merges are done.')
|
||||
= render_if_exists 'projects/merge_pipelines_settings', form: form
|
||||
= render_if_exists 'projects/merge_trains_settings', form: form
|
||||
.form-check.mb-2
|
||||
|
@ -12,10 +12,10 @@
|
|||
.form-check.mb-2
|
||||
= form.check_box :printing_merge_request_link_enabled, class: 'form-check-input'
|
||||
= form.label :printing_merge_request_link_enabled, class: 'form-check-label' do
|
||||
= s_('ProjectSettings|Show link to create/view merge request when pushing from the command line')
|
||||
= s_('ProjectSettings|Show link to create or view a merge request when pushing from the command line')
|
||||
.form-check.mb-2
|
||||
= form.check_box :remove_source_branch_after_merge, class: 'form-check-input'
|
||||
= form.label :remove_source_branch_after_merge, class: 'form-check-label' do
|
||||
= s_("ProjectSettings|Enable 'Delete source branch' option by default")
|
||||
= s_('ProjectSettings|Enable "Delete source branch" option by default')
|
||||
.descr.text-secondary
|
||||
= s_('ProjectSettings|Existing merge requests and protected branches are not affected')
|
||||
= s_('ProjectSettings|Existing merge requests and protected branches are not affected.')
|
||||
|
|
|
@ -3,15 +3,13 @@
|
|||
.form-group
|
||||
%b= s_('ProjectSettings|Merge suggestions')
|
||||
%p.text-secondary
|
||||
= s_('ProjectSettings|The commit message used to apply merge request suggestions')
|
||||
= link_to sprite_icon('question-o'),
|
||||
help_page_path('user/discussions/index.md',
|
||||
anchor: 'configure-the-commit-message-for-applied-suggestions'),
|
||||
target: '_blank'
|
||||
- configure_the_commit_message_for_applied_suggestions_help_link_url = help_page_path('user/discussions/index.md', anchor: 'configure-the-commit-message-for-applied-suggestions')
|
||||
- configure_the_commit_message_for_applied_suggestions_help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: configure_the_commit_message_for_applied_suggestions_help_link_url }
|
||||
= s_('ProjectSettings|The commit message used when applying merge request suggestions. %{link_start}Learn more about suggestions.%{link_end}').html_safe % { link_start: configure_the_commit_message_for_applied_suggestions_help_link_start, link_end: '</a>'.html_safe }
|
||||
.mb-2
|
||||
= form.text_field :suggestion_commit_message, class: 'form-control gl-form-input mb-2', placeholder: Gitlab::Suggestions::CommitMessage::DEFAULT_SUGGESTION_COMMIT_MESSAGE
|
||||
= form.text_field :suggestion_commit_message, class: 'form-control mb-2', placeholder: Gitlab::Suggestions::CommitMessage::DEFAULT_SUGGESTION_COMMIT_MESSAGE
|
||||
%p.form-text.text-muted
|
||||
= s_('ProjectSettings|The variables GitLab supports:')
|
||||
= s_('ProjectSettings|Supported variables:')
|
||||
- Gitlab::Suggestions::CommitMessage::PLACEHOLDERS.keys.each do |placeholder|
|
||||
%code
|
||||
= "%{#{placeholder}}".html_safe
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.form-group
|
||||
%b= s_('ProjectSettings|Squash commits when merging')
|
||||
%p.text-secondary
|
||||
= s_('ProjectSettings|Set the default behavior and availability of this option in merge requests. Changes made are also applied to existing merge requests.')
|
||||
= s_('ProjectSettings|Set the default behavior of this option in merge requests. Changes to this are also applied to existing merge requests.')
|
||||
= link_to "What is squashing?",
|
||||
help_page_path('user/project/merge_requests/squash_and_merge.md'),
|
||||
target: '_blank'
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
%td.line-numbers
|
||||
- (current_line...(current_line + line_count)).each do |i|
|
||||
%a.diff-line-num{ href: "#L#{i}", id: "L#{i}", 'data-line-number' => i }
|
||||
%a.diff-line-num.gl-justify-content-end{ href: "#L#{i}", id: "L#{i}", 'data-line-number' => i, class: "gl-display-flex!" }
|
||||
= link_icon
|
||||
= i
|
||||
\
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Link fields to types in GraphQL reference documentation
|
||||
merge_request: 55901
|
||||
author:
|
||||
type: changed
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
title: Fixed error handling GraphQL API when issue board creation fails
|
||||
merge_request: 55982
|
||||
author:
|
||||
type: fixed
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Updated UI text to match style guidelines
|
||||
merge_request: 50383
|
||||
author:
|
||||
type: fixed
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Add selected state for chart button in vulnerabilities dashboard
|
||||
merge_request: 54763
|
||||
author: Yogi (@yo)
|
||||
type: changed
|
File diff suppressed because it is too large
Load Diff
|
@ -319,10 +319,7 @@ For example, to add support for files referenced by a `Widget` model with a
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Geo::WidgetRegistry < Geo::BaseRegistry
|
||||
include Geo::ReplicableRegistry
|
||||
# TODO: Include VerificationState in VerifiableRegistry
|
||||
# https://gitlab.com/gitlab-org/gitlab/-/issues/298811
|
||||
include ::Gitlab::Geo::VerificationState
|
||||
include ::Geo::ReplicableRegistry
|
||||
include ::Geo::VerifiableRegistry
|
||||
|
||||
MODEL_CLASS = ::Widget
|
||||
|
|
|
@ -20,7 +20,7 @@ Every GitLab project can define its own set of description templates as they
|
|||
are added to the root directory of a GitLab project's repository.
|
||||
|
||||
Description templates must be written in [Markdown](../markdown.md) and stored
|
||||
in your project's repository under a directory named `.gitlab`. Only the
|
||||
in your project's repository in the `.gitlab` directory. Only the
|
||||
templates of the default branch are taken into account.
|
||||
|
||||
To learn how to create templates for various file types in groups, visit
|
||||
|
@ -28,10 +28,14 @@ To learn how to create templates for various file types in groups, visit
|
|||
|
||||
## Use cases
|
||||
|
||||
These are some situations when you might find description templates useful:
|
||||
|
||||
- You can create issues and merge request templates for different
|
||||
stages of your workflow, for example, feature proposal, feature improvement, or a bug report.
|
||||
- Add a template to be used in every issue for a specific project,
|
||||
giving instructions and guidelines, requiring for information specific to that subject.
|
||||
For example, if you have a project for tracking new blog posts, you can require the
|
||||
title, outlines, author name, author social media information, and so on.
|
||||
title, outlines, author name, and author social media information.
|
||||
- Following the previous example, you can make a template for every MR submitted
|
||||
with a new blog post, requiring information about the post date, front matter data,
|
||||
images guidelines, link to the related issue, reviewer name, and so on.
|
||||
|
@ -130,21 +134,23 @@ with access" or "Only Project Members" in your project's **Settings / Visibility
|
|||
template text areas don't show. This is the default behavior, so in most cases
|
||||
you should be fine.
|
||||
|
||||
To set a default description template for merge requests:
|
||||
|
||||
1. Go to your project's **Settings**.
|
||||
1. Click **Expand** under the **Merge requests** header.
|
||||
1. Select **Expand** under the **Merge requests** header.
|
||||
1. Fill in the **Default description template for merge requests** text area.
|
||||
1. Click **Expand** under **Default issue template**.
|
||||
1. Select **Save changes**.
|
||||
|
||||
To set a default description template for issues:
|
||||
|
||||
1. Select **Expand** under **Default issue template**.
|
||||
1. Fill in the **Default description template for issues** text area.
|
||||
Since GitLab merge request and issues support [Markdown](../markdown.md), you can use it to format
|
||||
headings, lists, and so on.
|
||||
|
||||
![Default merge request description templates](img/description_templates_merge_request_settings.png)
|
||||
Because GitLab merge request and issues support [Markdown](../markdown.md), you can use it to format
|
||||
headings, lists, and so on.
|
||||
|
||||
![Default issue description templates](img/description_templates_issue_settings.png)
|
||||
|
||||
After you add the description, hit **Save changes** for the settings to take
|
||||
effect. Now, every time a new merge request or issue is created, it is
|
||||
pre-filled with the text you entered in the template(s).
|
||||
Now, every time a new merge request or issue is created, it's pre-filled with the text you entered
|
||||
in the templates.
|
||||
|
||||
[GitLab versions 13.10 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/885)
|
||||
provide `issues_template` and `merge_requests_template` attributes in the
|
||||
|
@ -152,15 +158,16 @@ provide `issues_template` and `merge_requests_template` attributes in the
|
|||
|
||||
## Description template example
|
||||
|
||||
We make use of description templates for issues and merge requests in the GitLab project.
|
||||
For some examples, refer to the [`.gitlab` folder](https://gitlab.com/gitlab-org/gitlab/tree/master/.gitlab).
|
||||
We use description templates for issues and merge requests in the
|
||||
[`.gitlab` folder](https://gitlab.com/gitlab-org/gitlab/tree/master/.gitlab) of the
|
||||
GitLab project, which you can refer to for some examples.
|
||||
|
||||
NOTE:
|
||||
It's possible to use [quick actions](quick_actions.md) in description templates to quickly add
|
||||
labels, assignees, and milestones. The quick actions are only executed if the user submitting
|
||||
the issue or merge request has the permissions to perform the relevant actions.
|
||||
|
||||
Here is an example of a Bug report template:
|
||||
Here is an example of a bug report template:
|
||||
|
||||
```markdown
|
||||
## Summary
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 48 KiB |
|
@ -27,16 +27,18 @@ module Gitlab
|
|||
MD
|
||||
end
|
||||
|
||||
def render_name_and_description(object)
|
||||
content = "### `#{object[:name]}`\n"
|
||||
def render_name_and_description(object, level = 3)
|
||||
content = []
|
||||
|
||||
content << "#{'#' * level} `#{object[:name]}`"
|
||||
|
||||
if object[:description].present?
|
||||
content += "\n#{object[:description]}"
|
||||
content += '.' unless object[:description].ends_with?('.')
|
||||
content += "\n"
|
||||
desc = object[:description].strip
|
||||
desc += '.' unless desc.ends_with?('.')
|
||||
content << desc
|
||||
end
|
||||
|
||||
content
|
||||
content.join("\n\n")
|
||||
end
|
||||
|
||||
def sorted_by_name(objects)
|
||||
|
@ -46,18 +48,15 @@ module Gitlab
|
|||
end
|
||||
|
||||
def render_field(field)
|
||||
'| %s | %s | %s |' % [
|
||||
render_name(field),
|
||||
render_field_type(field[:type][:info]),
|
||||
render_description(field)
|
||||
]
|
||||
row(render_name(field), render_field_type(field[:type]), render_description(field))
|
||||
end
|
||||
|
||||
def render_enum_value(value)
|
||||
'| %s | %s |' % [
|
||||
render_name(value),
|
||||
render_description(value)
|
||||
]
|
||||
row(render_name(value), render_description(value))
|
||||
end
|
||||
|
||||
def row(*values)
|
||||
"| #{values.join(' | ')} |"
|
||||
end
|
||||
|
||||
def render_name(object)
|
||||
|
@ -74,27 +73,19 @@ module Gitlab
|
|||
"**Deprecated:** #{object[:deprecation_reason]}"
|
||||
end
|
||||
|
||||
# Some fields types are arrays of other types and are displayed
|
||||
# on docs wrapped in square brackets, for example: [String!].
|
||||
# This makes GitLab docs renderer thinks they are links so here
|
||||
# we change them to be rendered as: String! => Array.
|
||||
def render_field_type(type)
|
||||
array_type = type[/\[(.+)\]/, 1]
|
||||
"[`#{type[:info]}`](##{type[:name].downcase})"
|
||||
end
|
||||
|
||||
if array_type
|
||||
"#{array_type} => Array"
|
||||
else
|
||||
type
|
||||
end
|
||||
def render_return_type(query)
|
||||
"Returns #{render_field_type(query[:type])}.\n"
|
||||
end
|
||||
|
||||
# We are ignoring connections and built in types for now,
|
||||
# they should be added when queries are generated.
|
||||
def objects
|
||||
object_types = graphql_object_types.select do |object_type|
|
||||
!object_type[:name]["Connection"] &&
|
||||
!object_type[:name]["Edge"] &&
|
||||
!object_type[:name]["__"]
|
||||
!object_type[:name]["__"]
|
||||
end
|
||||
|
||||
object_types.each do |type|
|
||||
|
@ -109,7 +100,7 @@ module Gitlab
|
|||
# We ignore the built-in enum types.
|
||||
def enums
|
||||
graphql_enum_types.select do |enum_type|
|
||||
!enum_type[:name].in?(%w(__DirectiveLocation __TypeKind))
|
||||
!enum_type[:name].in?(%w[__DirectiveLocation __TypeKind])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
- sorted_by_name(queries).each do |query|
|
||||
= render_name_and_description(query)
|
||||
\
|
||||
= render_return_type(query)
|
||||
- unless query[:arguments].empty?
|
||||
~ "#### Arguments\n"
|
||||
~ "| Name | Type | Description |"
|
||||
|
@ -52,6 +54,7 @@
|
|||
- objects.each do |type|
|
||||
- unless type[:fields].empty?
|
||||
= render_name_and_description(type)
|
||||
\
|
||||
~ "| Field | Type | Description |"
|
||||
~ "| ----- | ---- | ----------- |"
|
||||
- sorted_by_name(type[:fields]).each do |field|
|
||||
|
@ -72,8 +75,74 @@
|
|||
- enums.each do |enum|
|
||||
- unless enum[:values].empty?
|
||||
= render_name_and_description(enum)
|
||||
\
|
||||
~ "| Value | Description |"
|
||||
~ "| ----- | ----------- |"
|
||||
- sorted_by_name(enum[:values]).each do |value|
|
||||
= render_enum_value(value)
|
||||
\
|
||||
|
||||
:plain
|
||||
## Scalar types
|
||||
|
||||
Scalar values are atomic values, and do not have fields of their own.
|
||||
Basic scalars include strings, boolean values, and numbers. This schema also
|
||||
defines various custom scalar values, such as types for times and dates.
|
||||
|
||||
This schema includes custom scalar types for identifiers, with a specific type for
|
||||
each kind of object.
|
||||
|
||||
For more information, read about [Scalar Types](https://graphql.org/learn/schema/#scalar-types) on `graphql.org`.
|
||||
\
|
||||
|
||||
- graphql_scalar_types.each do |type|
|
||||
= render_name_and_description(type)
|
||||
\
|
||||
|
||||
:plain
|
||||
## Abstract types
|
||||
|
||||
Abstract types (unions and interfaces) are ways the schema can represent
|
||||
values that may be one of several concrete types.
|
||||
|
||||
- A [`Union`](https://graphql.org/learn/schema/#union-types) is a set of possible types.
|
||||
The types might not have any fields in common.
|
||||
- An [`Interface`](https://graphql.org/learn/schema/#interfaces) is a defined set of fields.
|
||||
Types may `implement` an interface, which
|
||||
guarantees that they have all the fields in the set. A type may implement more than
|
||||
one interface.
|
||||
|
||||
See the [GraphQL documentation](https://graphql.org/learn/) for more information on using
|
||||
abstract types.
|
||||
\
|
||||
|
||||
:plain
|
||||
### Unions
|
||||
\
|
||||
|
||||
- graphql_union_types.each do |type|
|
||||
= render_name_and_description(type, 4)
|
||||
\
|
||||
One of:
|
||||
\
|
||||
- type[:possible_types].each do |type_name|
|
||||
~ "- [`#{type_name}`](##{type_name.downcase})"
|
||||
\
|
||||
|
||||
:plain
|
||||
### Interfaces
|
||||
\
|
||||
|
||||
- graphql_interface_types.each do |type|
|
||||
= render_name_and_description(type, 4)
|
||||
\
|
||||
Implementations:
|
||||
\
|
||||
- type[:implemented_by].each do |type_name|
|
||||
~ "- [`#{type_name}`](##{type_name.downcase})"
|
||||
\
|
||||
~ "| Field | Type | Description |"
|
||||
~ "| ----- | ---- | ----------- |"
|
||||
- sorted_by_name(type[:fields] + type[:connections]).each do |field|
|
||||
= render_field(field)
|
||||
\
|
||||
|
|
|
@ -10870,6 +10870,9 @@ msgstr ""
|
|||
msgid "Dismiss Value Stream Analytics introduction box"
|
||||
msgstr ""
|
||||
|
||||
msgid "Dismiss merge request promotion"
|
||||
msgstr ""
|
||||
|
||||
msgid "Dismiss selected"
|
||||
msgstr ""
|
||||
|
||||
|
@ -15670,10 +15673,10 @@ msgid_plural "Importing %d repositories"
|
|||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "Improve Merge Requests and customer support with GitLab Enterprise Edition."
|
||||
msgid "Improve customer support with Service Desk"
|
||||
msgstr ""
|
||||
|
||||
msgid "Improve customer support with Service Desk"
|
||||
msgid "Improve merge requests and customer support with GitLab Enterprise Edition."
|
||||
msgstr ""
|
||||
|
||||
msgid "Improve search with Advanced Search and GitLab Enterprise Edition."
|
||||
|
@ -18958,9 +18961,6 @@ msgstr ""
|
|||
msgid "Merge Request Analytics"
|
||||
msgstr ""
|
||||
|
||||
msgid "Merge Request Approvals"
|
||||
msgstr ""
|
||||
|
||||
msgid "Merge Request Commits"
|
||||
msgstr ""
|
||||
|
||||
|
@ -19018,9 +19018,6 @@ msgstr ""
|
|||
msgid "Merge request approvals"
|
||||
msgstr ""
|
||||
|
||||
msgid "Merge request approvals allow you to set the number of necessary approvals and predefine a list of approvers that will need to approve every merge request in a project."
|
||||
msgstr ""
|
||||
|
||||
msgid "Merge request dependencies"
|
||||
msgstr ""
|
||||
|
||||
|
@ -23734,7 +23731,10 @@ msgstr ""
|
|||
msgid "ProjectService|To set up this service:"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Additional merge request capabilities that influence how and when merges will be performed"
|
||||
msgid "ProjectSettings|%{link_start}What are description templates?%{link_end}"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Additional settings that influence how and when merges are done."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|All discussions must be resolved"
|
||||
|
@ -23788,25 +23788,28 @@ msgstr ""
|
|||
msgid "ProjectSettings|Customize this project's badges."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Determine what happens to the commit history when you merge a merge request."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Disable email notifications"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Do not allow"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Enable 'Delete source branch' option by default"
|
||||
msgid "ProjectSettings|Enable \"Delete source branch\" option by default"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Enable merge trains."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Enable merged results pipelines."
|
||||
msgid "ProjectSettings|Enable merged results pipelines"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Encourage"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Every merge creates a merge commit"
|
||||
msgid "ProjectSettings|Every merge creates a merge commit."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Every project can have its own space to store its Docker images"
|
||||
|
@ -23818,7 +23821,7 @@ msgstr ""
|
|||
msgid "ProjectSettings|Everyone"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Existing merge requests and protected branches are not affected"
|
||||
msgid "ProjectSettings|Existing merge requests and protected branches are not affected."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Failed to protect the tag"
|
||||
|
@ -23830,7 +23833,7 @@ msgstr ""
|
|||
msgid "ProjectSettings|Fast-forward merge"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Fast-forward merges only"
|
||||
msgid "ProjectSettings|Fast-forward merges only."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Forks"
|
||||
|
@ -23842,10 +23845,10 @@ msgstr ""
|
|||
msgid "ProjectSettings|Global"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|If pipelines for merge requests are enabled in the CI/CD configuration file, pipelines validate the combined results of the source and target branches."
|
||||
msgid "ProjectSettings|Internal"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Internal"
|
||||
msgid "ProjectSettings|Introduces the risk of merging changes that do not pass the pipeline."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Issues"
|
||||
|
@ -23878,10 +23881,13 @@ msgstr ""
|
|||
msgid "ProjectSettings|Merge requests"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Merge requests approved for merge are queued, and pipelines validate the combined results of the source and target branches before merge. %{link_start}What are merge trains?%{link_end}"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Merge suggestions"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|No merge commits are created"
|
||||
msgid "ProjectSettings|No merge commits are created."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Note: the container registry is always visible when a project is public"
|
||||
|
@ -23911,9 +23917,6 @@ msgstr ""
|
|||
msgid "ProjectSettings|Pipelines must succeed"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Pipelines need to be configured to enable this feature."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Private"
|
||||
msgstr ""
|
||||
|
||||
|
@ -23944,7 +23947,7 @@ msgstr ""
|
|||
msgid "ProjectSettings|Security & Compliance for this project"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Set the default behavior and availability of this option in merge requests. Changes made are also applied to existing merge requests."
|
||||
msgid "ProjectSettings|Set the default behavior of this option in merge requests. Changes to this are also applied to existing merge requests."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Share code with others outside the project."
|
||||
|
@ -23953,7 +23956,7 @@ msgstr ""
|
|||
msgid "ProjectSettings|Show default award emojis"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Show link to create/view merge request when pushing from the command line"
|
||||
msgid "ProjectSettings|Show link to create or view a merge request when pushing from the command line"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Skipped pipelines are considered successful"
|
||||
|
@ -23974,16 +23977,13 @@ msgstr ""
|
|||
msgid "ProjectSettings|Submit changes to be merged upstream."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|The commit message used to apply merge request suggestions"
|
||||
msgid "ProjectSettings|Supported variables:"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|The variables GitLab supports:"
|
||||
msgid "ProjectSettings|The commit message used when applying merge request suggestions. %{link_start}Learn more about suggestions.%{link_end}"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|These checks must pass before merge requests can be merged"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|This introduces the risk of merging changes that will not pass the pipeline."
|
||||
msgid "ProjectSettings|These checks must pass before merge requests can be merged."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|This setting is applied on the server level and can be overridden by an admin."
|
||||
|
@ -23995,12 +23995,15 @@ msgstr ""
|
|||
msgid "ProjectSettings|This setting will be applied to all projects unless overridden by an admin."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|This will dictate the commit history when you merge a merge request"
|
||||
msgid "ProjectSettings|To enable this feature, configure pipelines. %{link_start}How to configure pipelines for merge requests?%{link_end}"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Transfer project"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Used for every new merge request."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Users can copy the repository to a new project."
|
||||
msgstr ""
|
||||
|
||||
|
@ -24028,10 +24031,10 @@ msgstr ""
|
|||
msgid "ProjectSettings|What are badges?"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|When approved for merge, merge requests are queued and pipelines validate the combined results of the source and target branches before merge."
|
||||
msgid "ProjectSettings|When pipelines for merge requests are enabled in the CI/CD configuration file, pipelines validate the combined results of the source and target branches. %{link_start}How to configure pipelines for merge requests?%{link_end}"
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|When conflicts arise the user is given the option to rebase"
|
||||
msgid "ProjectSettings|When there is a merge conflict, the user is given the option to rebase."
|
||||
msgstr ""
|
||||
|
||||
msgid "ProjectSettings|Wiki"
|
||||
|
@ -27523,6 +27526,9 @@ msgstr ""
|
|||
msgid "Set the milestone to %{milestone_reference}."
|
||||
msgstr ""
|
||||
|
||||
msgid "Set the number of necessary approvals and define a list of approvers needed for every merge request in a project."
|
||||
msgstr ""
|
||||
|
||||
msgid "Set the timeout in seconds to send a secondary node status to the primary and IPs allowed for the secondary nodes."
|
||||
msgstr ""
|
||||
|
||||
|
@ -32379,7 +32385,7 @@ msgstr ""
|
|||
msgid "Upgrade your plan to enable this feature of the Jira Integration."
|
||||
msgstr ""
|
||||
|
||||
msgid "Upgrade your plan to improve Merge Requests."
|
||||
msgid "Upgrade your plan to improve merge requests."
|
||||
msgstr ""
|
||||
|
||||
msgid "Upload"
|
||||
|
|
|
@ -15,10 +15,13 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
end
|
||||
end
|
||||
|
||||
GraphQL::Schema.define(query: query_type)
|
||||
GraphQL::Schema.define(
|
||||
query: query_type,
|
||||
resolve_type: ->(obj, ctx) { raise 'Not a real schema' }
|
||||
)
|
||||
end
|
||||
|
||||
let_it_be(:template) { Rails.root.join('lib/gitlab/graphql/docs/templates/', 'default.md.haml') }
|
||||
let_it_be(:template) { Rails.root.join('lib/gitlab/graphql/docs/templates/default.md.haml') }
|
||||
let(:field_description) { 'List of objects.' }
|
||||
|
||||
subject(:contents) do
|
||||
|
@ -29,7 +32,23 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
).contents
|
||||
end
|
||||
|
||||
context 'A type with a field with a [Array] return type' do
|
||||
describe 'headings' do
|
||||
let(:type) { ::GraphQL::INT_TYPE }
|
||||
|
||||
it 'contains the expected sections' do
|
||||
expect(contents.lines.map(&:chomp)).to include(
|
||||
'## `Query` type',
|
||||
'## Object types',
|
||||
'## Enumeration types',
|
||||
'## Scalar types',
|
||||
'## Abstract types',
|
||||
'### Unions',
|
||||
'### Interfaces'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a field has a list type' do
|
||||
let(:type) do
|
||||
Class.new(Types::BaseObject) do
|
||||
graphql_name 'ArrayTest'
|
||||
|
@ -39,29 +58,33 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
end
|
||||
|
||||
specify do
|
||||
type_name = '[String!]!'
|
||||
inner_type = 'string'
|
||||
expectation = <<~DOC
|
||||
### `ArrayTest`
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `foo` | String! => Array | A description. |
|
||||
| `foo` | [`#{type_name}`](##{inner_type}) | A description. |
|
||||
DOC
|
||||
|
||||
is_expected.to include(expectation)
|
||||
end
|
||||
|
||||
context 'query generation' do
|
||||
describe 'a top level query field' do
|
||||
let(:expectation) do
|
||||
<<~DOC
|
||||
### `foo`
|
||||
|
||||
List of objects.
|
||||
|
||||
Returns [`ArrayTest`](#arraytest).
|
||||
|
||||
#### Arguments
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| `id` | ID | ID of the object. |
|
||||
| `id` | [`ID`](#id) | ID of the object. |
|
||||
DOC
|
||||
end
|
||||
|
||||
|
@ -79,7 +102,7 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
end
|
||||
end
|
||||
|
||||
context 'A type with fields defined in reverse alphabetical order' do
|
||||
describe 'when fields are not defined in alphabetical order' do
|
||||
let(:type) do
|
||||
Class.new(Types::BaseObject) do
|
||||
graphql_name 'OrderingTest'
|
||||
|
@ -89,49 +112,56 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
end
|
||||
end
|
||||
|
||||
specify do
|
||||
it 'lists the fields in alphabetical order' do
|
||||
expectation = <<~DOC
|
||||
### `OrderingTest`
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `bar` | String! | A description of bar field. |
|
||||
| `foo` | String! | A description of foo field. |
|
||||
| `bar` | [`String!`](#string) | A description of bar field. |
|
||||
| `foo` | [`String!`](#string) | A description of foo field. |
|
||||
DOC
|
||||
|
||||
is_expected.to include(expectation)
|
||||
end
|
||||
end
|
||||
|
||||
context 'A type with a deprecated field' do
|
||||
context 'when a field is deprecated' do
|
||||
let(:type) do
|
||||
Class.new(Types::BaseObject) do
|
||||
graphql_name 'DeprecatedTest'
|
||||
|
||||
field :foo, GraphQL::STRING_TYPE, null: false, deprecated: { reason: 'This is deprecated', milestone: '1.10' }, description: 'A description.'
|
||||
field :foo,
|
||||
type: GraphQL::STRING_TYPE,
|
||||
null: false,
|
||||
deprecated: { reason: 'This is deprecated', milestone: '1.10' },
|
||||
description: 'A description.'
|
||||
end
|
||||
end
|
||||
|
||||
specify do
|
||||
it 'includes the deprecation' do
|
||||
expectation = <<~DOC
|
||||
### `DeprecatedTest`
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `foo` **{warning-solid}** | String! | **Deprecated:** This is deprecated. Deprecated in 1.10. |
|
||||
| `foo` **{warning-solid}** | [`String!`](#string) | **Deprecated:** This is deprecated. Deprecated in 1.10. |
|
||||
DOC
|
||||
|
||||
is_expected.to include(expectation)
|
||||
end
|
||||
end
|
||||
|
||||
context 'A type with an emum field' do
|
||||
context 'when a field has an Enumeration type' do
|
||||
let(:type) do
|
||||
enum_type = Class.new(Types::BaseEnum) do
|
||||
graphql_name 'MyEnum'
|
||||
|
||||
value 'BAZ', description: 'A description of BAZ.'
|
||||
value 'BAR', description: 'A description of BAR.', deprecated: { reason: 'This is deprecated', milestone: '1.10' }
|
||||
value 'BAZ',
|
||||
description: 'A description of BAZ.'
|
||||
value 'BAR',
|
||||
description: 'A description of BAR.',
|
||||
deprecated: { reason: 'This is deprecated', milestone: '1.10' }
|
||||
end
|
||||
|
||||
Class.new(Types::BaseObject) do
|
||||
|
@ -141,7 +171,7 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
end
|
||||
end
|
||||
|
||||
specify do
|
||||
it 'includes the description of the Enumeration' do
|
||||
expectation = <<~DOC
|
||||
### `MyEnum`
|
||||
|
||||
|
@ -154,5 +184,129 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
|
|||
is_expected.to include(expectation)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a field has a global ID type' do
|
||||
let(:type) do
|
||||
Class.new(Types::BaseObject) do
|
||||
graphql_name 'IDTest'
|
||||
description 'A test for rendering IDs.'
|
||||
|
||||
field :foo, ::Types::GlobalIDType[::User], null: true, description: 'A user foo.'
|
||||
end
|
||||
end
|
||||
|
||||
it 'includes the field and the description of the ID, so we can link to it' do
|
||||
type_section = <<~DOC
|
||||
### `IDTest`
|
||||
|
||||
A test for rendering IDs.
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `foo` | [`UserID`](#userid) | A user foo. |
|
||||
DOC
|
||||
|
||||
id_section = <<~DOC
|
||||
### `UserID`
|
||||
|
||||
A `UserID` is a global ID. It is encoded as a string.
|
||||
|
||||
An example `UserID` is: `"gid://gitlab/User/1"`.
|
||||
DOC
|
||||
|
||||
is_expected.to include(type_section, id_section)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is an interface and a union' do
|
||||
let(:type) do
|
||||
user = Class.new(::Types::BaseObject)
|
||||
user.graphql_name 'User'
|
||||
user.field :user_field, ::GraphQL::STRING_TYPE, null: true
|
||||
group = Class.new(::Types::BaseObject)
|
||||
group.graphql_name 'Group'
|
||||
group.field :group_field, ::GraphQL::STRING_TYPE, null: true
|
||||
|
||||
union = Class.new(::Types::BaseUnion)
|
||||
union.graphql_name 'UserOrGroup'
|
||||
union.description 'Either a user or a group.'
|
||||
union.possible_types user, group
|
||||
|
||||
interface = Module.new
|
||||
interface.include(::Types::BaseInterface)
|
||||
interface.graphql_name 'Flying'
|
||||
interface.description 'Something that can fly.'
|
||||
interface.field :flight_speed, GraphQL::INT_TYPE, null: true, description: 'Speed in mph.'
|
||||
|
||||
african_swallow = Class.new(::Types::BaseObject)
|
||||
african_swallow.graphql_name 'AfricanSwallow'
|
||||
african_swallow.description 'A swallow from Africa.'
|
||||
african_swallow.implements interface
|
||||
interface.orphan_types african_swallow
|
||||
|
||||
Class.new(::Types::BaseObject) do
|
||||
graphql_name 'AbstactTypeTest'
|
||||
description 'A test for abstract types.'
|
||||
|
||||
field :foo, union, null: true, description: 'The foo.'
|
||||
field :flying, interface, null: true, description: 'A flying thing.'
|
||||
end
|
||||
end
|
||||
|
||||
it 'lists the fields correctly, and includes descriptions of all the types' do
|
||||
type_section = <<~DOC
|
||||
### `AbstactTypeTest`
|
||||
|
||||
A test for abstract types.
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `flying` | [`Flying`](#flying) | A flying thing. |
|
||||
| `foo` | [`UserOrGroup`](#userorgroup) | The foo. |
|
||||
DOC
|
||||
|
||||
union_section = <<~DOC
|
||||
#### `UserOrGroup`
|
||||
|
||||
Either a user or a group.
|
||||
|
||||
One of:
|
||||
|
||||
- [`Group`](#group)
|
||||
- [`User`](#user)
|
||||
DOC
|
||||
|
||||
interface_section = <<~DOC
|
||||
#### `Flying`
|
||||
|
||||
Something that can fly.
|
||||
|
||||
Implementations:
|
||||
|
||||
- [`AfricanSwallow`](#africanswallow)
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `flightSpeed` | [`Int`](#int) | Speed in mph. |
|
||||
DOC
|
||||
|
||||
implementation_section = <<~DOC
|
||||
### `AfricanSwallow`
|
||||
|
||||
A swallow from Africa.
|
||||
|
||||
| Field | Type | Description |
|
||||
| ----- | ---- | ----------- |
|
||||
| `flightSpeed` | [`Int`](#int) | Speed in mph. |
|
||||
DOC
|
||||
|
||||
is_expected.to include(
|
||||
type_section,
|
||||
union_section,
|
||||
interface_section,
|
||||
implementation_section
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -81,6 +81,32 @@ RSpec.describe AlertManagement::HttpIntegration do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'before validation' do
|
||||
describe '#ensure_payload_example_not_nil' do
|
||||
subject(:integration) { build(:alert_management_http_integration, payload_example: payload_example) }
|
||||
|
||||
context 'when the payload_example is nil' do
|
||||
let(:payload_example) { nil }
|
||||
|
||||
it 'sets the payload_example to empty JSON' do
|
||||
integration.valid?
|
||||
|
||||
expect(integration.payload_example).to eq({})
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the payload_example is not nil' do
|
||||
let(:payload_example) { { 'key' => 'value' } }
|
||||
|
||||
it 'sets the payload_example to specified value' do
|
||||
integration.valid?
|
||||
|
||||
expect(integration.payload_example).to eq(payload_example)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#token' do
|
||||
subject { integration.token }
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
|
|||
created_at: file.created_at,
|
||||
download_path: file.download_path,
|
||||
file_name: file.file_name,
|
||||
size: file.size
|
||||
size: file.size,
|
||||
file_md5: file.file_md5,
|
||||
file_sha1: file.file_sha1,
|
||||
file_sha256: file.file_sha256
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -66,7 +66,9 @@ RSpec.shared_examples 'boards create mutation' do
|
|||
|
||||
context 'when the Boards::CreateService returns an error response' do
|
||||
before do
|
||||
params[:name] = ''
|
||||
allow_next_instance_of(Boards::CreateService) do |service|
|
||||
allow(service).to receive(:execute).and_return(ServiceResponse.error(message: 'There was an error.'))
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not create a board' do
|
||||
|
@ -78,7 +80,7 @@ RSpec.shared_examples 'boards create mutation' do
|
|||
|
||||
expect(mutation_response).to have_key('board')
|
||||
expect(mutation_response['board']).to be_nil
|
||||
expect(mutation_response['errors'].first).to eq('There was an error when creating a board.')
|
||||
expect(mutation_response['errors'].first).to eq('There was an error.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue