Skip to content
Snippets Groups Projects
Commit b98fa9ef authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 7e300596
No related branches found
No related tags found
No related merge requests found
Showing
with 289 additions and 145 deletions
Loading
Loading
@@ -115,7 +115,7 @@ data migration. Migrating millions of rows will always be troublesome and
can have a negative impact on the application.
 
To better understand how to get help with the query plan reviews
read this section on [how to prepare the merge request for a database review](https://docs.gitlab.com/ee/development/database_review.html#how-to-prepare-the-merge-request-for-a-database-review).
read this section on [how to prepare the merge request for a database review](database_review.md#how-to-prepare-the-merge-request-for-a-database-review).
 
## Query Counts
 
Loading
Loading
@@ -199,7 +199,7 @@ This could result in Puma/Unicorn timeout and should be avoided at all cost.
You should set a reasonable timeout, gracefully handle exceptions and surface the
errors in UI or logging internally.
 
Using [`ReactiveCaching`](https://docs.gitlab.com/ee/development/utilities.html#reactivecaching) is one of the best solutions to fetch external data.
Using [`ReactiveCaching`](utilities.md#reactivecaching) is one of the best solutions to fetch external data.
 
## Keep database transaction minimal
 
Loading
Loading
@@ -396,4 +396,4 @@ Performance deficiencies should be addressed right away after we merge initial
changes.
 
Read more about when and how feature flags should be used in
[Feature flags in GitLab development](https://docs.gitlab.com/ee/development/feature_flags/process.html#feature-flags-in-gitlab-development).
[Feature flags in GitLab development](feature_flags/process.md#feature-flags-in-gitlab-development).
Loading
Loading
@@ -49,7 +49,7 @@ require Rails.root.join('db', 'post_migrate', '20170526185842_migrate_pipeline_s
#### `table`
 
Use the `table` helper to create a temporary `ActiveRecord::Base`-derived model
for a table. [FactoryBot](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#factories)
for a table. [FactoryBot](best_practices.md#factories)
**should not** be used to create data for migration specs. For example, to
create a record in the `projects` table:
 
Loading
Loading
Loading
Loading
@@ -511,7 +511,7 @@ Here are some common pitfalls and how to overcome them:
If you see `Elasticsearch::Model::Response::Records`, you are using Elasticsearch.
 
NOTE: **Note**:
The above instructions are used to verify that GitLab is using Elasticsearch only when indexing all namespaces. This is not to be used for scenarios that only index a [subset of namespaces](https://docs.gitlab.com/ee/integration/elasticsearch.html#limiting-namespaces-and-projects).
The above instructions are used to verify that GitLab is using Elasticsearch only when indexing all namespaces. This is not to be used for scenarios that only index a [subset of namespaces](#limiting-namespaces-and-projects).
 
- **I updated GitLab and now I can't find anything**
 
Loading
Loading
@@ -534,7 +534,7 @@ Here are some common pitfalls and how to overcome them:
```
 
NOTE: **Note**:
The above instructions are not to be used for scenarios that only index a [subset of namespaces](https://docs.gitlab.com/ee/integration/elasticsearch.html#limiting-namespaces-and-projects).
The above instructions are not to be used for scenarios that only index a [subset of namespaces](#limiting-namespaces-and-projects).
 
See [Elasticsearch Index Scopes](#elasticsearch-index-scopes) for more information on searching for specific types of data.
 
Loading
Loading
@@ -597,7 +597,7 @@ Here are some common pitfalls and how to overcome them:
AWS has [fixed limits](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html)
for this setting ("Maximum Size of HTTP Request Payloads"), based on the size of
the underlying instance.
- **My single node Elasticsearch cluster status never goes from `yellow` to `green` even though everything seems to be running properly**
 
**For a single node Elasticsearch cluster the functional cluster health status will be yellow** (will never be green) because the primary shard is allocated but replicas can not be as there is no other node to which Elasticsearch can assign a replica. This also applies if you are using using the
Loading
Loading
@@ -614,7 +614,7 @@ Here are some common pitfalls and how to overcome them:
}
}'
```
- **I'm getting a `health check timeout: no Elasticsearch node available` error in Sidekiq during the indexing process**
 
```
Loading
Loading
Loading
Loading
@@ -243,7 +243,7 @@ If you reach your limit, you can [purchase additional CI minutes](#extra-shared-
 
##### How pipeline quota usage is calculated
 
Pipeline quota usage is calculated as the sum of the duration of each individual job. This is slightly different to how pipeline _duration_ is [calculated](https://docs.gitlab.com/ee/ci/pipelines.html#how-pipeline-duration-is-calculated). Pipeline quota usage doesn't consider the intersection of jobs.
Pipeline quota usage is calculated as the sum of the duration of each individual job. This is slightly different to how pipeline _duration_ is [calculated](../ci/pipelines.md#how-pipeline-duration-is-calculated). Pipeline quota usage doesn't consider the intersection of jobs.
 
A simple example is:
 
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ like:
- Working with secrets.
- Setting up CORS.
 
Alternatively, you can quickly [create a new project with a template](https://docs.gitlab.com/ee/gitlab-basics/create-project.html#project-templates). The [`Serverless Framework/JS` template](https://gitlab.com/gitlab-org/project-templates/serverless-framework/) already includes all parts described below.
Alternatively, you can quickly [create a new project with a template](../../../../gitlab-basics/create-project.md#project-templates). The [`Serverless Framework/JS` template](https://gitlab.com/gitlab-org/project-templates/serverless-framework/) already includes all parts described below.
 
## Example
 
Loading
Loading
@@ -282,6 +282,6 @@ The example code is available:
- As a [cloneable repository](https://gitlab.com/gitlab-org/serverless/examples/serverless-framework-js).
- In a version with [tests and secret variables](https://gitlab.com/gitlab-org/project-templates/serverless-framework/).
 
You can also use a [template](https://docs.gitlab.com/ee/gitlab-basics/create-project.html#project-templates)
You can also use a [template](../../../../gitlab-basics/create-project.md#project-templates)
(based on the version with tests and secret variables) from within the GitLab UI (see
the `Serverless Framework/JS` template).
Loading
Loading
@@ -7,7 +7,7 @@ type: reference
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/15643) in GitLab 11.7.
 
GitLab supports using client-side [Git push options](https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt)
to perform various actions at the same time as pushing changes. Additionally, [Push Rules](https://docs.gitlab.com/ee/push_rules/push_rules.html) offer server-side control and enforcement options.
to perform various actions at the same time as pushing changes. Additionally, [Push Rules](../../push_rules/push_rules.md) offer server-side control and enforcement options.
 
Currently, there are push options available for:
 
Loading
Loading
Loading
Loading
@@ -247,6 +247,7 @@ module API
requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
optional :title, type: String, desc: 'The title of an issue'
optional :updated_at, type: DateTime,
allow_blank: false,
desc: 'Date time when the issue was updated. Available only for admins and project owners.'
optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue'
use :issue_params
Loading
Loading
Loading
Loading
@@ -13,6 +13,7 @@ module Gitlab
 
def initialize(command_definitions)
@command_definitions = command_definitions
@commands_regex = {}
end
 
# Extracts commands from content and return an array of commands.
Loading
Loading
@@ -58,7 +59,8 @@ module Gitlab
content = content.dup
content.delete!("\r")
 
content.gsub!(commands_regex(only: only)) do
names = command_names(limit_to_commands: only).map(&:to_s)
content.gsub!(commands_regex(names: names)) do
command, output = process_commands($~, redact)
commands << command
output
Loading
Loading
@@ -91,10 +93,8 @@ module Gitlab
# It looks something like:
#
# /^\/(?<cmd>close|reopen|...)(?:( |$))(?<arg>[^\/\n]*)(?:\n|$)/
def commands_regex(only:)
names = command_names(limit_to_commands: only).map(&:to_s)
@commands_regex ||= %r{
def commands_regex(names:)
@commands_regex[names] ||= %r{
(?<code>
# Code blocks:
# ```
Loading
Loading
@@ -151,14 +151,18 @@ module Gitlab
end
 
substitution_definitions.each do |substitution|
match_data = substitution.match(content.downcase)
if match_data
command = [substitution.name.to_s]
command << match_data[1] unless match_data[1].empty?
commands << command
regex = commands_regex(names: substitution.all_names)
content = content.gsub(regex) do |text|
if $~[:cmd]
command = [substitution.name.to_s]
command << $~[:arg] if $~[:arg].present?
commands << command
substitution.perform_substitution(self, text)
else
text
end
end
content = substitution.perform_substitution(self, content)
end
 
[content, commands]
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ module Gitlab
return unless content
 
all_names.each do |a_name|
content = content.gsub(%r{/#{a_name}(?![\S]) ?(.*)$}i, execute_block(action_block, context, '\1'))
content = content.sub(%r{/#{a_name}(?![\S]) ?(.*)$}i, execute_block(action_block, context, '\1'))
end
 
content
Loading
Loading
Loading
Loading
@@ -155,7 +155,7 @@ module Gitlab
end
 
def repository
@repository ||= project.repository
@repository ||= project&.repository
end
end
end
Loading
Loading
Loading
Loading
@@ -3,9 +3,11 @@
require 'spec_helper'
 
describe Projects::SnippetsController do
include Gitlab::Routing
let_it_be(:user) { create(:user) }
let_it_be(:user2) { create(:user) }
let(:project) { create(:project_empty_repo, :public) }
let(:user) { create(:user) }
let(:user2) { create(:user) }
 
before do
project.add_maintainer(user)
Loading
Loading
@@ -318,14 +320,45 @@ describe Projects::SnippetsController do
end
end
 
shared_examples 'successful response' do
it 'renders the snippet' do
subject
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it 'renders the blob from the repository' do
subject
expect(assigns(:blob)).to eq(project_snippet.blobs.first)
end
context 'when feature flag version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it 'returns the snippet database content' do
subject
blob = assigns(:blob)
expect(blob.data).to eq(project_snippet.content)
end
end
end
%w[show raw].each do |action|
describe "GET ##{action}" do
context 'when the project snippet is private' do
let(:project_snippet) { create(:project_snippet, :private, project: project, author: user) }
let(:project_snippet) { create(:project_snippet, :private, :repository, project: project, author: user) }
subject { get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } }
 
context 'when anonymous' do
it 'responds with status 404' do
get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
subject
 
expect(response).to have_gitlab_http_status(:not_found)
end
Loading
Loading
@@ -336,12 +369,7 @@ describe Projects::SnippetsController do
sign_in(user)
end
 
it 'renders the snippet' do
get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it_behaves_like 'successful response'
end
 
context 'when signed in as a project member' do
Loading
Loading
@@ -349,19 +377,16 @@ describe Projects::SnippetsController do
sign_in(user2)
end
 
it 'renders the snippet' do
get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it_behaves_like 'successful response'
end
end
 
context 'when the project snippet does not exist' do
subject { get action, params: { namespace_id: project.namespace, project_id: project, id: 42 } }
context 'when anonymous' do
it 'responds with status 404' do
get action, params: { namespace_id: project.namespace, project_id: project, id: 42 }
subject
 
expect(response).to have_gitlab_http_status(:not_found)
end
Loading
Loading
@@ -373,7 +398,7 @@ describe Projects::SnippetsController do
end
 
it 'responds with status 404' do
get action, params: { namespace_id: project.namespace, project_id: project, id: 42 }
subject
 
expect(response).to have_gitlab_http_status(:not_found)
end
Loading
Loading
@@ -383,18 +408,20 @@ describe Projects::SnippetsController do
end
 
describe "GET #show for embeddable content" do
let(:project_snippet) { create(:project_snippet, snippet_permission, project: project, author: user) }
let(:project_snippet) { create(:project_snippet, :repository, snippet_permission, project: project, author: user) }
 
before do
sign_in(user)
get :show, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }, format: :js
end
 
subject { get :show, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }, format: :js }
context 'when snippet is private' do
let(:snippet_permission) { :private }
 
it 'responds with status 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
Loading
Loading
@@ -402,10 +429,7 @@ describe Projects::SnippetsController do
context 'when snippet is public' do
let(:snippet_permission) { :public }
 
it 'responds with status 200' do
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it_behaves_like 'successful response'
end
 
context 'when the project is private' do
Loading
Loading
@@ -415,6 +439,8 @@ describe Projects::SnippetsController do
let(:project_snippet) { create(:project_snippet, :public, project: project, author: user) }
 
it 'responds with status 404' do
subject
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(:not_found)
end
Loading
Loading
@@ -423,14 +449,17 @@ describe Projects::SnippetsController do
end
 
describe 'GET #raw' do
let(:content) { "first line\r\nsecond line\r\nthird line" }
let(:formatted_content) { content.gsub(/\r\n/, "\n") }
let(:project_snippet) do
create(
:project_snippet, :public,
:project_snippet, :public, :repository,
project: project,
author: user,
content: "first line\r\nsecond line\r\nthird line"
content: content
)
end
let(:blob) { project_snippet.blobs.first }
 
context 'CRLF line ending' do
let(:params) do
Loading
Loading
@@ -441,16 +470,22 @@ describe Projects::SnippetsController do
}
end
 
before do
allow_next_instance_of(Blob) do |instance|
allow(instance).to receive(:data).and_return(content)
end
end
it 'returns LF line endings by default' do
get :raw, params: params
 
expect(response.body).to eq("first line\nsecond line\nthird line")
expect(response.body).to eq(formatted_content)
end
 
it 'does not convert line endings when parameter present' do
get :raw, params: params.merge(line_ending: :raw)
 
expect(response.body).to eq("first line\r\nsecond line\r\nthird line")
expect(response.body).to eq(content)
end
end
end
Loading
Loading
Loading
Loading
@@ -3,11 +3,9 @@
require 'spec_helper'
 
describe SnippetsController do
let(:user) { create(:user) }
let_it_be(:user) { create(:user) }
 
describe 'GET #index' do
let(:user) { create(:user) }
context 'when username parameter is present' do
it_behaves_like 'paginated collection' do
let(:collection) { Snippet.all }
Loading
Loading
@@ -75,8 +73,37 @@ describe SnippetsController do
end
 
describe 'GET #show' do
shared_examples 'successful response' do
it 'renders the snippet' do
subject
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it 'renders the blob from the repository' do
subject
expect(assigns(:blob)).to eq(personal_snippet.blobs.first)
end
context 'when feature flag version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it 'returns the snippet database content' do
subject
blob = assigns(:blob)
expect(blob.data).to eq(personal_snippet.content)
end
end
end
context 'when the personal snippet is private' do
let(:personal_snippet) { create(:personal_snippet, :private, author: user) }
let_it_be(:personal_snippet) { create(:personal_snippet, :private, :repository, author: user) }
 
context 'when signed in' do
before do
Loading
Loading
@@ -95,11 +122,8 @@ describe SnippetsController do
end
 
context 'when signed in user is the author' do
it 'renders the snippet' do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
it_behaves_like 'successful response' do
subject { get :show, params: { id: personal_snippet.to_param } }
end
 
it 'responds with status 404 when embeddable content is requested' do
Loading
Loading
@@ -120,18 +144,15 @@ describe SnippetsController do
end
 
context 'when the personal snippet is internal' do
let(:personal_snippet) { create(:personal_snippet, :internal, author: user) }
let_it_be(:personal_snippet) { create(:personal_snippet, :internal, :repository, author: user) }
 
context 'when signed in' do
before do
sign_in(user)
end
 
it 'renders the snippet' do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
it_behaves_like 'successful response' do
subject { get :show, params: { id: personal_snippet.to_param } }
end
 
it 'responds with status 404 when embeddable content is requested' do
Loading
Loading
@@ -151,18 +172,15 @@ describe SnippetsController do
end
 
context 'when the personal snippet is public' do
let(:personal_snippet) { create(:personal_snippet, :public, author: user) }
let_it_be(:personal_snippet) { create(:personal_snippet, :public, :repository, author: user) }
 
context 'when signed in' do
before do
sign_in(user)
end
 
it 'renders the snippet' do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
it_behaves_like 'successful response' do
subject { get :show, params: { id: personal_snippet.to_param } }
end
 
it 'responds with status 200 when embeddable content is requested' do
Loading
Loading
@@ -481,8 +499,82 @@ describe SnippetsController do
end
 
describe "GET #raw" do
shared_examples '200 status' do
before do
subject
end
it 'responds with status 200' do
expect(assigns(:snippet)).to eq(snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it 'has expected headers' do
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
expect(response.header['Content-Disposition']).to match(/inline/)
end
it "sets #{Gitlab::Workhorse::DETECT_HEADER} header" do
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq 'true'
end
end
shared_examples 'CRLF line ending' do
let(:content) { "first line\r\nsecond line\r\nthird line" }
let(:formatted_content) { content.gsub(/\r\n/, "\n") }
let(:snippet) do
create(:personal_snippet, :public, :repository, author: user, content: content)
end
before do
allow_next_instance_of(Blob) do |instance|
allow(instance).to receive(:data).and_return(content)
end
subject
end
it 'returns LF line endings by default' do
expect(response.body).to eq(formatted_content)
end
context 'when parameter present' do
let(:params) { { id: snippet.to_param, line_ending: :raw } }
it 'does not convert line endings when parameter present' do
expect(response.body).to eq(content)
end
end
end
shared_examples 'successful response' do
it_behaves_like '200 status'
it_behaves_like 'CRLF line ending'
it 'returns snippet first blob data' do
subject
expect(response.body).to eq snippet.blobs.first.data
end
context 'when feature flag version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it_behaves_like '200 status'
it_behaves_like 'CRLF line ending'
it 'returns snippet database content' do
subject
expect(response.body).to eq snippet.content
end
end
end
context 'when the personal snippet is private' do
let(:personal_snippet) { create(:personal_snippet, :private, author: user) }
let_it_be(:personal_snippet) { create(:personal_snippet, :private, :repository, author: user) }
 
context 'when signed in' do
before do
Loading
Loading
@@ -501,24 +593,11 @@ describe SnippetsController do
end
 
context 'when signed in user is the author' do
before do
get :raw, params: { id: personal_snippet.to_param }
end
it_behaves_like 'successful response' do
let(:snippet) { personal_snippet }
let(:params) { { id: snippet.to_param } }
 
it 'responds with status 200' do
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
it 'has expected headers' do
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
expect(response.header['Content-Disposition']).to match(/inline/)
end
it "sets #{Gitlab::Workhorse::DETECT_HEADER} header" do
expect(response).to have_gitlab_http_status(:ok)
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
subject { get :raw, params: params }
end
end
end
Loading
Loading
@@ -533,18 +612,18 @@ describe SnippetsController do
end
 
context 'when the personal snippet is internal' do
let(:personal_snippet) { create(:personal_snippet, :internal, author: user) }
let_it_be(:personal_snippet) { create(:personal_snippet, :internal, :repository, author: user) }
 
context 'when signed in' do
before do
sign_in(user)
end
 
it 'responds with status 200' do
get :raw, params: { id: personal_snippet.to_param }
it_behaves_like 'successful response' do
let(:snippet) { personal_snippet }
let(:params) { { id: snippet.to_param } }
 
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
subject { get :raw, params: params }
end
end
 
Loading
Loading
@@ -558,36 +637,18 @@ describe SnippetsController do
end
 
context 'when the personal snippet is public' do
let(:personal_snippet) { create(:personal_snippet, :public, author: user) }
let_it_be(:personal_snippet) { create(:personal_snippet, :public, :repository, author: user) }
 
context 'when signed in' do
before do
sign_in(user)
end
 
it 'responds with status 200' do
get :raw, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(:ok)
end
context 'CRLF line ending' do
let(:personal_snippet) do
create(:personal_snippet, :public, author: user, content: "first line\r\nsecond line\r\nthird line")
end
it_behaves_like 'successful response' do
let(:snippet) { personal_snippet }
let(:params) { { id: snippet.to_param } }
 
it 'returns LF line endings by default' do
get :raw, params: { id: personal_snippet.to_param }
expect(response.body).to eq("first line\nsecond line\nthird line")
end
it 'does not convert line endings when parameter present' do
get :raw, params: { id: personal_snippet.to_param, line_ending: :raw }
expect(response.body).to eq("first line\r\nsecond line\r\nthird line")
end
subject { get :raw, params: params }
end
end
 
Loading
Loading
Loading
Loading
@@ -3,9 +3,9 @@
require 'spec_helper'
 
describe 'Thread Comments Snippet', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:snippet) { create(:project_snippet, :private, project: project, author: user) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:snippet) { create(:project_snippet, :private, :repository, project: project, author: user) }
 
before do
stub_feature_flags(snippets_vue: false)
Loading
Loading
Loading
Loading
@@ -5,8 +5,8 @@ require 'spec_helper'
describe 'Projects > Snippets > Create Snippet', :js do
include DropzoneHelper
 
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
 
def description_field
find('.js-description-input input,textarea')
Loading
Loading
@@ -102,7 +102,7 @@ describe 'Projects > Snippets > Create Snippet', :js do
end
 
it 'shows a public snippet on the index page but not the New snippet button' do
snippet = create(:project_snippet, :public, project: project)
snippet = create(:project_snippet, :public, :repository, project: project)
 
visit project_snippets_path(project)
 
Loading
Loading
Loading
Loading
@@ -3,9 +3,9 @@
require 'spec_helper'
 
describe 'Projects > Snippets > User comments on a snippet', :js do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:snippet) { create(:project_snippet, :repository, project: project, author: user) }
 
before do
stub_feature_flags(snippets_vue: false)
Loading
Loading
Loading
Loading
@@ -3,8 +3,8 @@
require 'spec_helper'
 
describe 'Reportable note on snippets', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
 
before do
stub_feature_flags(snippets_vue: false)
Loading
Loading
@@ -13,8 +13,8 @@ describe 'Reportable note on snippets', :js do
end
 
describe 'on project snippet' do
let(:snippet) { create(:project_snippet, :public, project: project, author: user) }
let!(:note) { create(:note_on_project_snippet, noteable: snippet, project: project) }
let_it_be(:snippet) { create(:project_snippet, :public, :repository, project: project, author: user) }
let_it_be(:note) { create(:note_on_project_snippet, noteable: snippet, project: project) }
 
before do
visit project_snippet_path(project, snippet)
Loading
Loading
Loading
Loading
@@ -41,6 +41,23 @@ describe 'Labels (JavaScript fixtures)' do
end
end
 
describe API::Helpers::LabelHelpers, type: :request do
include JavaScriptFixturesHelpers
include ApiHelpers
let(:user) { create(:user) }
before do
group.add_owner(user)
end
it 'api/group_labels.json' do
get api("/groups/#{group.id}/labels", user)
expect(response).to be_successful
end
end
describe Projects::LabelsController, '(JavaScript fixtures)', type: :controller do
render_views
 
Loading
Loading
import { viewerInformationForPath } from '~/vue_shared/components/content_viewer/lib/viewer_utils';
import { decorateFiles, splitParent } from '~/ide/lib/files';
import { decorateData } from '~/ide/stores/utils';
import { escapeFileUrl } from '~/lib/utils/url_utility';
 
const TEST_BRANCH_ID = 'lorem-ipsum';
const TEST_PROJECT_ID = 10;
Loading
Loading
@@ -22,7 +21,7 @@ const createEntries = paths => {
id: path,
name,
path,
url: createUrl(`/${TEST_PROJECT_ID}/${type}/${TEST_BRANCH_ID}/-/${escapeFileUrl(path)}`),
url: createUrl(`/${TEST_PROJECT_ID}/${type}/${TEST_BRANCH_ID}/-/${path}`),
type,
previewMode,
binary: (previewMode && previewMode.binary) || false,
Loading
Loading
Loading
Loading
@@ -494,7 +494,7 @@ describe('Multi-file store mutations', () => {
it('properly handles files with spaces in name', () => {
const path = 'my fancy path';
const newPath = 'new path';
const oldEntry = { ...file(path, path, 'blob'), url: `project/-/${encodeURI(path)}` };
const oldEntry = { ...file(path, path, 'blob'), url: `project/-/${path}` };
 
localState.entries[path] = oldEntry;
 
Loading
Loading
@@ -510,12 +510,12 @@ describe('Multi-file store mutations', () => {
id: newPath,
path: newPath,
name: newPath,
url: `project/-/new%20path`,
url: `project/-/new path`,
key: expect.stringMatching(newPath),
prevId: path,
prevName: path,
prevPath: path,
prevUrl: `project/-/my%20fancy%20path`,
prevUrl: `project/-/my fancy path`,
prevKey: oldEntry.key,
prevParentPath: oldEntry.parentPath,
});
Loading
Loading
import { file } from 'jest/ide/helpers';
import FileRow from '~/vue_shared/components/file_row.vue';
import { mount } from '@vue/test-utils';
import FileHeader from '~/vue_shared/components/file_row_header.vue';
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import { escapeFileUrl } from '~/lib/utils/url_utility';
 
describe('File row component', () => {
let wrapper;
 
function createComponent(propsData) {
wrapper = mount(FileRow, {
function createComponent(propsData, $router = undefined) {
wrapper = shallowMount(FileRow, {
propsData,
mocks: {
$router,
},
});
}
 
Loading
Loading
@@ -61,7 +67,7 @@ describe('File row component', () => {
}),
});
 
return wrapper.vm.$nextTick().then(() => {
return nextTick().then(() => {
expect(wrapper.vm.scrollIntoView).toHaveBeenCalled();
});
});
Loading
Loading
@@ -85,6 +91,27 @@ describe('File row component', () => {
level: 0,
});
 
expect(wrapper.element.classList).toContain('js-file-row-header');
expect(wrapper.contains(FileHeader)).toBe(true);
});
it('matches the current route against encoded file URL', () => {
const fileName = 'with space';
const rowFile = Object.assign({}, file(fileName), {
url: `/${fileName}`,
});
const routerPath = `/project/${escapeFileUrl(fileName)}`;
createComponent(
{
file: rowFile,
level: 0,
},
{
currentRoute: {
path: routerPath,
},
},
);
expect(wrapper.vm.hasUrlAtCurrentRoute()).toBe(true);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment