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

Add latest changes from gitlab-org/gitlab@master

parent 4ce0bee9
No related branches found
No related tags found
No related merge requests found
Showing
with 320 additions and 89 deletions
Loading
Loading
@@ -60,6 +60,7 @@ module Gitlab
diff.importing = true
diff.save
diff.save_git_content
diff.set_as_latest_diff
end
end
end
Loading
Loading
Loading
Loading
@@ -80,7 +80,7 @@ module Gitlab
if host.present? && api_version.present?
"#{host}/api/#{api_version}"
else
github_options[:site]
github_options[:site] || ::Octokit::Default.api_endpoint
end
end
 
Loading
Loading
# frozen_string_literal: true
module Sentry
class ApiUrls
def initialize(url_base)
@uri = URI(url_base).freeze
end
def issues_url
with_path(File.join(@uri.path, '/issues/'))
end
def issue_url(issue_id)
with_path("/api/0/issues/#{escape(issue_id)}/")
end
def projects_url
with_path('/api/0/projects/')
end
def issue_latest_event_url(issue_id)
with_path("/api/0/issues/#{escape(issue_id)}/events/latest/")
end
private
def with_path(new_path)
new_uri = @uri.dup
# Sentry API returns 404 if there are extra slashes in the URL
new_uri.path = new_path.squeeze('/')
new_uri
end
def escape(param)
CGI.escape(param.to_s)
end
end
end
Loading
Loading
@@ -19,6 +19,10 @@ module Sentry
 
private
 
def api_urls
@api_urls ||= Sentry::ApiUrls.new(@url)
end
def handle_mapping_exceptions(&block)
yield
rescue KeyError => e
Loading
Loading
Loading
Loading
@@ -4,20 +4,13 @@ module Sentry
class Client
module Event
def issue_latest_event(issue_id:)
latest_event = http_get(issue_latest_event_api_url(issue_id))[:body]
latest_event = http_get(api_urls.issue_latest_event_url(issue_id))[:body]
 
map_to_event(latest_event)
end
 
private
 
def issue_latest_event_api_url(issue_id)
latest_event_url = URI(url)
latest_event_url.path = "/api/0/issues/#{issue_id}/events/latest/"
latest_event_url
end
def map_to_event(event)
stack_trace = parse_stack_trace(event)
 
Loading
Loading
Loading
Loading
@@ -35,14 +35,14 @@ module Sentry
end
 
def update_issue(issue_id:, params:)
http_put(issue_api_url(issue_id), params)[:body]
http_put(api_urls.issue_url(issue_id), params)[:body]
end
 
private
 
def get_issues(**keyword_args)
response = http_get(
issues_api_url,
api_urls.issues_url,
query: list_issue_sentry_query(keyword_args)
)
 
Loading
Loading
@@ -72,21 +72,7 @@ module Sentry
end
 
def get_issue(issue_id:)
http_get(issue_api_url(issue_id))[:body]
end
def issues_api_url
issues_url = URI("#{url}/issues/")
issues_url.path.squeeze!('/')
issues_url
end
def issue_api_url(issue_id)
issue_url = URI(url)
issue_url.path = "/api/0/issues/#{CGI.escape(issue_id.to_s)}/"
issue_url
http_get(api_urls.issue_url(issue_id))[:body]
end
 
def parse_gitlab_issue(plugin_issues)
Loading
Loading
Loading
Loading
@@ -14,14 +14,7 @@ module Sentry
private
 
def get_projects
http_get(projects_api_url)[:body]
end
def projects_api_url
projects_url = URI(url)
projects_url.path = '/api/0/projects/'
projects_url
http_get(api_urls.projects_url)[:body]
end
 
def map_to_projects(projects)
Loading
Loading
Loading
Loading
@@ -41,6 +41,11 @@ describe "User browses files" do
 
it "shows the `Browse Directory` link" do
click_link("files")
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link("History")
 
expect(page).to have_link("Browse Directory").and have_no_link("Browse Code")
Loading
Loading
Loading
Loading
@@ -19,7 +19,17 @@ describe 'Projects > Files > User browses LFS files' do
 
it 'is possible to see raw content of LFS pointer' do
click_link 'files'
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link 'lfs'
page.within('.repo-breadcrumb') do
expect(page).to have_link('lfs')
end
click_link 'lfs_object.iso'
 
expect(page).to have_content 'version https://git-lfs.github.com/spec/v1'
Loading
Loading
@@ -38,6 +48,11 @@ describe 'Projects > Files > User browses LFS files' do
 
it 'shows an LFS object' do
click_link('files')
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link('lfs')
click_link('lfs_object.iso')
 
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe 'User views AsciiDoc page with includes', :js do
let_it_be(:user) { create(:user) }
let_it_be(:wiki_content_selector) { '[data-qa-selector=wiki_page_content]' }
let(:project) { create(:project, :public, :wiki_repo) }
let!(:included_wiki_page) { create_wiki_page('included_page', content: 'Content from the included page')}
let!(:wiki_page) { create_wiki_page('home', content: "Content from the main page.\ninclude::included_page.asciidoc[]") }
def create_wiki_page(title, content:)
attrs = {
title: title,
content: content,
format: :asciidoc
}
create(:wiki_page, wiki: project.wiki, attrs: attrs)
end
before do
sign_in(user)
end
context 'when the file being included exists' do
it 'includes the file contents' do
visit(project_wiki_path(project, wiki_page))
page.within(:css, wiki_content_selector) do
expect(page).to have_content('Content from the main page. Content from the included page')
end
end
context 'when there are multiple versions of the wiki pages' do
before do
included_wiki_page.update(message: 'updated included file', content: 'Updated content from the included page')
wiki_page.update(message: 'updated wiki page', content: "Updated content from the main page.\ninclude::included_page.asciidoc[]")
end
let(:latest_version_id) { wiki_page.versions.first.id }
let(:oldest_version_id) { wiki_page.versions.last.id }
context 'viewing the latest version' do
it 'includes the latest content' do
visit(project_wiki_path(project, wiki_page, version_id: latest_version_id))
page.within(:css, wiki_content_selector) do
expect(page).to have_content('Updated content from the main page. Updated content from the included page')
end
end
end
context 'viewing the original version' do
it 'includes the content from the original version' do
visit(project_wiki_path(project, wiki_page, version_id: oldest_version_id))
page.within(:css, wiki_content_selector) do
expect(page).to have_content('Content from the main page. Content from the included page')
end
end
end
end
end
context 'when the file being included does not exist' do
before do
included_wiki_page.delete
end
it 'outputs an error' do
visit(project_wiki_path(project, wiki_page))
page.within(:css, wiki_content_selector) do
expect(page).to have_content('Content from the main page. [ERROR: include::included_page.asciidoc[] - unresolved directive]')
end
end
end
end
Loading
Loading
@@ -16,7 +16,8 @@
"confidential_note_events": { "type": "boolean" },
"pipeline_events": { "type": "boolean" },
"wiki_page_events": { "type": "boolean" },
"job_events": { "type": "boolean" }
"job_events": { "type": "boolean" },
"comment_on_event_enabled": { "type": "boolean" }
},
"additionalProperties": false
}
import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui';
import ParentRow from '~/repository/components/table/parent_row.vue';
 
let vm;
let $router;
 
function factory(path) {
function factory(path, loadingPath) {
$router = {
push: jest.fn(),
};
Loading
Loading
@@ -13,6 +14,7 @@ function factory(path) {
propsData: {
commitRef: 'master',
path,
loadingPath,
},
stubs: {
RouterLink: RouterLinkStub,
Loading
Loading
@@ -61,4 +63,10 @@ describe('Repository parent row component', () => {
path: '/tree/master/app',
});
});
it('renders loading icon when loading parent', () => {
factory('app/assets', 'app');
expect(vm.find(GlLoadingIcon).exists()).toBe(true);
});
});
import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { GlBadge, GlLink } from '@gitlab/ui';
import { GlBadge, GlLink, GlLoadingIcon } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility';
import TableRow from '~/repository/components/table/row.vue';
import Icon from '~/vue_shared/components/icon.vue';
Loading
Loading
@@ -198,4 +198,17 @@ describe('Repository table row component', () => {
expect(vm.find(Icon).exists()).toBe(true);
});
});
it('renders loading icon when path is loading', () => {
factory({
id: '1',
sha: '1',
path: 'test',
type: 'tree',
currentPath: '/',
loadingPath: 'test',
});
expect(vm.find(GlLoadingIcon).exists()).toBe(true);
});
});
Loading
Loading
@@ -273,16 +273,19 @@ describe MarkupHelper do
 
describe '#render_wiki_content' do
let(:wiki) { double('WikiPage', path: "file.#{extension}") }
let(:wiki_repository) { double('Repository') }
let(:context) do
{
pipeline: :wiki, project: project, project_wiki: wiki,
page_slug: 'nested/page', issuable_state_filter_enabled: true
page_slug: 'nested/page', issuable_state_filter_enabled: true,
repository: wiki_repository
}
end
 
before do
expect(wiki).to receive(:content).and_return('wiki content')
expect(wiki).to receive(:slug).and_return('nested/page')
expect(wiki).to receive(:repository).and_return(wiki_repository)
helper.instance_variable_set(:@project_wiki, wiki)
end
 
Loading
Loading
Loading
Loading
@@ -15,4 +15,11 @@ describe Gitlab::AppTextLogger do
it 'logs a string unchanged' do
expect(subject.format_message('INFO', Time.now, nil, string_message)).to include(string_message)
end
it 'logs time in UTC with ISO8601.3 standard' do
Timecop.freeze do
expect(subject.format_message('INFO', Time.now, nil, string_message))
.to include(Time.now.utc.iso8601(3))
end
end
end
Loading
Loading
@@ -518,6 +518,28 @@ module Gitlab
end
end
 
context 'when repository is passed into the context' do
let(:wiki_repo) { project.wiki.repository }
let(:include_path) { 'wiki_file.adoc' }
before do
project.create_wiki
context.merge!(repository: wiki_repo)
end
context 'when the file exists' do
before do
create_file(include_path, 'Content from wiki', repository: wiki_repo)
end
it { is_expected.to include('<p>Content from wiki</p>') }
end
context 'when the file does not exist' do
it { is_expected.to include("[ERROR: include::#{include_path}[] - unresolved directive]")}
end
end
context 'recursive includes with relative paths' do
let(:input) do
<<~ADOC
Loading
Loading
@@ -562,8 +584,8 @@ module Gitlab
end
end
 
def create_file(path, content)
project.repository.create_file(project.creator, path, content,
def create_file(path, content, repository: project.repository)
repository.create_file(project.creator, path, content,
message: "Add #{path}", branch_name: 'asciidoc')
end
end
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Sentry::ApiUrls do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/' }
let(:token) { 'test-token' }
let(:issue_id) { '123456' }
let(:issue_id_with_reserved_chars) { '123$%' }
let(:escaped_issue_id) { '123%24%25' }
let(:api_urls) { Sentry::ApiUrls.new(sentry_url) }
# Sentry API returns 404 if there are extra slashes in the URL!
shared_examples 'correct url with extra slashes' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects//sentry-org/sentry-project/' }
it_behaves_like 'correct url'
end
shared_examples 'correctly escapes issue ID' do
context 'with param a string with reserved chars' do
let(:issue_id) { issue_id_with_reserved_chars }
it { expect(subject.to_s).to include(escaped_issue_id) }
end
context 'with param a symbol with reserved chars' do
let(:issue_id) { issue_id_with_reserved_chars.to_sym }
it { expect(subject.to_s).to include(escaped_issue_id) }
end
context 'with param an integer' do
let(:issue_id) { 12345678 }
it { expect(subject.to_s).to include(issue_id.to_s) }
end
end
describe '#issues_url' do
subject { api_urls.issues_url }
shared_examples 'correct url' do
it { is_expected.to eq_uri('https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/issues/') }
end
it_behaves_like 'correct url'
it_behaves_like 'correct url with extra slashes'
end
describe '#issue_url' do
subject { api_urls.issue_url(issue_id) }
shared_examples 'correct url' do
it { is_expected.to eq_uri("https://sentrytest.gitlab.com/api/0/issues/#{issue_id}/") }
end
it_behaves_like 'correct url'
it_behaves_like 'correct url with extra slashes'
it_behaves_like 'correctly escapes issue ID'
end
describe '#projects_url' do
subject { api_urls.projects_url }
shared_examples 'correct url' do
it { is_expected.to eq_uri('https://sentrytest.gitlab.com/api/0/projects/') }
end
it_behaves_like 'correct url'
it_behaves_like 'correct url with extra slashes'
end
describe '#issue_latest_event_url' do
subject { api_urls.issue_latest_event_url(issue_id) }
shared_examples 'correct url' do
it { is_expected.to eq_uri("https://sentrytest.gitlab.com/api/0/issues/#{issue_id}/events/latest/") }
end
it_behaves_like 'correct url'
it_behaves_like 'correct url with extra slashes'
it_behaves_like 'correctly escapes issue ID'
end
end
Loading
Loading
@@ -109,28 +109,6 @@ describe Sentry::Client::Issue do
it_behaves_like 'no Sentry redirects'
end
 
# Sentry API returns 404 if there are extra slashes in the URL!
context 'extra slashes in URL' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects//sentry-org/sentry-project/' }
let(:sentry_request_url) do
'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/' \
'issues/?limit=20&query=is:unresolved'
end
it 'removes extra slashes in api url' do
expect(client.url).to eq(sentry_url)
expect(Gitlab::HTTP).to receive(:get).with(
URI('https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/issues/'),
anything
).and_call_original
subject
expect(sentry_api_request).to have_been_requested
end
end
context 'requests with sort parameter in sentry api' do
let(:sentry_request_url) do
'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/' \
Loading
Loading
@@ -232,14 +210,6 @@ describe Sentry::Client::Issue do
 
subject { client.issue_details(issue_id: issue_id) }
 
it 'escapes issue ID' do
allow(CGI).to receive(:escape).and_call_original
subject
expect(CGI).to have_received(:escape).with(issue_id.to_s)
end
context 'error object created from sentry response' do
using RSpec::Parameterized::TableSyntax
 
Loading
Loading
Loading
Loading
@@ -91,25 +91,6 @@ describe Sentry::Client::Projects do
it_behaves_like 'no Sentry redirects'
end
 
# Sentry API returns 404 if there are extra slashes in the URL!
context 'extra slashes in URL' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api//0/projects//' }
let!(:valid_req_stub) do
stub_sentry_request(sentry_list_projects_url)
end
it 'removes extra slashes in api url' do
expect(Gitlab::HTTP).to receive(:get).with(
URI(sentry_list_projects_url),
anything
).and_call_original
subject
expect(valid_req_stub).to have_been_requested
end
end
context 'when exception is raised' do
let(:sentry_request_url) { sentry_list_projects_url }
 
Loading
Loading
Loading
Loading
@@ -9,6 +9,32 @@ describe AtomicInternalId do
let(:scope_attrs) { { project: milestone.project } }
let(:usage) { :milestones }
 
describe '#save!' do
context 'when IID is provided' do
before do
milestone.iid = external_iid
end
it 'tracks the value' do
expect(milestone).to receive(:track_project_iid!)
milestone.save!
end
context 'when importing' do
before do
milestone.importing = true
end
it 'does not track the value' do
expect(milestone).not_to receive(:track_project_iid!)
milestone.save!
end
end
end
end
describe '#track_project_iid!' do
subject { milestone.track_project_iid! }
 
Loading
Loading
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