diff --git a/app/assets/javascripts/content_editor/components/content_editor.vue b/app/assets/javascripts/content_editor/components/content_editor.vue
index 659c447e861..b5a88f97d83 100644
--- a/app/assets/javascripts/content_editor/components/content_editor.vue
+++ b/app/assets/javascripts/content_editor/components/content_editor.vue
@@ -3,7 +3,7 @@ import { EditorContent as TiptapEditorContent } from '@tiptap/vue-2';
import { __ } from '~/locale';
import { VARIANT_DANGER } from '~/flash';
import { createContentEditor } from '../services/create_content_editor';
-import { ALERT_EVENT } from '../constants';
+import { ALERT_EVENT, TIPTAP_AUTOFOCUS_OPTIONS } from '../constants';
import ContentEditorAlert from './content_editor_alert.vue';
import ContentEditorProvider from './content_editor_provider.vue';
import EditorStateObserver from './editor_state_observer.vue';
@@ -51,6 +51,12 @@ export default {
required: false,
default: '',
},
+ autofocus: {
+ type: [String, Boolean],
+ required: false,
+ default: false,
+ validator: (autofocus) => TIPTAP_AUTOFOCUS_OPTIONS.includes(autofocus),
+ },
},
data() {
return {
@@ -67,7 +73,7 @@ export default {
},
},
created() {
- const { renderMarkdown, uploadsPath, extensions, serializerConfig } = this;
+ const { renderMarkdown, uploadsPath, extensions, serializerConfig, autofocus } = this;
// This is a non-reactive attribute intentionally since this is a complex object.
this.contentEditor = createContentEditor({
@@ -75,6 +81,9 @@ export default {
uploadsPath,
extensions,
serializerConfig,
+ tiptapOptions: {
+ autofocus,
+ },
});
},
mounted() {
diff --git a/app/assets/javascripts/content_editor/constants/index.js b/app/assets/javascripts/content_editor/constants/index.js
index 564cca23afa..96bf9a23cdc 100644
--- a/app/assets/javascripts/content_editor/constants/index.js
+++ b/app/assets/javascripts/content_editor/constants/index.js
@@ -66,3 +66,5 @@ export const SAFE_VIDEO_EXT = ['mp4', 'm4v', 'mov', 'webm', 'ogv'];
export const SAFE_AUDIO_EXT = ['mp3', 'oga', 'ogg', 'spx', 'wav'];
export const DIAGRAM_LANGUAGES = ['plantuml', 'mermaid'];
+
+export const TIPTAP_AUTOFOCUS_OPTIONS = [true, false, 'start', 'end', 'all'];
diff --git a/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue b/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue
index bd3929c5f59..647cfd1c5b4 100644
--- a/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue
+++ b/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue
@@ -299,7 +299,7 @@ export default {
:uploads-path="pageInfo.uploadsPath"
:enable-content-editor="isMarkdownFormat"
:enable-preview="isMarkdownFormat"
- :autofocus="pageInfo.persisted"
+ :init-on-autofocus="pageInfo.persisted"
:form-field-placeholder="$options.i18n.content.placeholder"
:form-field-aria-label="$options.i18n.content.label"
form-field-id="wiki_content"
diff --git a/app/assets/javascripts/vue_shared/components/markdown/markdown_editor.vue b/app/assets/javascripts/vue_shared/components/markdown/markdown_editor.vue
index fd8496fa313..4f0fb7e1844 100644
--- a/app/assets/javascripts/vue_shared/components/markdown/markdown_editor.vue
+++ b/app/assets/javascripts/vue_shared/components/markdown/markdown_editor.vue
@@ -31,7 +31,8 @@ export default {
},
uploadsPath: {
type: String,
- required: true,
+ required: false,
+ default: () => window.uploads_path,
},
enableContentEditor: {
type: Boolean,
@@ -56,11 +57,6 @@ export default {
required: false,
default: true,
},
- autofocus: {
- type: Boolean,
- required: false,
- default: false,
- },
formFieldPlaceholder: {
type: String,
required: false,
@@ -71,17 +67,30 @@ export default {
required: false,
default: '',
},
+ initOnAutofocus: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
},
data() {
return {
editingMode: EDITING_MODE_MARKDOWN_FIELD,
switchEditingControlEnabled: true,
+ autofocus: this.initOnAutofocus,
};
},
computed: {
isContentEditorActive() {
return this.enableContentEditor && this.editingMode === EDITING_MODE_CONTENT_EDITOR;
},
+ contentEditorAutofocus() {
+ // Match textarea focus behavior
+ return this.autofocus ? 'end' : false;
+ },
+ },
+ mounted() {
+ this.autofocusTextarea(this.editingMode);
},
methods: {
updateMarkdownFromContentEditor({ markdown }) {
@@ -99,9 +108,25 @@ export default {
renderMarkdown(markdown) {
return axios.post(this.renderMarkdownPath, { text: markdown }).then(({ data }) => data.body);
},
+ onEditingModeChange(editingMode) {
+ this.notifyEditingModeChange(editingMode);
+ this.enableAutofocus(editingMode);
+ },
+ onEditingModeRestored(editingMode) {
+ this.notifyEditingModeChange(editingMode);
+ },
notifyEditingModeChange(editingMode) {
this.$emit(editingMode);
},
+ enableAutofocus(editingMode) {
+ this.autofocus = true;
+ this.autofocusTextarea(editingMode);
+ },
+ autofocusTextarea(editingMode) {
+ if (this.autofocus && editingMode === EDITING_MODE_MARKDOWN_FIELD) {
+ this.$refs.textarea.focus();
+ }
+ },
},
switchEditingControlOptions: [
{ text: __('Source'), value: EDITING_MODE_MARKDOWN_FIELD },
@@ -119,13 +144,13 @@ export default {
class="gl-display-flex"
:options="$options.switchEditingControlOptions"
:disabled="!enableContentEditor || !switchEditingControlEnabled"
- @change="notifyEditingModeChange"
+ @change="onEditingModeChange"
/>
Repository**.
+1. Expand the **Pre-defined push rules** section.
1. Select the settings you want.
1. Select **Save Push Rules**.
In GitLab 15.3 and earlier, to configure push rules for a group:
-1. On the left sidebar, select **Settings > Repository** page.
-1. Expand the **Pre-defined push rules** section.
+1. On the left sidebar, select **Push rules**.
1. Select the settings you want.
1. Select **Save Push Rules**.
diff --git a/lib/gitlab/github_import/importer/diff_notes_importer.rb b/lib/gitlab/github_import/importer/diff_notes_importer.rb
index 49cbc8f7a42..92f26692a05 100644
--- a/lib/gitlab/github_import/importer/diff_notes_importer.rb
+++ b/lib/gitlab/github_import/importer/diff_notes_importer.rb
@@ -27,7 +27,7 @@ module Gitlab
end
def id_for_already_imported_cache(note)
- note.id
+ note[:id]
end
end
end
diff --git a/lib/gitlab/github_import/importer/issue_events_importer.rb b/lib/gitlab/github_import/importer/issue_events_importer.rb
index 71dd99f91f9..a1c706c5d78 100644
--- a/lib/gitlab/github_import/importer/issue_events_importer.rb
+++ b/lib/gitlab/github_import/importer/issue_events_importer.rb
@@ -27,7 +27,7 @@ module Gitlab
end
def id_for_already_imported_cache(event)
- event.id
+ event[:id]
end
end
end
diff --git a/lib/gitlab/github_import/importer/issues_importer.rb b/lib/gitlab/github_import/importer/issues_importer.rb
index 21d9ce8cd2d..c77e805210f 100644
--- a/lib/gitlab/github_import/importer/issues_importer.rb
+++ b/lib/gitlab/github_import/importer/issues_importer.rb
@@ -33,7 +33,7 @@ module Gitlab
end
def id_for_already_imported_cache(issue)
- issue.number
+ issue[:number]
end
def collection_options
diff --git a/lib/gitlab/github_import/importer/labels_importer.rb b/lib/gitlab/github_import/importer/labels_importer.rb
index 7293de56a9a..9a011f17a18 100644
--- a/lib/gitlab/github_import/importer/labels_importer.rb
+++ b/lib/gitlab/github_import/importer/labels_importer.rb
@@ -22,7 +22,7 @@ module Gitlab
end
def already_imported?(label)
- existing_labels.include?(label.name)
+ existing_labels.include?(label[:name])
end
def build_labels_cache
@@ -33,8 +33,8 @@ module Gitlab
time = Time.zone.now
{
- title: label.name,
- color: '#' + label.color,
+ title: label[:name],
+ color: '#' + label[:color],
project_id: project.id,
type: 'ProjectLabel',
created_at: time,
diff --git a/lib/gitlab/github_import/importer/milestones_importer.rb b/lib/gitlab/github_import/importer/milestones_importer.rb
index d11b151bbe2..1a3a54d0053 100644
--- a/lib/gitlab/github_import/importer/milestones_importer.rb
+++ b/lib/gitlab/github_import/importer/milestones_importer.rb
@@ -22,7 +22,7 @@ module Gitlab
end
def already_imported?(milestone)
- existing_milestones.include?(milestone.number)
+ existing_milestones.include?(milestone[:number])
end
def build_milestones_cache
@@ -31,19 +31,19 @@ module Gitlab
def build(milestone)
{
- iid: milestone.number,
- title: milestone.title,
- description: milestone.description,
+ iid: milestone[:number],
+ title: milestone[:title],
+ description: milestone[:description],
project_id: project.id,
state: state_for(milestone),
- due_date: milestone.due_on&.to_date,
- created_at: milestone.created_at,
- updated_at: milestone.updated_at
+ due_date: milestone[:due_on]&.to_date,
+ created_at: milestone[:created_at],
+ updated_at: milestone[:updated_at]
}
end
def state_for(milestone)
- milestone.state == 'open' ? :active : :closed
+ milestone[:state] == 'open' ? :active : :closed
end
def each_milestone
diff --git a/lib/gitlab/github_import/importer/notes_importer.rb b/lib/gitlab/github_import/importer/notes_importer.rb
index ca1d7d60515..4c2b87a8c5e 100644
--- a/lib/gitlab/github_import/importer/notes_importer.rb
+++ b/lib/gitlab/github_import/importer/notes_importer.rb
@@ -27,7 +27,7 @@ module Gitlab
end
def id_for_already_imported_cache(note)
- note.id
+ note[:id]
end
end
end
diff --git a/lib/gitlab/github_import/importer/pull_requests_importer.rb b/lib/gitlab/github_import/importer/pull_requests_importer.rb
index 5d291d9d723..16541c90002 100644
--- a/lib/gitlab/github_import/importer/pull_requests_importer.rb
+++ b/lib/gitlab/github_import/importer/pull_requests_importer.rb
@@ -19,7 +19,7 @@ module Gitlab
end
def id_for_already_imported_cache(pr)
- pr.number
+ pr[:number]
end
def object_type
@@ -55,11 +55,11 @@ module Gitlab
def update_repository?(pr)
last_update = project.last_repository_updated_at || project.created_at
- return false if pr.updated_at < last_update
+ return false if pr[:updated_at] < last_update
# PRs may be updated without there actually being new commits, thus we
# check to make sure we only re-fetch if truly necessary.
- !(commit_exists?(pr.head.sha) && commit_exists?(pr.base.sha))
+ !(commit_exists?(pr.dig(:head, :sha)) && commit_exists?(pr.dig(:base, :sha)))
end
def commit_exists?(sha)
diff --git a/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb b/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb
index 5e55d09fe3d..0025c708717 100644
--- a/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb
+++ b/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb
@@ -34,7 +34,7 @@ module Gitlab
end
def id_for_already_imported_cache(review)
- review.id
+ review[:id]
end
# The worker can be interrupted, by rate limit for instance,
@@ -52,7 +52,7 @@ module Gitlab
Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched)
- review.merge_request_id = merge_request.id
+ review[:merge_request_id] = merge_request.id
yield(review)
mark_as_imported(review)
diff --git a/lib/gitlab/github_import/importer/releases_importer.rb b/lib/gitlab/github_import/importer/releases_importer.rb
index 51d364772d2..07efd22b0fe 100644
--- a/lib/gitlab/github_import/importer/releases_importer.rb
+++ b/lib/gitlab/github_import/importer/releases_importer.rb
@@ -21,21 +21,21 @@ module Gitlab
end
def already_imported?(release)
- existing_tags.include?(release.tag_name) || release.tag_name.nil?
+ existing_tags.include?(release[:tag_name]) || release[:tag_name].nil?
end
def build(release)
- existing_tags.add(release.tag_name)
+ existing_tags.add(release[:tag_name])
{
- name: release.name,
- tag: release.tag_name,
+ name: release[:name],
+ tag: release[:tag_name],
author_id: fetch_author_id(release),
description: description_for(release),
- created_at: release.created_at,
- updated_at: release.created_at,
+ created_at: release[:created_at],
+ updated_at: release[:created_at],
# Draft releases will have a null published_at
- released_at: release.published_at || Time.current,
+ released_at: release[:published_at] || Time.current,
project_id: project.id
}
end
@@ -45,7 +45,7 @@ module Gitlab
end
def description_for(release)
- release.body.presence || "Release for tag #{release.tag_name}"
+ release[:body].presence || "Release for tag #{release[:tag_name]}"
end
def object_type
diff --git a/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer.rb b/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer.rb
index 8a9ddfc6ec0..88b97d1c22c 100644
--- a/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer.rb
+++ b/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer.rb
@@ -28,7 +28,7 @@ module Gitlab
Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched)
pull_request = parent_record.is_a? MergeRequest
- associated.issue = { 'number' => parent_record.iid, 'pull_request' => pull_request }
+ associated[:issue] = { 'number' => parent_record.iid, 'pull_request' => pull_request }
yield(associated)
mark_as_imported(associated)
@@ -78,7 +78,7 @@ module Gitlab
end
def id_for_already_imported_cache(event)
- event.id
+ event[:id]
end
def collection_options
@@ -87,9 +87,9 @@ module Gitlab
# Cross-referenced events on Github doesn't have id.
def compose_associated_id!(issuable, event)
- return if event.event != 'cross-referenced'
+ return if event[:event] != 'cross-referenced'
- event.id = "cross-reference##{issuable.iid}-in-#{event.source.issue.id}"
+ event[:id] = "cross-reference##{issuable.iid}-in-#{event.dig(:source, :issue, :id)}"
end
end
end
diff --git a/lib/gitlab/github_import/representation/diff_note.rb b/lib/gitlab/github_import/representation/diff_note.rb
index 64aa6ea5cb4..3e9f23c9704 100644
--- a/lib/gitlab/github_import/representation/diff_note.rb
+++ b/lib/gitlab/github_import/representation/diff_note.rb
@@ -21,31 +21,31 @@ module Gitlab
#
# note - An instance of `Sawyer::Resource` containing the note details.
def self.from_api_response(note, additional_data = {})
- matches = note.html_url.match(NOTEABLE_ID_REGEX)
+ matches = note[:html_url].match(NOTEABLE_ID_REGEX)
unless matches
raise(
ArgumentError,
- "The note URL #{note.html_url.inspect} is not supported"
+ "The note URL #{note[:html_url].inspect} is not supported"
)
end
- user = Representation::User.from_api_response(note.user) if note.user
+ user = Representation::User.from_api_response(note[:user]) if note[:user]
hash = {
noteable_id: matches[:iid].to_i,
- file_path: note.path,
- commit_id: note.commit_id,
- original_commit_id: note.original_commit_id,
- diff_hunk: note.diff_hunk,
+ file_path: note[:path],
+ commit_id: note[:commit_id],
+ original_commit_id: note[:original_commit_id],
+ diff_hunk: note[:diff_hunk],
author: user,
- note: note.body,
- created_at: note.created_at,
- updated_at: note.updated_at,
- note_id: note.id,
- end_line: note.line,
- start_line: note.start_line,
- side: note.side,
- in_reply_to_id: note.in_reply_to_id
+ note: note[:body],
+ created_at: note[:created_at],
+ updated_at: note[:updated_at],
+ note_id: note[:id],
+ end_line: note[:line],
+ start_line: note[:start_line],
+ side: note[:side],
+ in_reply_to_id: note[:in_reply_to_id]
}
new(hash)
diff --git a/lib/gitlab/github_import/representation/issue.rb b/lib/gitlab/github_import/representation/issue.rb
index 9d457ec1c2f..240e45b437e 100644
--- a/lib/gitlab/github_import/representation/issue.rb
+++ b/lib/gitlab/github_import/representation/issue.rb
@@ -19,24 +19,24 @@ module Gitlab
# details.
def self.from_api_response(issue, additional_data = {})
user =
- if issue.user
- Representation::User.from_api_response(issue.user)
+ if issue[:user]
+ Representation::User.from_api_response(issue[:user])
end
hash = {
- iid: issue.number,
- title: issue.title,
- description: issue.body,
- milestone_number: issue.milestone&.number,
- state: issue.state == 'open' ? :opened : :closed,
- assignees: issue.assignees.map do |u|
+ iid: issue[:number],
+ title: issue[:title],
+ description: issue[:body],
+ milestone_number: issue.dig(:milestone, :number),
+ state: issue[:state] == 'open' ? :opened : :closed,
+ assignees: issue[:assignees].map do |u|
Representation::User.from_api_response(u)
end,
- label_names: issue.labels.map(&:name),
+ label_names: issue[:labels].map { _1[:name] },
author: user,
- created_at: issue.created_at,
- updated_at: issue.updated_at,
- pull_request: issue.pull_request ? true : false,
+ created_at: issue[:created_at],
+ updated_at: issue[:updated_at],
+ pull_request: issue[:pull_request] ? true : false,
work_item_type_id: additional_data[:work_item_type_id]
}
diff --git a/lib/gitlab/github_import/representation/issue_event.rb b/lib/gitlab/github_import/representation/issue_event.rb
index 89271a7dcd6..f088e324144 100644
--- a/lib/gitlab/github_import/representation/issue_event.rb
+++ b/lib/gitlab/github_import/representation/issue_event.rb
@@ -37,20 +37,20 @@ module Gitlab
# event - An instance of `Sawyer::Resource` containing the event details.
def from_api_response(event, additional_data = {})
new(
- id: event.id,
- actor: user_representation(event.actor),
- event: event.event,
- commit_id: event.commit_id,
- label_title: event.label && event.label[:name],
- old_title: event.rename && event.rename[:from],
- new_title: event.rename && event.rename[:to],
- milestone_title: event.milestone && event.milestone[:title],
- issue: event.issue&.to_h&.symbolize_keys,
- source: event.source,
- assignee: user_representation(event.assignee),
- requested_reviewer: user_representation(event.requested_reviewer),
- review_requester: user_representation(event.review_requester),
- created_at: event.created_at
+ id: event[:id],
+ actor: user_representation(event[:actor]),
+ event: event[:event],
+ commit_id: event[:commit_id],
+ label_title: event.dig(:label, :name),
+ old_title: event.dig(:rename, :from),
+ new_title: event.dig(:rename, :to),
+ milestone_title: event.dig(:milestone, :title),
+ issue: event[:issue]&.symbolize_keys,
+ source: event[:source],
+ assignee: user_representation(event[:assignee]),
+ requested_reviewer: user_representation(event[:requested_reviewer]),
+ review_requester: user_representation(event[:review_requester]),
+ created_at: event[:created_at]
)
end
diff --git a/lib/gitlab/github_import/representation/note.rb b/lib/gitlab/github_import/representation/note.rb
index ae56c370b19..0518b1386fc 100644
--- a/lib/gitlab/github_import/representation/note.rb
+++ b/lib/gitlab/github_import/representation/note.rb
@@ -18,12 +18,12 @@ module Gitlab
#
# note - An instance of `Sawyer::Resource` containing the note details.
def self.from_api_response(note, additional_data = {})
- matches = note.html_url.match(NOTEABLE_TYPE_REGEX)
+ matches = note[:html_url].match(NOTEABLE_TYPE_REGEX)
if !matches || !matches[:type]
raise(
ArgumentError,
- "The note URL #{note.html_url.inspect} is not supported"
+ "The note URL #{note[:html_url].inspect} is not supported"
)
end
@@ -34,15 +34,15 @@ module Gitlab
'Issue'
end
- user = Representation::User.from_api_response(note.user) if note.user
+ user = Representation::User.from_api_response(note[:user]) if note[:user]
hash = {
noteable_type: noteable_type,
noteable_id: matches[:iid].to_i,
author: user,
- note: note.body,
- created_at: note.created_at,
- updated_at: note.updated_at,
- note_id: note.id
+ note: note[:body],
+ created_at: note[:created_at],
+ updated_at: note[:updated_at],
+ note_id: note[:id]
}
new(hash)
diff --git a/lib/gitlab/github_import/representation/pull_request.rb b/lib/gitlab/github_import/representation/pull_request.rb
index 2adac2af502..c78478d4a03 100644
--- a/lib/gitlab/github_import/representation/pull_request.rb
+++ b/lib/gitlab/github_import/representation/pull_request.rb
@@ -19,28 +19,28 @@ module Gitlab
#
# issue - An instance of `Sawyer::Resource` containing the PR details.
def self.from_api_response(pr, additional_data = {})
- assignee = Representation::User.from_api_response(pr.assignee) if pr.assignee
- user = Representation::User.from_api_response(pr.user) if pr.user
- merged_by = Representation::User.from_api_response(pr.merged_by) if pr.merged_by
+ assignee = Representation::User.from_api_response(pr[:assignee]) if pr[:assignee]
+ user = Representation::User.from_api_response(pr[:user]) if pr[:user]
+ merged_by = Representation::User.from_api_response(pr[:merged_by]) if pr[:merged_by]
hash = {
- iid: pr.number,
- title: pr.title,
- description: pr.body,
- source_branch: pr.head.ref,
- target_branch: pr.base.ref,
- source_branch_sha: pr.head.sha,
- target_branch_sha: pr.base.sha,
- source_repository_id: pr.head&.repo&.id,
- target_repository_id: pr.base&.repo&.id,
- source_repository_owner: pr.head&.user&.login,
- state: pr.state == 'open' ? :opened : :closed,
- milestone_number: pr.milestone&.number,
+ iid: pr[:number],
+ title: pr[:title],
+ description: pr[:body],
+ source_branch: pr.dig(:head, :ref),
+ target_branch: pr.dig(:base, :ref),
+ source_branch_sha: pr.dig(:head, :sha),
+ target_branch_sha: pr.dig(:base, :sha),
+ source_repository_id: pr.dig(:head, :repo, :id),
+ target_repository_id: pr.dig(:base, :repo, :id),
+ source_repository_owner: pr.dig(:head, :user, :login),
+ state: pr[:state] == 'open' ? :opened : :closed,
+ milestone_number: pr.dig(:milestone, :number),
author: user,
assignee: assignee,
- created_at: pr.created_at,
- updated_at: pr.updated_at,
- merged_at: pr.merged_at,
+ created_at: pr[:created_at],
+ updated_at: pr[:updated_at],
+ merged_at: pr[:merged_at],
merged_by: merged_by
}
diff --git a/lib/gitlab/github_import/representation/pull_request_review.rb b/lib/gitlab/github_import/representation/pull_request_review.rb
index 8a7ecf0c588..691e7cce678 100644
--- a/lib/gitlab/github_import/representation/pull_request_review.rb
+++ b/lib/gitlab/github_import/representation/pull_request_review.rb
@@ -11,16 +11,19 @@ module Gitlab
expose_attribute :author, :note, :review_type, :submitted_at, :merge_request_id, :review_id
+ # Builds a PullRequestReview from a GitHub API response.
+ #
+ # review - An instance of `Sawyer::Resource` containing the note details.
def self.from_api_response(review, additional_data = {})
- user = Representation::User.from_api_response(review.user) if review.user
+ user = Representation::User.from_api_response(review[:user]) if review[:user]
new(
- merge_request_id: review.merge_request_id,
+ merge_request_id: review[:merge_request_id],
author: user,
- note: review.body,
- review_type: review.state,
- submitted_at: review.submitted_at,
- review_id: review.id
+ note: review[:body],
+ review_type: review[:state],
+ submitted_at: review[:submitted_at],
+ review_id: review[:id]
)
end
diff --git a/lib/gitlab/github_import/representation/user.rb b/lib/gitlab/github_import/representation/user.rb
index 4ef916cc41c..c06eaf514e3 100644
--- a/lib/gitlab/github_import/representation/user.rb
+++ b/lib/gitlab/github_import/representation/user.rb
@@ -16,8 +16,8 @@ module Gitlab
# user - An instance of `Sawyer::Resource` containing the user details.
def self.from_api_response(user, additional_data = {})
new(
- id: user.id,
- login: user.login
+ id: user[:id],
+ login: user[:login]
)
end
diff --git a/lib/gitlab/github_import/single_endpoint_notes_importing.rb b/lib/gitlab/github_import/single_endpoint_notes_importing.rb
index aea4059dfbc..5e8d23b7c2d 100644
--- a/lib/gitlab/github_import/single_endpoint_notes_importing.rb
+++ b/lib/gitlab/github_import/single_endpoint_notes_importing.rb
@@ -32,7 +32,7 @@ module Gitlab
end
def id_for_already_imported_cache(associated)
- associated.id
+ associated[:id]
end
def parent_collection
diff --git a/lib/gitlab/github_import/user_finder.rb b/lib/gitlab/github_import/user_finder.rb
index 1feb0d450f0..f1b18070440 100644
--- a/lib/gitlab/github_import/user_finder.rb
+++ b/lib/gitlab/github_import/user_finder.rb
@@ -39,18 +39,19 @@ module Gitlab
#
# If the object has no author ID we'll use the ID of the GitLab ghost
# user.
+ # object - An instance of `Sawyer::Resource` or a `Github::Representer`
def author_id_for(object, author_key: :author)
user_info = case author_key
when :actor
- object&.actor
+ object[:actor]
when :assignee
- object&.assignee
+ object[:assignee]
when :requested_reviewer
- object&.requested_reviewer
+ object[:requested_reviewer]
when :review_requester
- object&.review_requester
+ object[:review_requester]
else
- object&.author
+ object ? object[:author] : nil
end
id = user_info ? user_id_for(user_info) : GithubImport.ghost_user_id
@@ -64,14 +65,14 @@ module Gitlab
# Returns the GitLab user ID of an issuable's assignee.
def assignee_id_for(issuable)
- user_id_for(issuable.assignee) if issuable.assignee
+ user_id_for(issuable[:assignee]) if issuable[:assignee]
end
# Returns the GitLab user ID for a GitHub user.
#
- # user - An instance of `Gitlab::GithubImport::Representation::User`.
+ # user - An instance of `Gitlab::GithubImport::Representation::User` or `Sawyer::Resource`.
def user_id_for(user)
- find(user.id, user.login) if user.present?
+ find(user[:id], user[:login]) if user.present?
end
# Returns the GitLab ID for the given GitHub ID or username.
@@ -114,7 +115,7 @@ module Gitlab
unless email
user = client.user(username)
- email = Gitlab::Cache::Import::Caching.write(cache_key, user.email, timeout: timeout(user.email)) if user
+ email = Gitlab::Cache::Import::Caching.write(cache_key, user[:email], timeout: timeout(user[:email])) if user
end
email
diff --git a/scripts/slack b/scripts/slack
index 293f8070504..3ce2b4553ee 100755
--- a/scripts/slack
+++ b/scripts/slack
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# This is based on https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/bin/slack
#
# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set).
diff --git a/spec/frontend/content_editor/components/content_editor_spec.js b/spec/frontend/content_editor/components/content_editor_spec.js
index ae52cb05eaf..2172fda45f5 100644
--- a/spec/frontend/content_editor/components/content_editor_spec.js
+++ b/spec/frontend/content_editor/components/content_editor_spec.js
@@ -26,12 +26,13 @@ describe('ContentEditor', () => {
const findEditorStateObserver = () => wrapper.findComponent(EditorStateObserver);
const findLoadingIndicator = () => wrapper.findComponent(LoadingIndicator);
const findContentEditorAlert = () => wrapper.findComponent(ContentEditorAlert);
- const createWrapper = ({ markdown } = {}) => {
+ const createWrapper = ({ markdown, autofocus } = {}) => {
wrapper = shallowMountExtended(ContentEditor, {
propsData: {
renderMarkdown,
uploadsPath,
markdown,
+ autofocus,
},
stubs: {
EditorStateObserver,
@@ -70,14 +71,22 @@ describe('ContentEditor', () => {
expect(editorContent.classes()).toContain('md');
});
- it('renders ContentEditorProvider component', async () => {
- await createWrapper();
+ it('allows setting the tiptap editor to autofocus', async () => {
+ createWrapper({ autofocus: 'start' });
+
+ await nextTick();
+
+ expect(findEditorContent().props().editor.options.autofocus).toBe('start');
+ });
+
+ it('renders ContentEditorProvider component', () => {
+ createWrapper();
expect(wrapper.findComponent(ContentEditorProvider).exists()).toBe(true);
});
- it('renders top toolbar component', async () => {
- await createWrapper();
+ it('renders top toolbar component', () => {
+ createWrapper();
expect(wrapper.findComponent(TopToolbar).exists()).toBe(true);
});
diff --git a/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js b/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js
index 83aced63475..1b52e81d9ba 100644
--- a/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js
+++ b/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js
@@ -123,7 +123,7 @@ describe('WikiForm', () => {
renderMarkdownPath: pageInfoPersisted.markdownPreviewPath,
markdownDocsPath: pageInfoPersisted.markdownHelpPath,
uploadsPath: pageInfoPersisted.uploadsPath,
- autofocus: pageInfoPersisted.persisted,
+ initOnAutofocus: pageInfoPersisted.persisted,
formFieldId: 'wiki_content',
formFieldName: 'wiki[content]',
}),
diff --git a/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js b/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js
index da3777de1d0..ab47bed426e 100644
--- a/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js
+++ b/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js
@@ -1,12 +1,15 @@
import { GlSegmentedControl } from '@gitlab/ui';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
+import { nextTick } from 'vue';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import { EDITING_MODE_MARKDOWN_FIELD, EDITING_MODE_CONTENT_EDITOR } from '~/vue_shared/constants';
import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue';
import ContentEditor from '~/content_editor/components/content_editor.vue';
+import BubbleMenu from '~/content_editor/components/bubble_menus/bubble_menu.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import MarkdownField from '~/vue_shared/components/markdown/field.vue';
+import { stubComponent } from 'helpers/stub_component';
jest.mock('~/emoji');
@@ -15,7 +18,6 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
const value = 'test markdown';
const renderMarkdownPath = '/api/markdown';
const markdownDocsPath = '/help/markdown';
- const uploadsPath = '/uploads';
const enableAutocomplete = true;
const enablePreview = false;
const formFieldId = 'markdown_field';
@@ -24,13 +26,13 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
const formFieldAriaLabel = 'Edit your content';
let mock;
- const buildWrapper = (propsData = {}) => {
+ const buildWrapper = ({ propsData = {}, attachTo } = {}) => {
wrapper = mountExtended(MarkdownEditor, {
+ attachTo,
propsData: {
value,
renderMarkdownPath,
markdownDocsPath,
- uploadsPath,
enableAutocomplete,
enablePreview,
formFieldId,
@@ -39,6 +41,9 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
formFieldAriaLabel,
...propsData,
},
+ stubs: {
+ BubbleMenu: stubComponent(BubbleMenu),
+ },
});
};
const findSegmentedControl = () => wrapper.findComponent(GlSegmentedControl);
@@ -48,6 +53,7 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
const findContentEditor = () => wrapper.findComponent(ContentEditor);
beforeEach(() => {
+ window.uploads_path = 'uploads';
mock = new MockAdapter(axios);
});
@@ -66,7 +72,7 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
enableAutocomplete,
textareaValue: value,
markdownDocsPath,
- uploadsPath,
+ uploadsPath: window.uploads_path,
enablePreview,
}),
);
@@ -129,18 +135,32 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
expect(wrapper.emitted('input')).toEqual([[newValue]]);
});
+ describe('when initOnAutofocus is true', () => {
+ beforeEach(async () => {
+ buildWrapper({ attachTo: document.body, propsData: { initOnAutofocus: true } });
+
+ await nextTick();
+ });
+
+ it('sets the markdown field as the active element in the document', () => {
+ expect(document.activeElement).toBe(findTextarea().element);
+ });
+ });
+
describe(`when segmented control triggers input event with ${EDITING_MODE_CONTENT_EDITOR} value`, () => {
beforeEach(() => {
buildWrapper();
findSegmentedControl().vm.$emit('input', EDITING_MODE_CONTENT_EDITOR);
+ findSegmentedControl().vm.$emit('change', EDITING_MODE_CONTENT_EDITOR);
});
it('displays the content editor', () => {
expect(findContentEditor().props()).toEqual(
expect.objectContaining({
renderMarkdown: expect.any(Function),
- uploadsPath,
+ uploadsPath: window.uploads_path,
markdown: value,
+ autofocus: 'end',
}),
);
});
@@ -173,6 +193,17 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
findSegmentedControl().vm.$emit('input', EDITING_MODE_CONTENT_EDITOR);
});
+ describe('when initOnAutofocus is true', () => {
+ beforeEach(() => {
+ buildWrapper({ propsData: { initOnAutofocus: true } });
+ findLocalStorageSync().vm.$emit('input', EDITING_MODE_CONTENT_EDITOR);
+ });
+
+ it('sets the content editor autofocus property to end', () => {
+ expect(findContentEditor().props().autofocus).toBe('end');
+ });
+ });
+
it('emits input event when content editor emits change event', async () => {
const newValue = 'new value';
@@ -197,6 +228,19 @@ describe('vue_shared/component/markdown/markdown_editor', () => {
it('updates localStorage value', () => {
expect(findLocalStorageSync().props().value).toBe(EDITING_MODE_MARKDOWN_FIELD);
});
+
+ it('sets the textarea as the activeElement in the document', async () => {
+ // The component should be rebuilt to attach it to the document body
+ buildWrapper({ attachTo: document.body });
+ await findSegmentedControl().vm.$emit('input', EDITING_MODE_CONTENT_EDITOR);
+
+ expect(findContentEditor().exists()).toBe(true);
+
+ await findSegmentedControl().vm.$emit('input', EDITING_MODE_MARKDOWN_FIELD);
+ await findSegmentedControl().vm.$emit('change', EDITING_MODE_MARKDOWN_FIELD);
+
+ expect(document.activeElement).toBe(findTextarea().element);
+ });
});
describe('when content editor emits loading event', () => {
diff --git a/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb
index 8c4f7af0ef4..323bab89e6a 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/seed_spec.rb
@@ -68,8 +68,10 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Seed do
end
context 'when refs policy is specified' do
+ let(:tag_name) { project.repository.tags.first.name }
+
let(:pipeline) do
- build(:ci_pipeline, project: project, ref: 'feature', tag: true)
+ build(:ci_pipeline, project: project, ref: tag_name, tag: true)
end
let(:config) do
diff --git a/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb
index 6eb92cdeab9..85d39df7c89 100644
--- a/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb
@@ -7,14 +7,13 @@ RSpec.describe Gitlab::GithubImport::Importer::DiffNotesImporter do
let(:client) { double(:client) }
let(:github_comment) do
- double(
- :response,
+ {
html_url: 'https://github.com/foo/bar/pull/42',
path: 'README.md',
commit_id: '123abc',
original_commit_id: 'original123abc',
diff_hunk: "@@ -1 +1 @@\n-Hello\n+Hello world",
- user: double(:user, id: 4, login: 'alice'),
+ user: { id: 4, login: 'alice' },
created_at: Time.zone.now,
updated_at: Time.zone.now,
line: 23,
@@ -29,7 +28,7 @@ RSpec.describe Gitlab::GithubImport::Importer::DiffNotesImporter do
sug1
```
BODY
- )
+ }
end
describe '#parallel?' do
diff --git a/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb b/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb
index 6b807bdf098..e08659f5bac 100644
--- a/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb
@@ -9,20 +9,19 @@ RSpec.describe Gitlab::GithubImport::Importer::IssuesImporter do
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:github_issue) do
- double(
- :response,
+ {
number: 42,
title: 'My Issue',
body: 'This is my issue',
- milestone: double(:milestone, number: 4),
+ milestone: { number: 4 },
state: 'open',
- assignees: [double(:user, id: 4, login: 'alice')],
- labels: [double(:label, name: 'bug')],
- user: double(:user, id: 4, login: 'alice'),
+ assignees: [{ id: 4, login: 'alice' }],
+ labels: [{ name: 'bug' }],
+ user: { id: 4, login: 'alice' },
created_at: created_at,
updated_at: updated_at,
pull_request: false
- )
+ }
end
describe '#parallel?' do
diff --git a/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb b/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
index ca9d3e1e21c..81d534c566f 100644
--- a/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_red
describe '#build_labels' do
it 'returns an Array containnig label rows' do
- label = double(:label, name: 'bug', color: 'ffffff')
+ label = { name: 'bug', color: 'ffffff' }
expect(importer).to receive(:each_label).and_return([label])
@@ -41,7 +41,7 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_red
it 'does not create labels that already exist' do
create(:label, project: project, title: 'bug')
- label = double(:label, name: 'bug', color: 'ffffff')
+ label = { name: 'bug', color: 'ffffff' }
expect(importer).to receive(:each_label).and_return([label])
expect(importer.build_labels).to be_empty
@@ -60,7 +60,7 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_red
describe '#build' do
let(:label_hash) do
- importer.build(double(:label, name: 'bug', color: 'ffffff'))
+ importer.build({ name: 'bug', color: 'ffffff' })
end
it 'returns the attributes of the label as a Hash' do
diff --git a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
index dad1efc5a8d..04d76bd1f06 100644
--- a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
@@ -11,8 +11,7 @@ RSpec.describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:milestone) do
- double(
- :milestone,
+ {
number: 1,
title: '1.0',
description: 'The first release',
@@ -20,12 +19,11 @@ RSpec.describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab
due_on: due_on,
created_at: created_at,
updated_at: updated_at
- )
+ }
end
let(:milestone2) do
- double(
- :milestone,
+ {
number: 1,
title: '1.0',
description: 'The first release',
@@ -33,7 +31,7 @@ RSpec.describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab
due_on: nil,
created_at: created_at,
updated_at: updated_at
- )
+ }
end
describe '#execute' do
diff --git a/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb
index 3b4fe652da8..2fcc4f623a2 100644
--- a/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb
@@ -7,15 +7,14 @@ RSpec.describe Gitlab::GithubImport::Importer::NotesImporter do
let(:client) { double(:client) }
let(:github_comment) do
- double(
- :response,
+ {
html_url: 'https://github.com/foo/bar/issues/42',
- user: double(:user, id: 4, login: 'alice'),
+ user: { id: 4, login: 'alice' },
body: 'Hello world',
created_at: Time.zone.now,
updated_at: Time.zone.now,
id: 1
- )
+ }
end
describe '#parallel?' do
diff --git a/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb
index 016f6e5377b..f3a9bbac785 100644
--- a/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb
@@ -7,15 +7,16 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestMergedByImporter, :cle
let(:project) { merge_request.project }
let(:merged_at) { Time.new(2017, 1, 1, 12, 00).utc }
- let(:client_double) { double(user: double(id: 999, login: 'merger', email: 'merger@email.com')) }
- let(:merger_user) { double(id: 999, login: 'merger') }
+ let(:client_double) { double(user: { id: 999, login: 'merger', email: 'merger@email.com' } ) }
+ let(:merger_user) { { id: 999, login: 'merger' } }
let(:pull_request) do
- instance_double(
- Gitlab::GithubImport::Representation::PullRequest,
- iid: merge_request.iid,
- merged_at: merged_at,
- merged_by: merger_user
+ Gitlab::GithubImport::Representation::PullRequest.from_api_response(
+ {
+ number: merge_request.iid,
+ merged_at: merged_at,
+ merged_by: merger_user
+ }
)
end
diff --git a/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb
index a6da40f47f1..fb6024d0952 100644
--- a/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_request_review_importer_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestReviewImporter, :clean
let_it_be(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
- let(:client_double) { double(user: double(id: 999, login: 'author', email: 'author@email.com')) }
+ let(:client_double) { double(user: { id: 999, login: 'author', email: 'author@email.com' }) }
let(:submitted_at) { Time.new(2017, 1, 1, 12, 00).utc }
subject { described_class.new(review, project, client_double) }
diff --git a/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb
index c5846fa7a87..aa92abdb110 100644
--- a/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb
@@ -8,33 +8,30 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
let(:client) { double(:client) }
let(:pull_request) do
- double(
- :response,
+ {
number: 42,
title: 'My Pull Request',
body: 'This is my pull request',
state: 'closed',
- head: double(
- :head,
+ head: {
sha: '123abc',
ref: 'my-feature',
- repo: double(:repo, id: 400),
- user: double(:user, id: 4, login: 'alice')
- ),
- base: double(
- :base,
+ repo: { id: 400 },
+ user: { id: 4, login: 'alice' }
+ },
+ base: {
sha: '456def',
ref: 'master',
- repo: double(:repo, id: 200)
- ),
- milestone: double(:milestone, number: 4),
- user: double(:user, id: 4, login: 'alice'),
- assignee: double(:user, id: 4, login: 'alice'),
- merged_by: double(:user, id: 4, login: 'alice'),
+ repo: { id: 200 }
+ },
+ milestone: { number: 4 },
+ user: { id: 4, login: 'alice' },
+ assignee: { id: 4, login: 'alice' },
+ merged_by: { id: 4, login: 'alice' },
created_at: 1.second.ago,
updated_at: 1.second.ago,
merged_at: 1.second.ago
- )
+ }
end
describe '#parallel?' do
@@ -184,12 +181,11 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
context 'when the pull request was updated after the last update' do
let(:pr) do
- double(
- :pr,
+ {
updated_at: Time.zone.now,
- head: double(:head, sha: '123'),
- base: double(:base, sha: '456')
- )
+ head: { sha: '123' },
+ base: { sha: '456' }
+ }
end
before do
@@ -201,7 +197,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
it 'returns true when the head SHA is not present' do
expect(importer)
.to receive(:commit_exists?)
- .with(pr.head.sha)
+ .with('123')
.and_return(false)
expect(importer.update_repository?(pr)).to eq(true)
@@ -210,12 +206,12 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
it 'returns true when the base SHA is not present' do
expect(importer)
.to receive(:commit_exists?)
- .with(pr.head.sha)
+ .with('123')
.and_return(true)
expect(importer)
.to receive(:commit_exists?)
- .with(pr.base.sha)
+ .with('456')
.and_return(false)
expect(importer.update_repository?(pr)).to eq(true)
@@ -224,12 +220,12 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
it 'returns false if both the head and base SHAs are present' do
expect(importer)
.to receive(:commit_exists?)
- .with(pr.head.sha)
+ .with('123')
.and_return(true)
expect(importer)
.to receive(:commit_exists?)
- .with(pr.base.sha)
+ .with('456')
.and_return(true)
expect(importer.update_repository?(pr)).to eq(false)
@@ -238,7 +234,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
context 'when the pull request was updated before the last update' do
it 'returns false' do
- pr = double(:pr, updated_at: 1.year.ago)
+ pr = { updated_at: 1.year.ago }
allow(project)
.to receive(:last_repository_updated_at)
diff --git a/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb
index 0eb86feb040..5f9c73cbfff 100644
--- a/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_requests_reviews_importer_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsReviewsImporter do
end
describe '#id_for_already_imported_cache' do
- it { expect(subject.id_for_already_imported_cache(double(id: 1))).to eq(1) }
+ it { expect(subject.id_for_already_imported_cache({ id: 1 })).to eq(1) }
end
describe '#each_object_to_import', :clean_gitlab_redis_cache do
@@ -36,15 +36,11 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsReviewsImporter do
)
end
- let(:review) { double(id: 1) }
+ let(:review) { { id: 1 } }
it 'fetches the pull requests reviews data' do
page = double(objects: [review], number: 1)
- expect(review)
- .to receive(:merge_request_id=)
- .with(merge_request.id)
-
expect(client)
.to receive(:each_page)
.exactly(:once) # ensure to be cached on the second call
@@ -55,6 +51,8 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsReviewsImporter do
.to yield_with_args(review)
subject.each_object_to_import {}
+
+ expect(review[:merge_request_id]).to eq(merge_request.id)
end
it 'skips cached pages' do
diff --git a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
index b0f553dbef7..84d639a09ef 100644
--- a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
@@ -10,22 +10,21 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
let(:released_at) { Time.new(2017, 1, 1, 12, 00) }
let(:author) do
- double(
+ {
login: 'User A',
id: 1
- )
+ }
end
let(:github_release) do
- double(
- :github_release,
+ {
tag_name: '1.0',
name: github_release_name,
body: 'This is my release',
created_at: created_at,
published_at: released_at,
author: author
- )
+ }
end
def stub_email_for_github_username(user_name = 'User A', user_email = 'user@example.com')
@@ -56,7 +55,7 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
it 'imports draft releases' do
- release_double = double(
+ release_double = {
name: 'Test',
body: 'This is description',
tag_name: '1.0',
@@ -65,7 +64,7 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
updated_at: created_at,
published_at: nil,
author: author
- )
+ }
expect(importer).to receive(:each_release).and_return([release_double])
@@ -101,7 +100,7 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
it 'uses a default release description if none is provided' do
- expect(github_release).to receive(:body).and_return('')
+ github_release[:body] = nil
expect(importer).to receive(:each_release).and_return([github_release])
release = importer.build_releases.first
@@ -110,10 +109,10 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
it 'does not create releases that have a NULL tag' do
- null_tag_release = double(
+ null_tag_release = {
name: 'NULL Test',
tag_name: nil
- )
+ }
expect(importer).to receive(:each_release).and_return([null_tag_release])
expect(importer.build_releases).to be_empty
@@ -179,13 +178,13 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
it 'returns ghost user when author is empty in Github release' do
- allow(github_release).to receive(:author).and_return(nil)
+ github_release[:author] = nil
expect(release_hash[:author_id]).to eq(Gitlab::GithubImport.ghost_user_id)
end
context 'when Github author is not found in Gitlab' do
- let(:author) { double(login: 'octocat', id: 1 ) }
+ let(:author) { { login: 'octocat', id: 1 } }
before do
# Stub user email which does not match a Gitlab user.
@@ -222,11 +221,11 @@ RSpec.describe Gitlab::GithubImport::Importer::ReleasesImporter do
describe '#description_for' do
it 'returns the description when present' do
- expect(importer.description_for(github_release)).to eq(github_release.body)
+ expect(importer.description_for(github_release)).to eq(github_release[:body])
end
it 'returns a generated description when one is not present' do
- allow(github_release).to receive(:body).and_return('')
+ github_release[:body] = nil
expect(importer.description_for(github_release)).to eq('Release for tag 1.0')
end
diff --git a/spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb
index 471302cb31b..081d08edfb3 100644
--- a/spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointDiffNotesImporter d
it { expect(subject.importer_class).to eq(Gitlab::GithubImport::Importer::DiffNoteImporter) }
it { expect(subject.collection_method).to eq(:pull_request_comments) }
it { expect(subject.object_type).to eq(:diff_note) }
- it { expect(subject.id_for_already_imported_cache(double(id: 1))).to eq(1) }
+ it { expect(subject.id_for_already_imported_cache({ id: 1 })).to eq(1) }
describe '#each_object_to_import', :clean_gitlab_redis_cache do
let(:merge_request) do
@@ -26,7 +26,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointDiffNotesImporter d
)
end
- let(:note) { double(id: 1) }
+ let(:note) { { id: 1 } }
let(:page) { double(objects: [note], number: 1) }
it 'fetches data' do
diff --git a/spec/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer_spec.rb b/spec/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer_spec.rb
index 4ed01fd7e0b..15a0e15ae4d 100644
--- a/spec/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/single_endpoint_issue_events_importer_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter
end
describe '#id_for_already_imported_cache' do
- let(:event) { instance_double('Event', id: 1) }
+ let(:event) { { id: 1 } }
it { expect(subject.id_for_already_imported_cache(event)).to eq(1) }
end
@@ -116,8 +116,8 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter
counter = 0
subject.each_object_to_import do |object|
expect(object).to eq issue_event
- expect(issue_event.issue['number']).to eq issuable.iid
- expect(issue_event.issue['pull_request']).to eq false
+ expect(issue_event[:issue]['number']).to eq issuable.iid
+ expect(issue_event[:issue]['pull_request']).to eq false
counter += 1
end
expect(counter).to eq 1
@@ -131,8 +131,8 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter
counter = 0
subject.each_object_to_import do |object|
expect(object).to eq issue_event
- expect(issue_event.issue['number']).to eq issuable.iid
- expect(issue_event.issue['pull_request']).to eq true
+ expect(issue_event[:issue]['number']).to eq issuable.iid
+ expect(issue_event[:issue]['pull_request']).to eq true
counter += 1
end
expect(counter).to eq 1
diff --git a/spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb
index d769f4fdcf5..e1f65546e1d 100644
--- a/spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointIssueNotesImporter
it { expect(subject.importer_class).to eq(Gitlab::GithubImport::Importer::NoteImporter) }
it { expect(subject.collection_method).to eq(:issue_comments) }
it { expect(subject.object_type).to eq(:note) }
- it { expect(subject.id_for_already_imported_cache(double(id: 1))).to eq(1) }
+ it { expect(subject.id_for_already_imported_cache({ id: 1 })).to eq(1) }
describe '#each_object_to_import', :clean_gitlab_redis_cache do
let(:issue) do
@@ -25,7 +25,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointIssueNotesImporter
)
end
- let(:note) { double(id: 1) }
+ let(:note) { { id: 1 } }
let(:page) { double(objects: [note], number: 1) }
it 'fetches data' do
diff --git a/spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb
index 1dcc466d34c..5523b97acc3 100644
--- a/spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointMergeRequestNotesIm
it { expect(subject.importer_class).to eq(Gitlab::GithubImport::Importer::NoteImporter) }
it { expect(subject.collection_method).to eq(:issue_comments) }
it { expect(subject.object_type).to eq(:note) }
- it { expect(subject.id_for_already_imported_cache(double(id: 1))).to eq(1) }
+ it { expect(subject.id_for_already_imported_cache({ id: 1 })).to eq(1) }
describe '#each_object_to_import', :clean_gitlab_redis_cache do
let(:merge_request) do
@@ -26,7 +26,7 @@ RSpec.describe Gitlab::GithubImport::Importer::SingleEndpointMergeRequestNotesIm
)
end
- let(:note) { double(id: 1) }
+ let(:note) { { id: 1 } }
let(:page) { double(objects: [note], number: 1) }
it 'fetches data' do
diff --git a/spec/lib/gitlab/github_import/representation/diff_note_spec.rb b/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
index fe3040c102b..a656cd0d056 100644
--- a/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Gitlab::GithubImport::Representation::DiffNote, :clean_gitlab_red
let(:start_line) { nil }
let(:end_line) { 23 }
let(:note_body) { 'Hello world' }
- let(:user_data) { { 'id' => 4, 'login' => 'alice' } }
+ let(:user_data) { { id: 4, login: 'alice' } }
let(:side) { 'RIGHT' }
let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
@@ -275,15 +275,14 @@ RSpec.describe Gitlab::GithubImport::Representation::DiffNote, :clean_gitlab_red
describe '.from_api_response' do
it_behaves_like 'a DiffNote representation' do
let(:response) do
- double(
- :response,
+ {
id: note_id,
html_url: 'https://github.com/foo/bar/pull/42',
path: 'README.md',
commit_id: '123abc',
original_commit_id: 'original123abc',
side: side,
- user: user_data && double(:user, user_data),
+ user: user_data,
diff_hunk: hunk,
body: note_body,
created_at: created_at,
@@ -291,7 +290,7 @@ RSpec.describe Gitlab::GithubImport::Representation::DiffNote, :clean_gitlab_red
line: end_line,
start_line: start_line,
in_reply_to_id: in_reply_to_id
- )
+ }
end
subject(:note) { described_class.from_api_response(response) }
diff --git a/spec/lib/gitlab/github_import/representation/issue_spec.rb b/spec/lib/gitlab/github_import/representation/issue_spec.rb
index 5898518343a..263ef8b1708 100644
--- a/spec/lib/gitlab/github_import/representation/issue_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/issue_spec.rb
@@ -74,20 +74,19 @@ RSpec.describe Gitlab::GithubImport::Representation::Issue do
describe '.from_api_response' do
let(:response) do
- double(
- :response,
+ {
number: 42,
title: 'My Issue',
body: 'This is my issue',
- milestone: double(:milestone, number: 4),
+ milestone: { number: 4 },
state: 'open',
- assignees: [double(:user, id: 4, login: 'alice')],
- labels: [double(:label, name: 'bug')],
- user: double(:user, id: 4, login: 'alice'),
+ assignees: [{ id: 4, login: 'alice' }],
+ labels: [{ name: 'bug' }],
+ user: { id: 4, login: 'alice' },
created_at: created_at,
updated_at: updated_at,
pull_request: false
- )
+ }
end
let(:additional_data) { { work_item_type_id: work_item_type_id } }
@@ -97,9 +96,7 @@ RSpec.describe Gitlab::GithubImport::Representation::Issue do
end
it 'does not set the user if the response did not include a user' do
- allow(response)
- .to receive(:user)
- .and_return(nil)
+ response[:user] = nil
issue = described_class.from_api_response(response, additional_data)
diff --git a/spec/lib/gitlab/github_import/representation/note_spec.rb b/spec/lib/gitlab/github_import/representation/note_spec.rb
index 9f416eb3c02..49126dbe9c5 100644
--- a/spec/lib/gitlab/github_import/representation/note_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/note_spec.rb
@@ -48,15 +48,14 @@ RSpec.describe Gitlab::GithubImport::Representation::Note do
describe '.from_api_response' do
let(:response) do
- double(
- :response,
+ {
html_url: 'https://github.com/foo/bar/issues/42',
- user: double(:user, id: 4, login: 'alice'),
+ user: { id: 4, login: 'alice' },
body: 'Hello world',
created_at: created_at,
updated_at: updated_at,
id: 1
- )
+ }
end
it_behaves_like 'a Note' do
@@ -64,9 +63,7 @@ RSpec.describe Gitlab::GithubImport::Representation::Note do
end
it 'does not set the user if the response did not include a user' do
- allow(response)
- .to receive(:user)
- .and_return(nil)
+ response[:user] = nil
note = described_class.from_api_response(response)
diff --git a/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb b/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb
index d6e7a8172f7..0203da9f4fb 100644
--- a/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb
@@ -21,15 +21,14 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequestReview do
describe '.from_api_response' do
let(:response) do
- double(
- :response,
+ {
id: 999,
merge_request_id: 42,
body: 'note',
state: 'APPROVED',
- user: double(:user, id: 4, login: 'alice'),
+ user: { id: 4, login: 'alice' },
submitted_at: submitted_at
- )
+ }
end
it_behaves_like 'a PullRequest review' do
@@ -37,9 +36,7 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequestReview do
end
it 'does not set the user if the response did not include a user' do
- allow(response)
- .to receive(:user)
- .and_return(nil)
+ response[:user] = nil
review = described_class.from_api_response(response)
diff --git a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
index deb9535a845..b8c1c67e07c 100644
--- a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
@@ -93,33 +93,30 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequest do
describe '.from_api_response' do
let(:response) do
- double(
- :response,
+ {
number: 42,
title: 'My Pull Request',
body: 'This is my pull request',
state: 'closed',
- head: double(
- :head,
+ head: {
sha: '123abc',
ref: 'my-feature',
- repo: double(:repo, id: 400),
- user: double(:user, id: 4, login: 'alice')
- ),
- base: double(
- :base,
+ repo: { id: 400 },
+ user: { id: 4, login: 'alice' }
+ },
+ base: {
sha: '456def',
ref: 'master',
- repo: double(:repo, id: 200)
- ),
- milestone: double(:milestone, number: 4),
- user: double(:user, id: 4, login: 'alice'),
- assignee: double(:user, id: 4, login: 'alice'),
- merged_by: double(:user, id: 4, login: 'alice'),
+ repo: { id: 200 }
+ },
+ milestone: { number: 4 },
+ user: { id: 4, login: 'alice' },
+ assignee: { id: 4, login: 'alice' },
+ merged_by: { id: 4, login: 'alice' },
created_at: created_at,
updated_at: updated_at,
merged_at: merged_at
- )
+ }
end
it_behaves_like 'a PullRequest' do
@@ -127,9 +124,7 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequest do
end
it 'does not set the user if the response did not include a user' do
- allow(response)
- .to receive(:user)
- .and_return(nil)
+ response[:user] = nil
pr = described_class.from_api_response(response)
diff --git a/spec/lib/gitlab/github_import/representation/user_spec.rb b/spec/lib/gitlab/github_import/representation/user_spec.rb
index d7219556ada..ccada558f8b 100644
--- a/spec/lib/gitlab/github_import/representation/user_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/user_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Gitlab::GithubImport::Representation::User do
describe '.from_api_response' do
it_behaves_like 'a User' do
- let(:response) { double(:response, id: 42, login: 'alice') }
+ let(:response) { { id: 42, login: 'alice' } }
let(:user) { described_class.from_api_response(response) }
end
end
diff --git a/spec/lib/gitlab/github_import/user_finder_spec.rb b/spec/lib/gitlab/github_import/user_finder_spec.rb
index 8ebbff31f64..d77aaa0e846 100644
--- a/spec/lib/gitlab/github_import/user_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/user_finder_spec.rb
@@ -17,8 +17,8 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
describe '#author_id_for' do
context 'with default author_key' do
it 'returns the user ID for the author of an object' do
- user = double(:user, id: 4, login: 'kittens')
- note = double(:note, author: user)
+ user = { id: 4, login: 'kittens' }
+ note = { author: user }
expect(finder).to receive(:user_id_for).with(user).and_return(42)
@@ -26,8 +26,8 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
it 'returns the ID of the project creator if no user ID could be found' do
- user = double(:user, id: 4, login: 'kittens')
- note = double(:note, author: user)
+ user = { id: 4, login: 'kittens' }
+ note = { author: user }
expect(finder).to receive(:user_id_for).with(user).and_return(nil)
@@ -35,7 +35,7 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
it 'returns the ID of the ghost user when the object has no user' do
- note = double(:note, author: nil)
+ note = { author: nil }
expect(finder.author_id_for(note)).to eq([User.ghost.id, true])
end
@@ -46,7 +46,7 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
context 'with a non-default author_key' do
- let(:user) { double(:user, id: 4, login: 'kittens') }
+ let(:user) { { id: 4, login: 'kittens' } }
shared_examples 'user ID finder' do |author_key|
it 'returns the user ID for an object' do
@@ -57,25 +57,25 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
context 'when the author_key parameter is :actor' do
- let(:issue_event) { double('Gitlab::GithubImport::Representation::IssueEvent', actor: user) }
+ let(:issue_event) { { actor: user } }
it_behaves_like 'user ID finder', :actor
end
context 'when the author_key parameter is :assignee' do
- let(:issue_event) { double('Gitlab::GithubImport::Representation::IssueEvent', assignee: user) }
+ let(:issue_event) { { assignee: user } }
it_behaves_like 'user ID finder', :assignee
end
context 'when the author_key parameter is :requested_reviewer' do
- let(:issue_event) { double('Gitlab::GithubImport::Representation::IssueEvent', requested_reviewer: user) }
+ let(:issue_event) { { requested_reviewer: user } }
it_behaves_like 'user ID finder', :requested_reviewer
end
context 'when the author_key parameter is :review_requester' do
- let(:issue_event) { double('Gitlab::GithubImport::Representation::IssueEvent', review_requester: user) }
+ let(:issue_event) { { review_requester: user } }
it_behaves_like 'user ID finder', :review_requester
end
@@ -84,15 +84,15 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
describe '#assignee_id_for' do
it 'returns the user ID for the assignee of an issuable' do
- user = double(:user, id: 4, login: 'kittens')
- issue = double(:issue, assignee: user)
+ user = { id: 4, login: 'kittens' }
+ issue = { assignee: user }
expect(finder).to receive(:user_id_for).with(user).and_return(42)
expect(finder.assignee_id_for(issue)).to eq(42)
end
it 'returns nil if the issuable does not have an assignee' do
- issue = double(:issue, assignee: nil)
+ issue = { assignee: nil }
expect(finder).not_to receive(:user_id_for)
expect(finder.assignee_id_for(issue)).to be_nil
@@ -101,9 +101,9 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
describe '#user_id_for' do
it 'returns the user ID for the given user' do
- user = double(:user, id: 4, login: 'kittens')
+ user = { id: 4, login: 'kittens' }
- expect(finder).to receive(:find).with(user.id, user.login).and_return(42)
+ expect(finder).to receive(:find).with(user[:id], user[:login]).and_return(42)
expect(finder.user_id_for(user)).to eq(42)
end
@@ -221,7 +221,7 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
context 'when an Email address is not cached' do
- let(:user) { double(:user, email: email) }
+ let(:user) { { email: email } }
it 'retrieves the Email address from the GitHub API' do
expect(client).to receive(:user).with('kittens').and_return(user)
@@ -251,7 +251,7 @@ RSpec.describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
it 'shortens the timeout for Email address in cache when an Email address is private/nil from GitHub' do
- user = double(:user, email: nil)
+ user = { email: nil }
expect(client).to receive(:user).with('kittens').and_return(user)
expect(Gitlab::Cache::Import::Caching)
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 190227080cd..c57c21ad697 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -3069,8 +3069,24 @@ RSpec.describe Ci::Build do
end
context 'when build is for tag' do
+ let(:tag_name) { project.repository.tags.first.name }
+ let(:tag_message) { project.repository.tags.first.message }
+
+ let!(:pipeline) do
+ create(:ci_pipeline, project: project,
+ sha: project.commit.id,
+ ref: tag_name,
+ status: 'success')
+ end
+
+ let!(:build) { create(:ci_build, pipeline: pipeline, ref: tag_name) }
+
let(:tag_variable) do
- { key: 'CI_COMMIT_TAG', value: 'master', public: true, masked: false }
+ { key: 'CI_COMMIT_TAG', value: tag_name, public: true, masked: false }
+ end
+
+ let(:tag_message_variable) do
+ { key: 'CI_COMMIT_TAG_MESSAGE', value: tag_message, public: true, masked: false }
end
before do
@@ -3081,7 +3097,7 @@ RSpec.describe Ci::Build do
it do
build.reload
- expect(subject).to include(tag_variable)
+ expect(subject).to include(tag_variable, tag_message_variable)
end
end