Skip to content
Snippets Groups Projects
Commit c1093fb2 authored by John Jarvis's avatar John Jarvis
Browse files

Merge remote-tracking branch 'origin' into 12-3-auto-deploy-20190911

parents b3c6267c 28292d51
No related branches found
No related tags found
No related merge requests found
Showing
with 225 additions and 100 deletions
Loading
Loading
@@ -274,7 +274,7 @@ You can keep track of the progress to include the missing items in:
| [Server-side Git Hooks](../../custom_hooks.md) | No | No |
| [Elasticsearch integration](../../../integration/elasticsearch.md) | No | No |
| [GitLab Pages](../../pages/index.md) | No | No |
| [Container Registry](../../container_registry.md) ([track progress](https://gitlab.com/gitlab-org/gitlab-ee/issues/2870)) | No | No |
| [Container Registry](../../container_registry.md) | Yes | No |
| [NPM Registry](../../npm_registry.md) | No | No |
| [Maven Packages](../../maven_packages.md) | No | No |
| [External merge request diffs](../../merge_request_diffs.md) | No, if they are on-disk | No |
Loading
Loading
Loading
Loading
@@ -780,15 +780,19 @@ It is also possible to copy and paste the contents of the [Auto DevOps
template] into your project and edit this as needed. You may prefer to do it
that way if you want to specifically remove any part of it.
 
### Using components of Auto-DevOps
### Using components of Auto DevOps
 
If you only require a subset of the features offered by Auto-DevOps, you can include
individual Auto-DevOps jobs into your own `.gitlab-ci.yml`.
If you only require a subset of the features offered by Auto DevOps, you can include
individual Auto DevOps jobs into your own `.gitlab-ci.yml`. Each component job relies
on a stage that should be defined in the `.gitlab-ci.yml` that includes the template.
 
For example, to make use of [Auto Build](#auto-build), you can add the following to
your `.gitlab-ci.yml`:
 
```yaml
stages:
- build
include:
- template: Jobs/Build.gitlab-ci.yml
```
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ module Gitlab
 
return {} if issuable_ids.empty?
 
issuable_note_count = ::Note.count_for_collection(issuable_ids, collection_type)
issuable_notes_count = ::Note.count_for_collection(issuable_ids, collection_type)
issuable_votes_count = ::AwardEmoji.votes_for_collection(issuable_ids, collection_type)
issuable_merge_requests_count =
if collection_type == 'Issue'
Loading
Loading
@@ -31,7 +31,7 @@ module Gitlab
issuable_ids.each_with_object({}) do |id, issuable_meta|
downvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.downvote? }
upvotes = issuable_votes_count.find { |votes| votes.awardable_id == id && votes.upvote? }
notes = issuable_note_count.find { |notes| notes.noteable_id == id }
notes = issuable_notes_count.find { |notes| notes.noteable_id == id }
merge_requests = issuable_merge_requests_count.find { |mr| mr.first == id }
 
issuable_meta[id] = ::Issuable::IssuableMeta.new(
Loading
Loading
# frozen_string_literal: true
module Gitlab
module NoteableMetadata
def noteable_meta_data(noteable_collection, collection_type)
# ActiveRecord uses Object#extend for null relations.
if !(noteable_collection.singleton_class < ActiveRecord::NullRelation) &&
noteable_collection.respond_to?(:limit_value) &&
noteable_collection.limit_value.nil?
raise 'Collection must have a limit applied for preloading meta-data'
end
# map has to be used here since using pluck or select will
# throw an error when ordering noteables which inserts
# a new order into the collection.
# We cannot use reorder to not mess up the paginated collection.
noteable_ids = noteable_collection.map(&:id)
return {} if noteable_ids.empty?
noteable_notes_count = ::Note.count_for_collection(noteable_ids, collection_type)
noteable_ids.each_with_object({}) do |id, noteable_meta|
notes = noteable_notes_count.find { |notes| notes.noteable_id == id }
noteable_meta[id] = ::Noteable::NoteableMeta.new(
notes.try(:count).to_i
)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Dashboard::SnippetsController do
let(:user) { create(:user) }
before do
sign_in(user)
end
describe 'GET #index' do
it_behaves_like 'paginated collection' do
let(:collection) { Snippet.all }
before do
create(:personal_snippet, :public, author: user)
end
end
end
end
Loading
Loading
@@ -82,35 +82,15 @@ describe Dashboard::TodosController do
end
end
 
context 'when using pagination' do
let(:last_page) { user.todos.page.total_pages }
it_behaves_like 'paginated collection' do
let!(:issues) { create_list(:issue, 3, project: project, assignees: [user]) }
let(:collection) { user.todos }
 
before do
issues.each { |issue| todo_service.new_issue(issue, user) }
allow(Kaminari.config).to receive(:default_per_page).and_return(2)
end
 
it 'redirects to last_page if page number is larger than number of pages' do
get :index, params: { page: (last_page + 1).to_param }
expect(response).to redirect_to(dashboard_todos_path(page: last_page))
end
it 'goes to the correct page' do
get :index, params: { page: last_page }
expect(assigns(:todos).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
end
it 'does not redirect to external sites when provided a host field' do
external_host = "www.example.com"
get :index, params: { page: (last_page + 1).to_param, host: external_host }
expect(response).to redirect_to(dashboard_todos_path(page: last_page))
end
context 'when providing no filters' do
it 'does not perform a query to get the page count, but gets that from the user' do
allow(controller).to receive(:current_user).and_return(user)
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Explore::SnippetsController do
describe 'GET #index' do
it_behaves_like 'paginated collection' do
let(:collection) { Snippet.all }
before do
create(:personal_snippet, :public)
end
end
end
end
Loading
Loading
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Projects::ForksController do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:forked_project) { Projects::ForkService.new(project, user).execute }
let(:forked_project) { Projects::ForkService.new(project, user, name: 'Some name').execute }
let(:group) { create(:group) }
 
before do
Loading
Loading
@@ -13,11 +13,12 @@ describe Projects::ForksController do
end
 
describe 'GET index' do
def get_forks
def get_forks(search: nil)
get :index,
params: {
namespace_id: project.namespace,
project_id: project
project_id: project,
search: search
}
end
 
Loading
Loading
@@ -31,6 +32,41 @@ describe Projects::ForksController do
 
expect(assigns[:forks]).to be_present
end
it 'forks counts are correct' do
get_forks
expect(assigns[:total_forks_count]).to eq(1)
expect(assigns[:public_forks_count]).to eq(1)
expect(assigns[:internal_forks_count]).to eq(0)
expect(assigns[:private_forks_count]).to eq(0)
end
context 'after search' do
it 'forks counts are correct' do
get_forks(search: 'Non-matching query')
expect(assigns[:total_forks_count]).to eq(1)
expect(assigns[:public_forks_count]).to eq(1)
expect(assigns[:internal_forks_count]).to eq(0)
expect(assigns[:private_forks_count]).to eq(0)
end
end
end
context 'when fork is internal' do
before do
forked_project.update(visibility_level: Project::INTERNAL, group: group)
end
it 'forks counts are correct' do
get_forks
expect(assigns[:total_forks_count]).to eq(1)
expect(assigns[:public_forks_count]).to eq(0)
expect(assigns[:internal_forks_count]).to eq(1)
expect(assigns[:private_forks_count]).to eq(0)
end
end
 
context 'when fork is private' do
Loading
Loading
@@ -38,12 +74,25 @@ describe Projects::ForksController do
forked_project.update(visibility_level: Project::PRIVATE, group: group)
end
 
it 'is not be visible for non logged in users' do
shared_examples 'forks counts' do
it 'forks counts are correct' do
get_forks
expect(assigns[:total_forks_count]).to eq(1)
expect(assigns[:public_forks_count]).to eq(0)
expect(assigns[:internal_forks_count]).to eq(0)
expect(assigns[:private_forks_count]).to eq(1)
end
end
it 'is not visible for non logged in users' do
get_forks
 
expect(assigns[:forks]).to be_blank
end
 
include_examples 'forks counts'
context 'when user is logged in' do
before do
sign_in(project.creator)
Loading
Loading
@@ -67,6 +116,8 @@ describe Projects::ForksController do
 
expect(assigns[:forks]).to be_present
end
include_examples 'forks counts'
end
 
context 'when user is a member of the Group' do
Loading
Loading
@@ -79,6 +130,8 @@ describe Projects::ForksController do
 
expect(assigns[:forks]).to be_present
end
include_examples 'forks counts'
end
end
end
Loading
Loading
Loading
Loading
@@ -71,9 +71,16 @@ describe Projects::IssuesController do
end
end
 
context 'with page param' do
let(:last_page) { project.issues.page.total_pages }
it_behaves_like 'paginated collection' do
let!(:issue_list) { create_list(:issue, 2, project: project) }
let(:collection) { project.issues }
let(:params) do
{
namespace_id: project.namespace.to_param,
project_id: project,
state: 'opened'
}
end
 
before do
sign_in(user)
Loading
Loading
@@ -81,51 +88,10 @@ describe Projects::IssuesController do
allow(Kaminari.config).to receive(:default_per_page).and_return(1)
end
 
it 'redirects to last_page if page number is larger than number of pages' do
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
page: (last_page + 1).to_param
}
expect(response).to redirect_to(namespace_project_issues_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope]))
end
it 'redirects to specified page' do
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
page: last_page.to_param
}
expect(assigns(:issues).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
end
it 'does not redirect to external sites when provided a host field' do
external_host = "www.example.com"
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
page: (last_page + 1).to_param,
host: external_host
}
expect(response).to redirect_to(namespace_project_issues_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope]))
end
it 'does not use pagination if disabled' do
allow(controller).to receive(:pagination_disabled?).and_return(true)
 
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
page: (last_page + 1).to_param
}
get :index, params: params.merge(page: last_page + 1)
 
expect(response).to have_gitlab_http_status(200)
expect(assigns(:issues).size).to eq(2)
Loading
Loading
Loading
Loading
@@ -13,31 +13,17 @@ describe Projects::SnippetsController do
end
 
describe 'GET #index' do
context 'when page param' do
let(:last_page) { project.snippets.page.total_pages }
let!(:project_snippet) { create(:project_snippet, :public, project: project, author: user) }
it 'redirects to last_page if page number is larger than number of pages' do
get :index,
params: {
namespace_id: project.namespace,
project_id: project,
page: (last_page + 1).to_param
}
expect(response).to redirect_to(namespace_project_snippets_path(page: last_page))
it_behaves_like 'paginated collection' do
let(:collection) { project.snippets }
let(:params) do
{
namespace_id: project.namespace,
project_id: project
}
end
 
it 'redirects to specified page' do
get :index,
params: {
namespace_id: project.namespace,
project_id: project,
page: last_page.to_param
}
expect(assigns(:snippets).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
before do
create(:project_snippet, :public, project: project, author: user)
end
end
 
Loading
Loading
Loading
Loading
@@ -9,6 +9,15 @@ describe SnippetsController do
let(:user) { create(:user) }
 
context 'when username parameter is present' do
it_behaves_like 'paginated collection' do
let(:collection) { Snippet.all }
let(:params) { { username: user.username } }
before do
create(:personal_snippet, :public, author: user)
end
end
it 'renders snippets of a user when username is present' do
get :index, params: { username: user.username }
 
Loading
Loading
Loading
Loading
@@ -121,7 +121,6 @@ describe 'Project fork' do
end
 
expect(page).not_to have_content("#{another_project_fork.namespace.human_name} / #{another_project_fork.name}")
expect(page).to have_content("1 private fork")
end
end
 
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::NoteableMetadata do
subject { Class.new { include Gitlab::NoteableMetadata }.new }
it 'returns an empty Hash if an empty collection is provided' do
expect(subject.noteable_meta_data(Snippet.none, 'Snippet')).to eq({})
end
it 'raises an error when given a collection with no limit' do
expect { subject.noteable_meta_data(Snippet.all, 'Snippet') }.to raise_error(/must have a limit/)
end
context 'snippets' do
let!(:snippet) { create(:personal_snippet) }
let!(:other_snippet) { create(:personal_snippet) }
let!(:note) { create(:note, noteable: snippet) }
it 'aggregates stats on snippets' do
data = subject.noteable_meta_data(Snippet.all.limit(10), 'Snippet')
expect(data.count).to eq(2)
expect(data[snippet.id].user_notes_count).to eq(1)
expect(data[other_snippet.id].user_notes_count).to eq(0)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'paginated collection' do
let(:collection) { nil }
let(:last_page) { collection.page.total_pages }
let(:action) { :index }
let(:params) { {} }
it 'renders a page number that is not ouf of range' do
get action, params: params.merge(page: last_page)
expect(response).to have_gitlab_http_status(200)
end
it 'redirects to last_page if page number is larger than number of pages' do
get action, params: params.merge(page: last_page + 1)
expect(response).to redirect_to(params.merge(page: last_page))
end
it 'does not redirect to external sites when provided a host field' do
external_host = 'www.example.com'
get action, params: params.merge(page: last_page + 1, host: external_host)
expect(response).to redirect_to(params.merge(page: last_page))
end
end
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