Commit 406dfd6e authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge remote-tracking branch 'upstream/master' into fix-git-hooks-when-creating-file

* upstream/master:
  Ensure we have a project with a repo in GitlabMarkdownHelper specs
  Revert "Make sure TraceReader uses Encoding.default_external"
  Make sure TraceReader uses Encoding.default_external
  Update CONTRIBUTING.md after merging "up-for-grabs" and "Accepting Merge Requests" [ci skip]
  Use `:empty_project` where possible in finder specs
  Use `empty_project` where possible in controller specs
  Use `:empty_project` where possible in helper specs
  Don’t count tasks that are not defined as list items correctly
  Use a project factory with a repository where necessary
  Use `:empty_project` where possible throughout spec/lib
  Use hashrocket for dasherized attribute
  Remove markdown file extension and add anchor to link
  Fixed builds info link on project settings page
  Factories with a project association use `:empty_project` by default
  Update enviroments.md the example for deleting an environment is missing the "s" in environments. curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/environments/1"  wil 404
parents 8f3aa6ac d6bc24de
...@@ -80,11 +80,9 @@ the remaining issues on the GitHub issue tracker. ...@@ -80,11 +80,9 @@ the remaining issues on the GitHub issue tracker.
## I want to contribute! ## I want to contribute!
If you want to contribute to GitLab, but are not sure where to start, If you want to contribute to GitLab, but are not sure where to start,
look for [issues with the label `up-for-grabs`][up-for-grabs]. These issues look for [issues with the label `Accepting Merge Requests` and weight < 5][accepting-mrs-weight].
will be of reasonable size and challenge, for anyone to start contributing to These issues will be of reasonable size and challenge, for anyone to start
GitLab. contributing to GitLab.
This was inspired by [an article by Kent C. Dodds][medium-up-for-grabs].
## Implement design & UI elements ## Implement design & UI elements
...@@ -214,16 +212,19 @@ associated with in the description of the issue. ...@@ -214,16 +212,19 @@ associated with in the description of the issue.
## Merge requests ## Merge requests
We welcome merge requests with fixes and improvements to GitLab code, tests, We welcome merge requests with fixes and improvements to GitLab code, tests,
and/or documentation. The features we would really like a merge request for are and/or documentation. The issues that are specifically suitable for
listed with the label [`Accepting Merge Requests` on our issue tracker for CE][accepting-mrs-ce] community contributions are listed with the label
and [EE][accepting-mrs-ee] but other improvements are also welcome. Please note [`Accepting Merge Requests` on our issue tracker for CE][accepting-mrs-ce]
that if an issue is marked for the current milestone either before or while you and [EE][accepting-mrs-ee], but you are free to contribute to any other issue
are working on it, a team member may take over the merge request in order to you want.
ensure the work is finished before the release date.
Please note that if an issue is marked for the current milestone either before
or while you are working on it, a team member may take over the merge request
in order to ensure the work is finished before the release date.
If you want to add a new feature that is not labeled it is best to first create If you want to add a new feature that is not labeled it is best to first create
a feedback issue (if there isn't one already) and leave a comment asking for it a feedback issue (if there isn't one already) and leave a comment asking for it
to be marked as `Accepting merge requests`. Please include screenshots or to be marked as `Accepting Merge Requests`. Please include screenshots or
wireframes if the feature will also change the UI. wireframes if the feature will also change the UI.
Merge requests should be opened at [GitLab.com][gitlab-mr-tracker]. Merge requests should be opened at [GitLab.com][gitlab-mr-tracker].
...@@ -450,8 +451,7 @@ available at [http://contributor-covenant.org/version/1/1/0/](http://contributor ...@@ -450,8 +451,7 @@ available at [http://contributor-covenant.org/version/1/1/0/](http://contributor
[core team]: https://about.gitlab.com/core-team/ [core team]: https://about.gitlab.com/core-team/
[getting-help]: https://about.gitlab.com/getting-help/ [getting-help]: https://about.gitlab.com/getting-help/
[codetriage]: http://www.codetriage.com/gitlabhq/gitlabhq [codetriage]: http://www.codetriage.com/gitlabhq/gitlabhq
[up-for-grabs]: https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name=up-for-grabs [accepting-mrs-weight]: https://gitlab.com/gitlab-org/gitlab-ce/issues?assignee_id=0&label_name[]=Accepting%20Merge%20Requests&sort=weight_asc
[medium-up-for-grabs]: https://medium.com/@kentcdodds/first-timers-only-78281ea47455
[ce-tracker]: https://gitlab.com/gitlab-org/gitlab-ce/issues [ce-tracker]: https://gitlab.com/gitlab-org/gitlab-ce/issues
[ee-tracker]: https://gitlab.com/gitlab-org/gitlab-ee/issues [ee-tracker]: https://gitlab.com/gitlab-org/gitlab-ee/issues
[google-group]: https://groups.google.com/forum/#!forum/gitlabhq [google-group]: https://groups.google.com/forum/#!forum/gitlabhq
......
...@@ -11,10 +11,10 @@ module Taskable ...@@ -11,10 +11,10 @@ module Taskable
INCOMPLETE = 'incomplete'.freeze INCOMPLETE = 'incomplete'.freeze
ITEM_PATTERN = / ITEM_PATTERN = /
^ ^
\s*(?:[-+*]|(?:\d+\.))? # optional list prefix \s*(?:[-+*]|(?:\d+\.)) # list prefix required - task item has to be always in a list
\s* # optional whitespace prefix \s+ # whitespace prefix has to be always presented for a list item
(\[\s\]|\[[xX]\]) # checkbox (\[\s\]|\[[xX]\]) # checkbox
(\s.+) # followed by whitespace and some text. (\s.+) # followed by whitespace and some text.
/x /x
def self.get_tasks(content) def self.get_tasks(content)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
%br %br
%span.descr %span.descr
Builds need to be configured to enable this feature. Builds need to be configured to enable this feature.
= link_to icon('question-circle'), help_page_path('user/project/merge_requests/merge_when_build_succeeds', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds') = link_to icon('question-circle'), help_page_path('user/project/merge_requests/merge_when_pipeline_succeeds', anchor: 'only-allow-merge-requests-to-be-merged-if-the-pipeline-succeeds')
.checkbox .checkbox
= form.label :only_allow_merge_if_all_discussions_are_resolved do = form.label :only_allow_merge_if_all_discussions_are_resolved do
= form.check_box :only_allow_merge_if_all_discussions_are_resolved = form.check_box :only_allow_merge_if_all_discussions_are_resolved
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
.btn-group.inline .btn-group.inline
- if actions.any? - if actions.any?
.btn-group .btn-group
%button.dropdown-toggle.btn.btn-default.has-tooltip.js-pipeline-dropdown-manual-actions{ type: 'button', title: 'Manual build', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label': 'Manual build' } %button.dropdown-toggle.btn.btn-default.has-tooltip.js-pipeline-dropdown-manual-actions{ type: 'button', title: 'Manual build', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label' => 'Manual build' }
= custom_icon('icon_play') = custom_icon('icon_play')
= icon('caret-down', 'aria-hidden' => 'true') = icon('caret-down', 'aria-hidden' => 'true')
%ul.dropdown-menu.dropdown-menu-align-right %ul.dropdown-menu.dropdown-menu-align-right
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
%span= build.name %span= build.name
- if artifacts.present? - if artifacts.present?
.btn-group .btn-group
%button.dropdown-toggle.btn.btn-default.build-artifacts.has-tooltip.js-pipeline-dropdown-download{ type: 'button', title: 'Artifacts', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label': 'Artifacts' } %button.dropdown-toggle.btn.btn-default.build-artifacts.has-tooltip.js-pipeline-dropdown-download{ type: 'button', title: 'Artifacts', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label' => 'Artifacts' }
= icon("download") = icon("download")
= icon('caret-down') = icon('caret-down')
%ul.dropdown-menu.dropdown-menu-align-right %ul.dropdown-menu.dropdown-menu-align-right
...@@ -102,8 +102,8 @@ ...@@ -102,8 +102,8 @@
- if can?(current_user, :update_pipeline, pipeline.project) - if can?(current_user, :update_pipeline, pipeline.project)
.cancel-retry-btns.inline .cancel-retry-btns.inline
- if pipeline.retryable? - if pipeline.retryable?
= link_to retry_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: 'btn has-tooltip', title: 'Retry', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label': 'Retry' , method: :post do = link_to retry_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: 'btn has-tooltip', title: 'Retry', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label' => 'Retry' , method: :post do
= icon("repeat") = icon("repeat")
- if pipeline.cancelable? - if pipeline.cancelable?
= link_to cancel_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: 'btn btn-remove has-tooltip', title: 'Cancel', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label': 'Cancel' , method: :post do = link_to cancel_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: 'btn btn-remove has-tooltip', title: 'Cancel', data: { toggle: 'dropdown', placement: 'top' }, 'aria-label' => 'Cancel' , method: :post do
= icon("remove") = icon("remove")
---
title: Don’t count tasks that are not defined as list items correctly
merge_request: 8526
author:
---
title: Updated builds info link on the project settings page
merge_request:
author: Ryan Harris
...@@ -30,14 +30,13 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps ...@@ -30,14 +30,13 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
end end
step 'I am signed in as a developer of the project' do step 'I am signed in as a developer of the project' do
@user = create(:user) { |u| @project.add_developer(u) }
login_as(@user) login_as(@user)
end end
step 'There is an open Merge Request' do step 'There is an open Merge Request' do
@user = create(:user) @merge_request = create(:merge_request, :with_diffs, :simple)
@project = create(:project, :public, :repository) @project = @merge_request.source_project
@project_member = create(:project_member, :developer, user: @user, project: @project)
@merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
end end
step 'I should see a revert error' do step 'I should see a revert error' do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::GroupsController do describe Admin::GroupsController do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) } let(:project) { create(:empty_project, namespace: group) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Admin::ProjectsController do describe Admin::ProjectsController do
let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let!(:project) { create(:empty_project, :public) }
before do before do
sign_in(create(:admin)) sign_in(create(:admin))
......
require 'spec_helper' require 'spec_helper'
describe AutocompleteController do describe AutocompleteController do
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
let!(:user) { create(:user) } let!(:user) { create(:user) }
context 'GET users' do context 'GET users' do
......
require 'spec_helper' require 'spec_helper'
describe Projects::BlobController do describe Projects::BlobController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Ci::ProjectsController do describe Ci::ProjectsController do
let(:visibility) { :public } let(:visibility) { :public }
let!(:project) { create(:project, visibility, ci_id: 1) } let!(:project) { create(:empty_project, visibility, ci_id: 1) }
let(:ci_id) { project.ci_id } let(:ci_id) { project.ci_id }
describe '#index' do describe '#index' do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Dashboard::TodosController do describe Dashboard::TodosController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:todo_service) { TodoService.new } let(:todo_service) { TodoService.new }
describe 'GET #index' do describe 'GET #index' do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Groups::MilestonesController do describe Groups::MilestonesController do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, group: group) } let(:project) { create(:empty_project, group: group) }
let(:project2) { create(:empty_project, group: group) } let(:project2) { create(:empty_project, group: group) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:title) { '肯定不是中文的问题' } let(:title) { '肯定不是中文的问题' }
......
...@@ -3,7 +3,7 @@ require 'rails_helper' ...@@ -3,7 +3,7 @@ require 'rails_helper'
describe GroupsController do describe GroupsController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) } let(:project) { create(:empty_project, namespace: group) }
let!(:group_member) { create(:group_member, group: group, user: user) } let!(:group_member) { create(:group_member, group: group, user: user) }
describe 'GET #index' do describe 'GET #index' do
......
...@@ -52,7 +52,7 @@ describe Import::BitbucketController do ...@@ -52,7 +52,7 @@ describe Import::BitbucketController do
end end
it "assigns variables" do it "assigns variables" do
@project = create(:project, import_type: 'bitbucket', creator_id: user.id) @project = create(:empty_project, import_type: 'bitbucket', creator_id: user.id)
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo]) allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status get :status
...@@ -63,7 +63,7 @@ describe Import::BitbucketController do ...@@ -63,7 +63,7 @@ describe Import::BitbucketController do
end end
it "does not show already added project" do it "does not show already added project" do
@project = create(:project, import_type: 'bitbucket', creator_id: user.id, import_source: 'asd/vim') @project = create(:empty_project, import_type: 'bitbucket', creator_id: user.id, import_source: 'asd/vim')
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo]) allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status get :status
......
...@@ -16,7 +16,7 @@ describe Import::FogbugzController do ...@@ -16,7 +16,7 @@ describe Import::FogbugzController do
end end
it 'assigns variables' do it 'assigns variables' do
@project = create(:project, import_type: 'fogbugz', creator_id: user.id) @project = create(:empty_project, import_type: 'fogbugz', creator_id: user.id)
stub_client(repos: [@repo]) stub_client(repos: [@repo])
get :status get :status
...@@ -26,7 +26,7 @@ describe Import::FogbugzController do ...@@ -26,7 +26,7 @@ describe Import::FogbugzController do
end end
it 'does not show already added project' do it 'does not show already added project' do
@project = create(:project, import_type: 'fogbugz', creator_id: user.id, import_source: 'vim') @project = create(:empty_project, import_type: 'fogbugz', creator_id: user.id, import_source: 'vim')
stub_client(repos: [@repo]) stub_client(repos: [@repo])
get :status get :status
......
...@@ -36,7 +36,7 @@ describe Import::GitlabController do ...@@ -36,7 +36,7 @@ describe Import::GitlabController do
end end
it "assigns variables" do it "assigns variables" do
@project = create(:project, import_type: 'gitlab', creator_id: user.id) @project = create(:empty_project, import_type: 'gitlab', creator_id: user.id)
stub_client(projects: [@repo]) stub_client(projects: [@repo])
get :status get :status
...@@ -46,7 +46,7 @@ describe Import::GitlabController do ...@@ -46,7 +46,7 @@ describe Import::GitlabController do
end end
it "does not show already added project" do it "does not show already added project" do
@project = create(:project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim') @project = create(:empty_project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim')
stub_client(projects: [@repo]) stub_client(projects: [@repo])
get :status get :status
......
...@@ -27,7 +27,7 @@ describe Import::GoogleCodeController do ...@@ -27,7 +27,7 @@ describe Import::GoogleCodeController do
end end
it "assigns variables" do it "assigns variables" do
@project = create(:project, import_type: 'google_code', creator_id: user.id) @project = create(:empty_project, import_type: 'google_code', creator_id: user.id)
stub_client(repos: [@repo], incompatible_repos: []) stub_client(repos: [@repo], incompatible_repos: [])
get :status get :status
...@@ -38,7 +38,7 @@ describe Import::GoogleCodeController do ...@@ -38,7 +38,7 @@ describe Import::GoogleCodeController do
end end
it "does not show already added project" do it "does not show already added project" do
@project = create(:project, import_type: 'google_code', creator_id: user.id, import_source: 'vim') @project = create(:empty_project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
stub_client(repos: [@repo], incompatible_repos: []) stub_client(repos: [@repo], incompatible_repos: [])
get :status get :status
......
...@@ -93,7 +93,7 @@ describe NotificationSettingsController do ...@@ -93,7 +93,7 @@ describe NotificationSettingsController do
end end
context 'not authorized' do context 'not authorized' do
let(:private_project) { create(:project, :private) } let(:private_project) { create(:empty_project, :private) }
before { sign_in(user) } before { sign_in(user) }
it 'returns 404' do it 'returns 404' do
......
require 'spec_helper' require 'spec_helper'
describe Projects::AvatarsController do describe Projects::AvatarsController do
let(:project) { create(:project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let(:project) { create(:empty_project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::BlameController do describe Projects::BlameController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'rails_helper' require 'rails_helper'
describe Projects::BlobController do describe Projects::BlobController do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::BranchesController do describe Projects::BranchesController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:developer) { create(:user) } let(:developer) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe Projects::CommitController do describe Projects::CommitController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:commit) { project.commit("master") } let(:commit) { project.commit("master") }
let(:pipeline) { create(:ci_pipeline, project: project, commit: commit) } let(:pipeline) { create(:ci_pipeline, project: project, commit: commit) }
......
require 'spec_helper' require 'spec_helper'
describe Projects::CommitsController do describe Projects::CommitsController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::CompareController do describe Projects::CompareController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:ref_from) { "improve%2Fawesome" } let(:ref_from) { "improve%2Fawesome" }
let(:ref_to) { "feature" } let(:ref_to) { "feature" }
......
require 'spec_helper' require 'spec_helper'
describe Projects::CycleAnalyticsController do describe Projects::CycleAnalyticsController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::DiscussionsController do describe Projects::DiscussionsController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:merge_request) { create(:merge_request) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:project) { merge_request.source_project }
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) } let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
let(:discussion) { note.discussion } let(:discussion) { note.discussion }
......
require 'spec_helper' require 'spec_helper'
describe Projects::FindFileController do describe Projects::FindFileController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::ForksController do describe Projects::ForksController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:forked_project) { Projects::ForkService.new(project, user).execute } let(:forked_project) { Projects::ForkService.new(project, user).execute }
let(:group) { create(:group, owner: forked_project.creator) } let(:group) { create(:group, owner: forked_project.creator) }
......
require 'spec_helper' require 'spec_helper'
describe Projects::GraphsController do describe Projects::GraphsController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::GroupLinksController do describe Projects::GroupLinksController do
let(:group) { create(:group, :private) } let(:group) { create(:group, :private) }
let(:group2) { create(:group, :private) } let(:group2) { create(:group, :private) }
let(:project) { create(:project, :private, group: group2) } let(:project) { create(:empty_project, :private, group: group2) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -98,7 +98,7 @@ describe Projects::IssuesController do ...@@ -98,7 +98,7 @@ describe Projects::IssuesController do
end end
it 'fills in an issue for a merge request' do it 'fills in an issue for a merge request' do
project_with_repository = create(:project) project_with_repository = create(:project, :repository)
project_with_repository.team << [user, :developer] project_with_repository.team << [user, :developer]
mr = create(:merge_request_with_diff_notes, source_project: project_with_repository) mr = create(:merge_request_with_diff_notes, source_project: project_with_repository)
...@@ -124,7 +124,7 @@ describe Projects::IssuesController do ...@@ -124,7 +124,7 @@ describe Projects::IssuesController do
describe 'PUT #update' do describe 'PUT #update' do
context 'when moving issue to another private project' do context 'when moving issue to another private project' do
let(:another_project) { create(:project, :private) } let(:another_project) { create(:empty_project, :private) }
before do before do
sign_in(user) sign_in(user)
...@@ -466,7 +466,7 @@ describe Projects::IssuesController do ...@@ -466,7 +466,7 @@ describe Projects::IssuesController do
context "when the user is owner" do context "when the user is owner" do
let(:owner) { create(:user) } let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) } let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:project, namespace: namespace) } let(:project) { create(:empty_project, namespace: namespace) }
before { sign_in(owner) } before { sign_in(owner) }
......
require 'spec_helper' require 'spec_helper'
describe Projects::MilestonesController do describe Projects::MilestonesController do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) } let(:milestone) { create(:milestone, project: project) }
let(:issue) { create(:issue, project: project, milestone: milestone) } let(:issue) { create(:issue, project: project, milestone: milestone) }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::NotesController do describe Projects::NotesController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:note) { create(:note, noteable: issue, project: project) } let(:note) { create(:note, noteable: issue, project: project) }
...@@ -16,6 +16,7 @@ describe Projects::NotesController do ...@@ -16,6 +16,7 @@ describe Projects::NotesController do
describe 'POST create' do describe 'POST create' do
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
let(:request_params) do let(:request_params) do
{ {
note: { note: 'some note', noteable_id: merge_request.id, noteable_type: 'MergeRequest' }, note: { note: 'some note', noteable_id: merge_request.id, noteable_type: 'MergeRequest' },
...@@ -88,6 +89,7 @@ describe Projects::NotesController do ...@@ -88,6 +89,7 @@ describe Projects::NotesController do
end end
describe "resolving and unresolving" do describe "resolving and unresolving" do
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) } let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
......
...@@ -143,7 +143,7 @@ describe Projects::ProjectMembersController do ...@@ -143,7 +143,7 @@ describe Projects::ProjectMembersController do
end end
context 'and is an owner' do context 'and is an owner' do
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:empty_project, namespace: user.namespace) }
before { project.team << [user, :master] } before { project.team << [user, :master] }
...@@ -234,7 +234,7 @@ describe Projects::ProjectMembersController do ...@@ -234,7 +234,7 @@ describe Projects::ProjectMembersController do
end end
describe 'POST apply_import' do describe 'POST apply_import' do
let(:another_project) { create(:project, :private) } let(:another_project) { create(:empty_project, :private) }
let(:member) { create(:user) } let(:member) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::RawController do describe Projects::RawController do
let(:public_project) { create(:project, :public) } let(:public_project) { create(:project, :public, :repository) }
describe "#show" do describe "#show" do
context 'regular filename' do context 'regular filename' do
......
require 'spec_helper' require 'spec_helper'
describe Projects::RefsController do describe Projects::RefsController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::ReleasesController do describe Projects::ReleasesController do
let!(:project) { create(:project) } let!(:project) { create(:project, :repository) }
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:release) { create(:release, project: project) } let!(:release) { create(:release, project: project) }
let!(:tag) { release.tag } let!(:tag) { release.tag }
......
require "spec_helper" require "spec_helper"
describe Projects::RepositoriesController do describe Projects::RepositoriesController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
describe "GET archive" do describe "GET archive" do
context 'as a guest' do context 'as a guest' do
......
require 'spec_helper' require 'spec_helper'
describe Projects::ServicesController do describe Projects::ServicesController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:service) { create(:service, project: project) } let(:service) { create(:service, project: project) }
......
require 'spec_helper' require 'spec_helper'
describe Projects::Settings::IntegrationsController do describe Projects::Settings::IntegrationsController do
let(:project) { create(:project, :public) } let(:project) { create(:empty_project, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::TagsController do describe Projects::TagsController do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let!(:release) { create(:release, project: project) } let!(:release) { create(:release, project: project) }
let!(:invalid_release) { create(:release, project: project, tag: 'does-not-exist') } let!(:invalid_release) { create(:release, project: project, tag: 'does-not-exist') }
......
require 'spec_helper' require 'spec_helper'
describe Projects::TemplatesController do describe Projects::TemplatesController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:file_path_1) { '.gitlab/issue_templates/bug.md' } let(:file_path_1) { '.gitlab/issue_templates/bug.md' }
......
require 'spec_helper' require 'spec_helper'
describe Projects::TreeController do describe Projects::TreeController do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require('spec_helper') require('spec_helper')
describe Projects::UploadsController do describe Projects::UploadsController do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
......
require('spec_helper') require('spec_helper')
describe ProjectsController do describe ProjectsController do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:public_project) { create(:project, :public) } let(:public_project) { create(:empty_project, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
describe 'GET index' do describe 'GET index' do
context 'as a user' do context 'as a user' do
...@@ -32,7 +32,7 @@ describe ProjectsController do ...@@ -32,7 +32,7 @@ describe ProjectsController do
before { sign_in(user) } before { sign_in(user) }
context "user does not have access to project" do context "user does not have access to project" do
let(:private_project) { create(:project, :private) } let(:private_project) { create(:empty_project, :private) }
it "does not initialize notification setting" do it "does not initialize notification setting" do
get :show, namespace_id: private_project.namespace.path, id: private_project.path get :show, namespace_id: private_project.namespace.path, id: private_project.path
...@@ -146,6 +146,8 @@ describe ProjectsController do ...@@ -146,6 +146,8 @@ describe ProjectsController do
end end
context "rendering default project view" do context "rendering default project view" do
let(:public_project) { create(:project, :public, :repository) }
render_views render_views
it "renders the activity view" do it "renders the activity view" do
...@@ -190,25 +192,11 @@ describe ProjectsController do ...@@ -190,25 +192,11 @@ describe ProjectsController do
expect(assigns(:project)).to eq(public_project) expect(assigns(:project)).to eq(public_project)
expect(response).to redirect_to("/#{public_project.path_with_namespace}") expect(response).to redirect_to("/#{public_project.path_with_namespace}")
end end
# MySQL queries are case insensitive by default, so this spec would fail.
if Gitlab::Database.postgresql?
context "when there is also a match with the same casing" do
let!(:other_project) { create(:project, :public, namespace: public_project.namespace, path: public_project.path.upcase) }
it "loads the exactly matched project" do
get :show, namespace_id: public_project.namespace.path, id: public_project.path.upcase
expect(assigns(:project)).to eq(other_project)
expect(response).to have_http_status(200)
end
end
end
end end
end end
context "when the url contains .atom" do context "when the url contains .atom" do
let(:public_project_with_dot_atom) { build(:project, :public, name: 'my.atom', path: 'my.atom') } let(:public_project_with_dot_atom) { build(:empty_project, :public, name: 'my.atom', path: 'my.atom') }
it 'expects an error creating the project' do it 'expects an error creating the project' do
expect(public_project_with_dot_atom).not_to be_valid expect(public_project_with_dot_atom).not_to be_valid
...@@ -217,7 +205,7 @@ describe ProjectsController do ...@@ -217,7 +205,7 @@ describe ProjectsController do
context 'when the project is pending deletions' do context 'when the project is pending deletions' do
it 'renders a 404 error' do it 'renders a 404 error' do
project = create(:project, pending_delete: true) project = create(:empty_project, pending_delete: true)
sign_in(user) sign_in(user)
get :show, namespace_id: project.namespace.path, id: project.path get :show, namespace_id: project.namespace.path, id: project.path
...@@ -233,6 +221,7 @@ describe ProjectsController do ...@@ -233,6 +221,7 @@ describe ProjectsController do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
it "sets the repository to the right path after a rename" do it "sets the repository to the right path after a rename" do
project = create(:project, :repository)
new_path = 'renamed_path' new_path = 'renamed_path'
project_params = { path: new_path } project_params = { path: new_path }
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
...@@ -384,6 +373,8 @@ describe ProjectsController do ...@@ -384,6 +373,8 @@ describe ProjectsController do
end end
describe "GET refs" do describe "GET refs" do
let(:public_project) { create(:project, :public) }
it "gets a list of branches and tags" do it "gets a list of branches and tags" do
get :refs, namespace_id: public_project.namespace.path, id: public_project.path get :refs, namespace_id: public_project.namespace.path, id: public_project.path
......
...@@ -41,7 +41,7 @@ describe UploadsController do ...@@ -41,7 +41,7 @@ describe UploadsController do
end end
context "when viewing a project avatar" do context "when viewing a project avatar" do
let!(:project) { create(:project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let!(:project) { create(:empty_project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
context "when the project is public" do context "when the project is public" do
before do before do
......
...@@ -73,7 +73,7 @@ describe UsersController do ...@@ -73,7 +73,7 @@ describe UsersController do
end end
context 'forked project' do context 'forked project' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:forked_project) { Projects::ForkService.new(project, user).execute } let(:forked_project) { Projects::ForkService.new(project, user).execute }
before do before do
...@@ -91,7 +91,7 @@ describe UsersController do ...@@ -91,7 +91,7 @@ describe UsersController do
end end
describe 'GET #calendar_activities' do describe 'GET #calendar_activities' do
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
let!(:user) { create(:user) } let!(:user) { create(:user) }
before do before do
......
FactoryGirl.define do FactoryGirl.define do
factory :deploy_keys_project do factory :deploy_keys_project do
deploy_key deploy_key
project project factory: :empty_project
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :event do factory :event do
project project factory: :empty_project
author factory: :user author factory: :user
factory :closed_issue_event do factory :closed_issue_event do
......
FactoryGirl.define do FactoryGirl.define do
factory :file_uploader do factory :file_uploader do
project project factory: :empty_project
secret nil secret nil
transient do transient do
......
...@@ -6,7 +6,7 @@ FactoryGirl.define do ...@@ -6,7 +6,7 @@ FactoryGirl.define do
factory :issue do factory :issue do
title title
author author
project project factory: :empty_project
trait :confidential do trait :confidential do
confidential true confidential true
......
...@@ -2,7 +2,7 @@ FactoryGirl.define do ...@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :label, class: ProjectLabel do factory :label, class: ProjectLabel do
sequence(:title) { |n| "label#{n}" } sequence(:title) { |n| "label#{n}" }
color "#990000" color "#990000"
project project factory: :empty_project
transient do transient do
priority nil priority nil
......
...@@ -2,7 +2,7 @@ FactoryGirl.define do ...@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :merge_request do factory :merge_request do
title title
author author
source_project factory: :project association :source_project, :repository, factory: :project
target_project { source_project } target_project { source_project }
# $ git log --pretty=oneline feature..master # $ git log --pretty=oneline feature..master
......
FactoryGirl.define do FactoryGirl.define do
factory :milestone do factory :milestone do
title title
project project factory: :empty_project
trait :active do trait :active do
state "active" state "active"
......
...@@ -4,7 +4,7 @@ include ActionDispatch::TestProcess ...@@ -4,7 +4,7 @@ include ActionDispatch::TestProcess
FactoryGirl.define do FactoryGirl.define do
factory :note do factory :note do
project project factory: :empty_project
note "Note" note "Note"
author author
on_issue on_issue
...@@ -16,10 +16,16 @@ FactoryGirl.define do ...@@ -16,10 +16,16 @@ FactoryGirl.define do
factory :note_on_personal_snippet, traits: [:on_personal_snippet] factory :note_on_personal_snippet, traits: [:on_personal_snippet]
factory :system_note, traits: [:system] factory :system_note, traits: [:system]
factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote do
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote association :project, :repository
end
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do
association :project, :repository
end
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do
association :project, :repository
position do position do
Gitlab::Diff::Position.new( Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb", old_path: "files/ruby/popen.rb",
...@@ -37,6 +43,7 @@ FactoryGirl.define do ...@@ -37,6 +43,7 @@ FactoryGirl.define do
end end
factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do
association :project, :repository
position do position do
Gitlab::Diff::Position.new( Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb", old_path: "files/ruby/popen.rb",
...@@ -49,6 +56,7 @@ FactoryGirl.define do ...@@ -49,6 +56,7 @@ FactoryGirl.define do
end end
trait :on_commit do trait :on_commit do
association :project, :repository
noteable nil noteable nil
noteable_type 'Commit' noteable_type 'Commit'
noteable_id nil noteable_id nil
......
FactoryGirl.define do FactoryGirl.define do
factory :project_group_link do factory :project_group_link do
project project factory: :empty_project
group group
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :project_member do factory :project_member do
user user
project project factory: :empty_project
master master
trait(:guest) { access_level ProjectMember::GUEST } trait(:guest) { access_level ProjectMember::GUEST }
......
FactoryGirl.define do FactoryGirl.define do
factory :project_snippet, parent: :snippet, class: :ProjectSnippet do factory :project_snippet, parent: :snippet, class: :ProjectSnippet do
project project factory: :empty_project
end end
end end
...@@ -2,6 +2,6 @@ FactoryGirl.define do ...@@ -2,6 +2,6 @@ FactoryGirl.define do
factory :release do factory :release do
tag "v1.1.0" tag "v1.1.0"
description "Awesome release" description "Awesome release"
project project factory: :empty_project
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :sent_notification do factory :sent_notification do
project project factory: :empty_project
recipient factory: :user recipient factory: :user
noteable factory: :issue noteable factory: :issue
reply_key "0123456789abcdef" * 2 reply_key "0123456789abcdef" * 2
......
FactoryGirl.define do FactoryGirl.define do
factory :service do factory :service do
project project factory: :empty_project
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :todo do factory :todo do
project project factory: :empty_project
author author
user user
target factory: :issue target factory: :issue
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe BranchesFinder do describe BranchesFinder do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
describe '#execute' do describe '#execute' do
......
...@@ -6,8 +6,8 @@ describe ContributedProjectsFinder do ...@@ -6,8 +6,8 @@ describe ContributedProjectsFinder do
let(:finder) { described_class.new(source_user) } let(:finder) { described_class.new(source_user) }
let!(:public_project) { create(:project, :public) } let!(:public_project) { create(:empty_project, :public) }
let!(:private_project) { create(:project, :private) } let!(:private_project) { create(:empty_project, :private) }
before do before do
private_project.team << [source_user, Gitlab::Access::MASTER] private_project.team << [source_user, Gitlab::Access::MASTER]
......
...@@ -6,11 +6,11 @@ describe GroupProjectsFinder do ...@@ -6,11 +6,11 @@ describe GroupProjectsFinder do
let(:finder) { described_class.new(source_user) } let(:finder) { described_class.new(source_user) }
let!(:public_project) { create(:project, :public, group: group, path: '1') } let!(:public_project) { create(:empty_project, :public, group: group, path: '1') }
let!(:private_project) { create(:project, :private, group: group, path: '2') } let!(:private_project) { create(:empty_project, :private, group: group, path: '2') }
let!(:shared_project_1) { create(:project, :public, path: '3') } let!(:shared_project_1) { create(:empty_project, :public, path: '3') }
let!(:shared_project_2) { create(:project, :private, path: '4') } let!(:shared_project_2) { create(:empty_project, :private, path: '4') }
let!(:shared_project_3) { create(:project, :internal, path: '5') } let!(:shared_project_3) { create(:empty_project, :internal, path: '5') }
before do before do
shared_project_1.project_group_links.create(group_access: Gitlab::Access::MASTER, group: group) shared_project_1.project_group_links.create(group_access: Gitlab::Access::MASTER, group: group)
......
...@@ -42,7 +42,7 @@ describe JoinedGroupsFinder do ...@@ -42,7 +42,7 @@ describe JoinedGroupsFinder do
context 'if profile visitor is in one of the private group projects' do context 'if profile visitor is in one of the private group projects' do
before do before do
project = create(:project, :private, group: private_group, name: 'B', path: 'B') project = create(:empty_project, :private, group: private_group, name: 'B', path: 'B')
project.add_user(profile_visitor, Gitlab::Access::DEVELOPER) project.add_user(profile_visitor, Gitlab::Access::DEVELOPER)
end end
......
...@@ -4,9 +4,9 @@ describe MergeRequestsFinder do ...@@ -4,9 +4,9 @@ describe MergeRequestsFinder do
let(:user) { create :user } let(:user) { create :user }
let(:user2) { create :user } let(:user2) { create :user }
let(:project1) { create(:project) } let(:project1) { create(:empty_project) }
let(:project2) { create(:project, forked_from_project: project1) } let(:project2) { create(:empty_project, forked_from_project: project1) }
let(:project3) { create(:project, :archived, forked_from_project: project1) } let(:project3) { create(:empty_project, :archived, forked_from_project: project1) }
let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) } let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) }
let!(:merge_request2) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1, state: 'closed') } let!(:merge_request2) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1, state: 'closed') }
......
...@@ -28,7 +28,7 @@ describe NotesFinder do ...@@ -28,7 +28,7 @@ describe NotesFinder do
end end
it "excludes notes on commits the author can't download" do it "excludes notes on commits the author can't download" do
project = create(:project, :private) project = create(:project, :private, :repository)
note = create(:note_on_commit, project: project) note = create(:note_on_commit, project: project)
params = { target_type: 'commit', target_id: note.noteable.id } params = { target_type: 'commit', target_id: note.noteable.id }
...@@ -76,7 +76,7 @@ describe NotesFinder do ...@@ -76,7 +76,7 @@ describe NotesFinder do
end end
context 'for target' do context 'for target' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:note1) { create :note_on_commit, project: project } let(:note1) { create :note_on_commit, project: project }
let(:note2) { create :note_on_commit, project: project } let(:note2) { create :note_on_commit, project: project }
let(:commit) { note1.noteable } let(:commit) { note1.noteable }
......
...@@ -4,14 +4,14 @@ describe PersonalProjectsFinder do ...@@ -4,14 +4,14 @@ describe PersonalProjectsFinder do
let(:source_user) { create(:user) } let(:source_user) { create(:user) }
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
let(:finder) { described_class.new(source_user) } let(:finder) { described_class.new(source_user) }
let!(:public_project) { create(:project, :public, namespace: source_user.namespace) } let!(:public_project) { create(:empty_project, :public, namespace: source_user.namespace) }
let!(:private_project) do let!(:private_project) do
create(:project, :private, namespace: source_user.namespace, path: 'mepmep') create(:empty_project, :private, namespace: source_user.namespace, path: 'mepmep')
end end
let!(:internal_project) do let!(:internal_project) do
create(:project, :internal, namespace: source_user.namespace, path: 'C') create(:empty_project, :internal, namespace: source_user.namespace, path: 'C')
end end
before do before do
......
require 'spec_helper' require 'spec_helper'
describe PipelinesFinder do describe PipelinesFinder do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let!(:tag_pipeline) { create(:ci_pipeline, project: project, ref: 'v1.0.0') } let!(:tag_pipeline) { create(:ci_pipeline, project: project, ref: 'v1.0.0') }
let!(:branch_pipeline) { create(:ci_pipeline, project: project) } let!(:branch_pipeline) { create(:ci_pipeline, project: project) }
......
...@@ -6,19 +6,19 @@ describe ProjectsFinder do ...@@ -6,19 +6,19 @@ describe ProjectsFinder do
let(:group) { create(:group, :public) } let(:group) { create(:group, :public) }
let!(:private_project) do let!(:private_project) do
create(:project, :private, name: 'A', path: 'A') create(:empty_project, :private, name: 'A', path: 'A')
end end
let!(:internal_project) do let!(:internal_project) do
create(:project, :internal, group: group, name: 'B', path: 'B') create(:empty_project, :internal, group: group, name: 'B', path: 'B')
end end
let!(:public_project) do let!(:public_project) do
create(:project, :public, group: group, name: 'C', path: 'C') create(:empty_project, :public, group: group, name: 'C', path: 'C')
end end
let!(:shared_project) do let!(:shared_project) do
create(:project, :private, name: 'D', path: 'D') create(:empty_project, :private, name: 'D', path: 'D')
end end
let(:finder) { described_class.new } let(:finder) { described_class.new }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe TagsFinder do describe TagsFinder do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
describe '#execute' do describe '#execute' do
......
...@@ -55,7 +55,7 @@ describe ApplicationHelper do ...@@ -55,7 +55,7 @@ describe ApplicationHelper do
describe 'project_icon' do describe 'project_icon' do
it 'returns an url for the avatar' do it 'returns an url for the avatar' do
project = create(:project, avatar: File.open(uploaded_image_temp_path)) project = create(:empty_project, avatar: File.open(uploaded_image_temp_path))
avatar_url = "http://#{Gitlab.config.gitlab.host}/uploads/project/avatar/#{project.id}/banana_sample.gif" avatar_url = "http://#{Gitlab.config.gitlab.host}/uploads/project/avatar/#{project.id}/banana_sample.gif"
expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s). expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s).
...@@ -63,7 +63,7 @@ describe ApplicationHelper do ...@@ -63,7 +63,7 @@ describe ApplicationHelper do
end end
it 'gives uploaded icon when present' do it 'gives uploaded icon when present' do
project = create(:project) project = create(:empty_project)
allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true) allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true)
......
...@@ -70,7 +70,7 @@ describe BlobHelper do ...@@ -70,7 +70,7 @@ describe BlobHelper do
describe "#edit_blob_link" do describe "#edit_blob_link" do
let(:namespace) { create(:namespace, name: 'gitlab' )} let(:namespace) { create(:namespace, name: 'gitlab' )}
let(:project) { create(:project, namespace: namespace) } let(:project) { create(:project, :repository, namespace: namespace) }
before do before do
allow(self).to receive(:current_user).and_return(double) allow(self).to receive(:current_user).and_return(double)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe GitlabMarkdownHelper do describe GitlabMarkdownHelper do
include ApplicationHelper include ApplicationHelper
let!(:project) { create(:project) } let!(:project) { create(:project, :repository) }
let(:user) { create(:user, username: 'gfm') } let(:user) { create(:user, username: 'gfm') }
let(:commit) { project.commit } let(:commit) { project.commit }
...@@ -55,18 +55,18 @@ describe GitlabMarkdownHelper do ...@@ -55,18 +55,18 @@ describe GitlabMarkdownHelper do
end end
describe '#link_to_gfm' do describe '#link_to_gfm' do
let(:commit_path) { namespace_project_commit_path(project.namespace, project, commit) } let(:link) { '/commits/0a1b2c3d' }
let(:issues) { create_list(:issue, 2, project: project) } let(:issues) { create_list(:issue, 2, project: project) }
it 'handles references nested in links with all the text' do it 'handles references nested in links with all the text' do
actual = helper.link_to_gfm("This should finally fix #{issues[0].to_reference} and #{issues[1].to_reference} for real", commit_path) actual = helper.link_to_gfm("This should finally fix #{issues[0].to_reference} and #{issues[1].to_reference} for real", link)
doc = Nokogiri::HTML.parse(actual) doc = Nokogiri::HTML.parse(actual)
# Make sure we didn't create invalid markup # Make sure we didn't create invalid markup
expect(doc.errors).to be_empty expect(doc.errors).to be_empty
# Leading commit link # Leading commit link
expect(doc.css('a')[0].attr('href')).to eq commit_path expect(doc.css('a')[0].attr('href')).to eq link
expect(doc.css('a')[0].text).to eq 'This should finally fix ' expect(doc.css('a')[0].text).to eq 'This should finally fix '
# First issue link # First issue link
...@@ -75,7 +75,7 @@ describe GitlabMarkdownHelper do ...@@ -75,7 +75,7 @@ describe GitlabMarkdownHelper do
expect(doc.css('a')[1].text).to eq issues[0].to_reference expect(doc.css('a')[1].text).to eq issues[0].to_reference
# Internal commit link # Internal commit link
expect(doc.css('a')[2].attr('href')).to eq commit_path expect(doc.css('a')[2].attr('href')).to eq link
expect(doc.css('a')[2].text).to eq ' and ' expect(doc.css('a')[2].text).to eq ' and '
# Second issue link # Second issue link
...@@ -84,12 +84,12 @@ describe GitlabMarkdownHelper do ...@@ -84,12 +84,12 @@ describe GitlabMarkdownHelper do
expect(doc.css('a')[3].text).to eq issues[1].to_reference expect(doc.css('a')[3].text).to eq issues[1].to_reference
# Trailing commit link # Trailing commit link
expect(doc.css('a')[4].attr('href')).to eq commit_path expect(doc.css('a')[4].attr('href')).to eq link
expect(doc.css('a')[4].text).to eq ' for real' expect(doc.css('a')[4].text).to eq ' for real'
end end
it 'forwards HTML options' do it 'forwards HTML options' do
actual = helper.link_to_gfm("Fixed in #{commit.id}", commit_path, class: 'foo') actual = helper.link_to_gfm("Fixed in #{commit.id}", link, class: 'foo')
doc = Nokogiri::HTML.parse(actual) doc = Nokogiri::HTML.parse(actual)
expect(doc.css('a')).to satisfy do |v| expect(doc.css('a')).to satisfy do |v|
...@@ -100,7 +100,7 @@ describe GitlabMarkdownHelper do ...@@ -100,7 +100,7 @@ describe GitlabMarkdownHelper do
it "escapes HTML passed in as the body" do it "escapes HTML passed in as the body" do
actual = "This is a <h1>test</h1> - see #{issues[0].to_reference}" actual = "This is a <h1>test</h1> - see #{issues[0].to_reference}"
expect(helper.link_to_gfm(actual, commit_path)). expect(helper.link_to_gfm(actual, link)).
to match('&lt;h1&gt;test&lt;/h1&gt;') to match('&lt;h1&gt;test&lt;/h1&gt;')
end end
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe GraphHelper do describe GraphHelper do
describe '#get_refs' do describe '#get_refs' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:commit) { project.commit("master") } let(:commit) { project.commit("master") }
let(:graph) { Network::Graph.new(project, 'master', commit, '') } let(:graph) { Network::Graph.new(project, 'master', commit, '') }
......
require "spec_helper" require "spec_helper"
describe IssuesHelper do describe IssuesHelper do
let(:project) { create :project } let(:project) { create(:empty_project) }
let(:issue) { create :issue, project: project } let(:issue) { create :issue, project: project }
let(:ext_project) { create :redmine_project } let(:ext_project) { create :redmine_project }
......
...@@ -46,7 +46,7 @@ describe MembersHelper do ...@@ -46,7 +46,7 @@ describe MembersHelper do
end end
describe '#leave_confirmation_message' do describe '#leave_confirmation_message' do
let(:project) { build_stubbed(:project) } let(:project) { build_stubbed(:empty_project) }
let(:group) { build_stubbed(:group) } let(:group) { build_stubbed(:group) }
let(:user) { build_stubbed(:user) } let(:user) { build_stubbed(:user) }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequestsHelper do describe MergeRequestsHelper do
describe 'ci_build_details_path' do describe 'ci_build_details_path' do
let(:project) { create :project } let(:project) { create(:empty_project) }
let(:merge_request) { MergeRequest.new } let(:merge_request) { MergeRequest.new }
let(:ci_service) { CiService.new } let(:ci_service) { CiService.new }
let(:last_commit) { Ci::Pipeline.new({}) } let(:last_commit) { Ci::Pipeline.new({}) }
...@@ -30,7 +30,7 @@ describe MergeRequestsHelper do ...@@ -30,7 +30,7 @@ describe MergeRequestsHelper do
it { is_expected.to eq('#1, #2, and #3') } it { is_expected.to eq('#1, #2, and #3') }
context 'for JIRA issues' do context 'for JIRA issues' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:issues) do let(:issues) do
[ [
ExternalIssue.new('JIRA-123', project), ExternalIssue.new('JIRA-123', project),
...@@ -52,8 +52,8 @@ describe MergeRequestsHelper do ...@@ -52,8 +52,8 @@ describe MergeRequestsHelper do
end end
describe 'within different projects' do describe 'within different projects' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:empty_project, forked_from_project: project) }
let(:merge_request) { create(:merge_request, source_project: fork_project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: fork_project, target_project: project) }
subject { format_mr_branch_names(merge_request) } subject { format_mr_branch_names(merge_request) }
let(:source_title) { "#{fork_project.path_with_namespace}:#{merge_request.source_branch}" } let(:source_title) { "#{fork_project.path_with_namespace}:#{merge_request.source_branch}" }
...@@ -64,8 +64,8 @@ describe MergeRequestsHelper do ...@@ -64,8 +64,8 @@ describe MergeRequestsHelper do
end end
describe 'mr_widget_refresh_url' do describe 'mr_widget_refresh_url' do
let(:project) { create(:empty_project) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
let(:project) { create(:project) }
it 'returns correct url for MR' do it 'returns correct url for MR' do
expected_url = "#{project.path_with_namespace}/merge_requests/#{merge_request.iid}/merge_widget_refresh" expected_url = "#{project.path_with_namespace}/merge_requests/#{merge_request.iid}/merge_widget_refresh"
......
...@@ -21,24 +21,22 @@ describe MilestonesHelper do ...@@ -21,24 +21,22 @@ describe MilestonesHelper do
end end
describe '#milestone_counts' do describe '#milestone_counts' do
let(:project) { FactoryGirl.create(:project) } let(:project) { create(:empty_project) }
let(:counts) { helper.milestone_counts(project.milestones) } let(:counts) { helper.milestone_counts(project.milestones) }
context 'when there are milestones' do context 'when there are milestones' do
let!(:milestone_1) { FactoryGirl.create(:active_milestone, project: project) }
let!(:milestone_2) { FactoryGirl.create(:active_milestone, project: project) }
let!(:milestone_3) { FactoryGirl.create(:closed_milestone, project: project) }
it 'returns the correct counts' do it 'returns the correct counts' do
create_list(:active_milestone, 2, project: project)
create(:closed_milestone, project: project)
expect(counts).to eq(opened: 2, closed: 1, all: 3) expect(counts).to eq(opened: 2, closed: 1, all: 3)
end end
end end
context 'when there are only milestones of one type' do context 'when there are only milestones of one type' do
let!(:milestone_1) { FactoryGirl.create(:active_milestone, project: project) }
let!(:milestone_2) { FactoryGirl.create(:active_milestone, project: project) }
it 'returns the correct counts' do it 'returns the correct counts' do
create_list(:active_milestone, 2, project: project)
expect(counts).to eq(opened: 2, closed: 0, all: 2) expect(counts).to eq(opened: 2, closed: 0, all: 2)
end end
end end
......
...@@ -110,7 +110,7 @@ describe PreferencesHelper do ...@@ -110,7 +110,7 @@ describe PreferencesHelper do
end end
context 'when repository is not empty' do context 'when repository is not empty' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
it 'returns readme if user has repository access' do it 'returns readme if user has repository access' do
allow(helper).to receive(:can?).with(nil, :download_code, project).and_return(true) allow(helper).to receive(:can?).with(nil, :download_code, project).and_return(true)
......
...@@ -10,7 +10,7 @@ describe ProjectsHelper do ...@@ -10,7 +10,7 @@ describe ProjectsHelper do
end end
describe "can_change_visibility_level?" do describe "can_change_visibility_level?" do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:project_member, :reporter, user: create(:user), project: project).user } let(:user) { create(:project_member, :reporter, user: create(:user), project: project).user }
let(:fork_project) { Projects::ForkService.new(project, user).execute } let(:fork_project) { Projects::ForkService.new(project, user).execute }
...@@ -97,7 +97,7 @@ describe ProjectsHelper do ...@@ -97,7 +97,7 @@ describe ProjectsHelper do
end end
describe '#license_short_name' do describe '#license_short_name' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
context 'when project.repository has a license_key' do context 'when project.repository has a license_key' do
it 'returns the nickname of the license if present' do it 'returns the nickname of the license if present' do
......
...@@ -42,7 +42,7 @@ describe SearchHelper do ...@@ -42,7 +42,7 @@ describe SearchHelper do
end end
it "includes the user's projects" do it "includes the user's projects" do
project = create(:project, namespace: create(:namespace, owner: user)) project = create(:empty_project, namespace: create(:namespace, owner: user))
expect(search_autocomplete_opts(project.name).size).to eq(1) expect(search_autocomplete_opts(project.name).size).to eq(1)
end end
...@@ -52,7 +52,9 @@ describe SearchHelper do ...@@ -52,7 +52,9 @@ describe SearchHelper do
end end
context "with a current project" do context "with a current project" do
before { @project = create(:project) } before do
@project = create(:project, :repository)
end
it "includes project-specific sections" do it "includes project-specific sections" do
expect(search_autocomplete_opts("Files").size).to eq(1) expect(search_autocomplete_opts("Files").size).to eq(1)
......
...@@ -116,7 +116,7 @@ describe SubmoduleHelper do ...@@ -116,7 +116,7 @@ describe SubmoduleHelper do
context 'submodules with relative links' do context 'submodules with relative links' do
let(:group) { create(:group, name: "Master Project", path: "master-project") } let(:group) { create(:group, name: "Master Project", path: "master-project") }
let(:project) { create(:project, group: group) } let(:project) { create(:empty_project, group: group) }
let(:commit_id) { sample_commit[:id] } let(:commit_id) { sample_commit[:id] }
before do before do
...@@ -145,7 +145,7 @@ describe SubmoduleHelper do ...@@ -145,7 +145,7 @@ describe SubmoduleHelper do
context 'personal project' do context 'personal project' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:empty_project, namespace: user.namespace) }
it 'one level down with personal project' do it 'one level down with personal project' do
result = relative_self_links('../test.git', commit_id) result = relative_self_links('../test.git', commit_id)
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe TreeHelper do describe TreeHelper do
describe 'flatten_tree' do describe 'flatten_tree' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
before do before do
@repository = project.repository @repository = project.repository
......
require 'spec_helper' require 'spec_helper'
describe VisibilityLevelHelper do describe VisibilityLevelHelper do
let(:project) { build(:project) } let(:project) { build(:empty_project) }
let(:group) { build(:group) } let(:group) { build(:group) }
let(:personal_snippet) { build(:personal_snippet) } let(:personal_snippet) { build(:personal_snippet) }
let(:project_snippet) { build(:project_snippet) } let(:project_snippet) { build(:project_snippet) }
...@@ -60,8 +60,8 @@ describe VisibilityLevelHelper do ...@@ -60,8 +60,8 @@ describe VisibilityLevelHelper do
describe "skip_level?" do describe "skip_level?" do
describe "forks" do describe "forks" do
let(:project) { create(:project, :internal) } let(:project) { create(:empty_project, :internal) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:empty_project, forked_from_project: project) }
it "skips levels" do it "skips levels" do
expect(skip_level?(fork_project, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy expect(skip_level?(fork_project, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy
...@@ -71,7 +71,7 @@ describe VisibilityLevelHelper do ...@@ -71,7 +71,7 @@ describe VisibilityLevelHelper do
end end
describe "non-forked project" do describe "non-forked project" do
let(:project) { create(:project, :internal) } let(:project) { create(:empty_project, :internal) }
it "skips levels" do it "skips levels" do
expect(skip_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey expect(skip_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do
include FilterSpecHelper include FilterSpecHelper
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:commit1) { project.commit("HEAD~2") } let(:commit1) { project.commit("HEAD~2") }
let(:commit2) { project.commit } let(:commit2) { project.commit }
...@@ -99,7 +99,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do ...@@ -99,7 +99,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do
end end
context 'cross-project / cross-namespace complete reference' do context 'cross-project / cross-namespace complete reference' do
let(:project2) { create(:project, :public) } let(:project2) { create(:project, :public, :repository) }
let(:reference) { "#{project2.path_with_namespace}@#{commit1.id}...#{commit2.id}" } let(:reference) { "#{project2.path_with_namespace}@#{commit1.id}...#{commit2.id}" }
it 'links to a valid reference' do it 'links to a valid reference' do
...@@ -133,8 +133,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do ...@@ -133,8 +133,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do
context 'cross-project / same-namespace complete reference' do context 'cross-project / same-namespace complete reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) } let(:project) { create(:project, :public, :repository, namespace: namespace) }
let(:project2) { create(:project, :public, path: "same-namespace", namespace: namespace) } let(:project2) { create(:project, :public, :repository, path: "same-namespace", namespace: namespace) }
let(:reference) { "#{project2.path}@#{commit1.id}...#{commit2.id}" } let(:reference) { "#{project2.path}@#{commit1.id}...#{commit2.id}" }
it 'links to a valid reference' do it 'links to a valid reference' do
...@@ -168,8 +168,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do ...@@ -168,8 +168,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do
context 'cross-project shorthand reference' do context 'cross-project shorthand reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) } let(:project) { create(:project, :public, :repository, namespace: namespace) }
let(:project2) { create(:project, :public, path: "same-namespace", namespace: namespace) } let(:project2) { create(:project, :public, :repository, path: "same-namespace", namespace: namespace) }
let(:reference) { "#{project2.path}@#{commit1.id}...#{commit2.id}" } let(:reference) { "#{project2.path}@#{commit1.id}...#{commit2.id}" }
it 'links to a valid reference' do it 'links to a valid reference' do
...@@ -203,7 +203,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do ...@@ -203,7 +203,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do
context 'cross-project URL reference' do context 'cross-project URL reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:range) { CommitRange.new("#{commit1.id}...master", project) } let(:range) { CommitRange.new("#{commit1.id}...master", project) }
let(:reference) { urls.namespace_project_compare_url(project2.namespace, project2, from: commit1.id, to: 'master') } let(:reference) { urls.namespace_project_compare_url(project2.namespace, project2, from: commit1.id, to: 'master') }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Banzai::Filter::CommitReferenceFilter, lib: true do describe Banzai::Filter::CommitReferenceFilter, lib: true do
include FilterSpecHelper include FilterSpecHelper
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit } let(:commit) { project.commit }
it 'requires project context' do it 'requires project context' do
...@@ -96,7 +96,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do ...@@ -96,7 +96,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do
context 'cross-project / cross-namespace complete reference' do context 'cross-project / cross-namespace complete reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" } let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" }
...@@ -122,7 +122,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do ...@@ -122,7 +122,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do
context 'cross-project / same-namespace complete reference' do context 'cross-project / same-namespace complete reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project) { create(:empty_project, namespace: namespace) } let(:project) { create(:empty_project, namespace: namespace) }
let(:project2) { create(:project, :public, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" } let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" }
...@@ -148,7 +148,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do ...@@ -148,7 +148,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do
context 'cross-project shorthand reference' do context 'cross-project shorthand reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project) { create(:empty_project, namespace: namespace) } let(:project) { create(:empty_project, namespace: namespace) }
let(:project2) { create(:project, :public, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" } let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" }
...@@ -173,7 +173,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do ...@@ -173,7 +173,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do
context 'cross-project URL reference' do context 'cross-project URL reference' do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { urls.namespace_project_commit_url(project2.namespace, project2, commit.id) } let(:reference) { urls.namespace_project_commit_url(project2.namespace, project2, commit.id) }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Banzai::Filter::GollumTagsFilter, lib: true do describe Banzai::Filter::GollumTagsFilter, lib: true do
include FilterSpecHelper include FilterSpecHelper
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { double } let(:user) { double }
let(:project_wiki) { ProjectWiki.new(project, user) } let(:project_wiki) { ProjectWiki.new(project, user) }
......
...@@ -188,7 +188,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do ...@@ -188,7 +188,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do
context 'cross-project URL reference' do context 'cross-project URL reference' do
let(:namespace) { create(:namespace, name: 'cross-reference') } let(:namespace) { create(:namespace, name: 'cross-reference') }
let(:project2) { create(:project, :public, namespace: namespace) } let(:project2) { create(:empty_project, :public, namespace: namespace) }
let(:merge) { create(:merge_request, source_project: project2, target_project: project2) } let(:merge) { create(:merge_request, source_project: project2, target_project: project2) }
let(:reference) { urls.namespace_project_merge_request_url(project2.namespace, project2, merge) + '/diffs#note_123' } let(:reference) { urls.namespace_project_merge_request_url(project2.namespace, project2, merge) + '/diffs#note_123' }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Banzai::Filter::MilestoneReferenceFilter, lib: true do describe Banzai::Filter::MilestoneReferenceFilter, lib: true do
include FilterSpecHelper include FilterSpecHelper
let(:project) { create(:project, :public) } let(:project) { create(:empty_project, :public) }
let(:milestone) { create(:milestone, project: project) } let(:milestone) { create(:milestone, project: project) }
let(:reference) { milestone.to_reference } let(:reference) { milestone.to_reference }
......
...@@ -25,7 +25,7 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do ...@@ -25,7 +25,7 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do
%(<a href="#{path}">#{path}</a>) %(<a href="#{path}">#{path}</a>)
end end
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:project_path) { project.path_with_namespace } let(:project_path) { project.path_with_namespace }
let(:ref) { 'markdown' } let(:ref) { 'markdown' }
let(:commit) { project.commit(ref) } let(:commit) { project.commit(ref) }
......
...@@ -29,7 +29,7 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do ...@@ -29,7 +29,7 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
%(<div><a href="#{path}">#{path}</a></div>) %(<div><a href="#{path}">#{path}</a></div>)
end end
let(:project) { create(:project) } let(:project) { create(:empty_project) }
shared_examples :preserve_unchanged do shared_examples :preserve_unchanged do
it 'does not modify any relative URL in anchor' do it 'does not modify any relative URL in anchor' do
......
...@@ -13,7 +13,7 @@ describe Banzai::Filter::VideoLinkFilter, lib: true do ...@@ -13,7 +13,7 @@ describe Banzai::Filter::VideoLinkFilter, lib: true do
%(<img src="#{path}" />) %(<img src="#{path}" />)
end end
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
context 'when the element src has a video extension' do context 'when the element src has a video extension' do
UploaderHelper::VIDEO_EXT.each do |ext| UploaderHelper::VIDEO_EXT.each do |ext|
......
...@@ -147,7 +147,7 @@ describe Banzai::ReferenceParser::UserParser, lib: true do ...@@ -147,7 +147,7 @@ describe Banzai::ReferenceParser::UserParser, lib: true do
describe '#nodes_user_can_reference' do describe '#nodes_user_can_reference' do
context 'when the link has a data-author attribute' do context 'when the link has a data-author attribute' do
it 'returns the nodes when the user is a member of the project' do it 'returns the nodes when the user is a member of the project' do
other_project = create(:project) other_project = create(:empty_project)
other_project.team << [user, :developer] other_project.team << [user, :developer]
link['data-project'] = other_project.id.to_s link['data-project'] = other_project.id.to_s
...@@ -164,7 +164,7 @@ describe Banzai::ReferenceParser::UserParser, lib: true do ...@@ -164,7 +164,7 @@ describe Banzai::ReferenceParser::UserParser, lib: true do
end end
it 'returns an empty Array when the user could not be found' do it 'returns an empty Array when the user could not be found' do
other_project = create(:project) other_project = create(:empty_project)
link['data-project'] = other_project.id.to_s link['data-project'] = other_project.id.to_s
link['data-author'] = '' link['data-author'] = ''
...@@ -173,7 +173,7 @@ describe Banzai::ReferenceParser::UserParser, lib: true do ...@@ -173,7 +173,7 @@ describe Banzai::ReferenceParser::UserParser, lib: true do
end end
it 'returns an empty Array when the user is not a team member' do it 'returns an empty Array when the user is not a team member' do
other_project = create(:project) other_project = create(:empty_project)
link['data-project'] = other_project.id.to_s link['data-project'] = other_project.id.to_s
link['data-author'] = user.id.to_s link['data-author'] = user.id.to_s
......
require 'spec_helper' require 'spec_helper'
describe ProjectUrlConstrainer, lib: true do describe ProjectUrlConstrainer, lib: true do
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
let!(:namespace) { project.namespace } let!(:namespace) { project.namespace }
describe '#matches?' do describe '#matches?' do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe EventFilter, lib: true do describe EventFilter, lib: true do
describe '#apply_filter' do describe '#apply_filter' do
let(:source_user) { create(:user) } let(:source_user) { create(:user) }
let!(:public_project) { create(:project, :public) } let!(:public_project) { create(:empty_project, :public) }
let!(:push_event) { create(:event, action: Event::PUSHED, project: public_project, target: public_project, author: source_user) } let!(:push_event) { create(:event, action: Event::PUSHED, project: public_project, target: public_project, author: source_user) }
let!(:merged_event) { create(:event, action: Event::MERGED, project: public_project, target: public_project, author: source_user) } let!(:merged_event) { create(:event, action: Event::MERGED, project: public_project, target: public_project, author: source_user) }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment