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) }
......
...@@ -24,7 +24,7 @@ describe ExtractsPath, lib: true do ...@@ -24,7 +24,7 @@ describe ExtractsPath, lib: true do
let(:params) { { path: sample_commit[:line_code_path], ref: ref } } let(:params) { { path: sample_commit[:line_code_path], ref: ref } }
before do before do
@project = create(:project) @project = create(:project, :repository)
end end
it "log tree path has no escape sequences" do it "log tree path has no escape sequences" do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
require 'lib/gitlab/badge/shared/metadata' require 'lib/gitlab/badge/shared/metadata'
describe Gitlab::Badge::Build::Metadata do describe Gitlab::Badge::Build::Metadata do
let(:badge) { double(project: create(:project), ref: 'feature') } let(:badge) { double(project: create(:empty_project), ref: 'feature') }
let(:metadata) { described_class.new(badge) } let(:metadata) { described_class.new(badge) }
it_behaves_like 'badge metadata' it_behaves_like 'badge metadata'
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Badge::Build::Status do describe Gitlab::Badge::Build::Status do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:sha) { project.commit.sha } let(:sha) { project.commit.sha }
let(:branch) { 'master' } let(:branch) { 'master' }
let(:badge) { described_class.new(project, branch) } let(:badge) { described_class.new(project, branch) }
......
...@@ -3,7 +3,7 @@ require 'lib/gitlab/badge/shared/metadata' ...@@ -3,7 +3,7 @@ require 'lib/gitlab/badge/shared/metadata'
describe Gitlab::Badge::Coverage::Metadata do describe Gitlab::Badge::Coverage::Metadata do
let(:badge) do let(:badge) do
double(project: create(:project), ref: 'feature', job: 'test') double(project: create(:empty_project), ref: 'feature', job: 'test')
end end
let(:metadata) { described_class.new(badge) } let(:metadata) { described_class.new(badge) }
......
...@@ -52,7 +52,7 @@ describe Gitlab::BitbucketImport::Importer, lib: true do ...@@ -52,7 +52,7 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
let(:project) do let(:project) do
create( create(
:project, :empty_project,
import_source: project_identifier, import_source: project_identifier,
import_data: ProjectImportData.new(credentials: data) import_data: ProjectImportData.new(credentials: data)
) )
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Blame, lib: true do describe Gitlab::Blame, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:path) { 'files/ruby/popen.rb' } let(:path) { 'files/ruby/popen.rb' }
let(:commit) { project.commit('master') } let(:commit) { project.commit('master') }
let(:blob) { project.repository.blob_at(commit.id, path) } let(:blob) { project.repository.blob_at(commit.id, path) }
......
...@@ -11,7 +11,7 @@ describe Gitlab::ChatCommands::Command, service: true do ...@@ -11,7 +11,7 @@ describe Gitlab::ChatCommands::Command, service: true do
context 'when no command is available' do context 'when no command is available' do
let(:params) { { text: 'issue show 1' } } let(:params) { { text: 'issue show 1' } }
let(:project) { create(:project, has_external_issue_tracker: true) } let(:project) { create(:empty_project, has_external_issue_tracker: true) }
it 'displays 404 messages' do it 'displays 404 messages' do
expect(subject[:response_type]).to be(:ephemeral) expect(subject[:response_type]).to be(:ephemeral)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Checks::ChangeAccess, lib: true do describe Gitlab::Checks::ChangeAccess, lib: true do
describe '#exec' do describe '#exec' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user_access) { Gitlab::UserAccess.new(user, project: project) } let(:user_access) { Gitlab::UserAccess.new(user, project: project) }
let(:changes) do let(:changes) do
{ {
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Checks::ChangeAccess, lib: true do describe Gitlab::Checks::ChangeAccess, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
context "exit code checking" do context "exit code checking" do
it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::ClosingIssueExtractor, lib: true do describe Gitlab::ClosingIssueExtractor, lib: true do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:project2) { create(:project) } let(:project2) { create(:empty_project) }
let(:forked_project) { Projects::ForkService.new(project, project.creator).execute } let(:forked_project) { Projects::ForkService.new(project, project.creator).execute }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project2) } let(:issue2) { create(:issue, project: project2) }
let(:reference) { issue.to_reference } let(:reference) { issue.to_reference }
let(:cross_reference) { issue2.to_reference(project) } let(:cross_reference) { issue2.to_reference(project) }
let(:fork_cross_reference) { issue.to_reference(forked_project) } let(:fork_cross_reference) { issue.to_reference(forked_project) }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Conflict::File, lib: true do describe Gitlab::Conflict::File, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:rugged) { repository.rugged } let(:rugged) { repository.rugged }
let(:their_commit) { rugged.branches['conflict-start'].target } let(:their_commit) { rugged.branches['conflict-start'].target }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::CycleAnalytics::StageSummary, models: true do describe Gitlab::CycleAnalytics::StageSummary, models: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:from) { 1.day.ago } let(:from) { 1.day.ago }
let(:user) { create(:user, :admin) } let(:user) { create(:user, :admin) }
subject { described_class.new(project, from: Time.now, current_user: user).data } subject { described_class.new(project, from: Time.now, current_user: user).data }
...@@ -15,7 +15,7 @@ describe Gitlab::CycleAnalytics::StageSummary, models: true do ...@@ -15,7 +15,7 @@ describe Gitlab::CycleAnalytics::StageSummary, models: true do
end end
it "doesn't find issues from other projects" do it "doesn't find issues from other projects" do
Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project)) } Timecop.freeze(5.days.from_now) { create(:issue, project: create(:empty_project)) }
expect(subject.first[:value]).to eq(0) expect(subject.first[:value]).to eq(0)
end end
...@@ -30,7 +30,7 @@ describe Gitlab::CycleAnalytics::StageSummary, models: true do ...@@ -30,7 +30,7 @@ describe Gitlab::CycleAnalytics::StageSummary, models: true do
end end
it "doesn't find commits from other projects" do it "doesn't find commits from other projects" do
Timecop.freeze(5.days.from_now) { create_commit("Test message", create(:project), user, 'master') } Timecop.freeze(5.days.from_now) { create_commit("Test message", create(:project, :repository), user, 'master') }
expect(subject.second[:value]).to eq(0) expect(subject.second[:value]).to eq(0)
end end
...@@ -51,7 +51,9 @@ describe Gitlab::CycleAnalytics::StageSummary, models: true do ...@@ -51,7 +51,9 @@ describe Gitlab::CycleAnalytics::StageSummary, models: true do
end end
it "doesn't find commits from other projects" do it "doesn't find commits from other projects" do
Timecop.freeze(5.days.from_now) { create(:deployment, project: create(:project)) } Timecop.freeze(5.days.from_now) do
create(:deployment, project: create(:project, :repository))
end
expect(subject.third[:value]).to eq(0) expect(subject.third[:value]).to eq(0)
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::DataBuilder::Note, lib: true do describe Gitlab::DataBuilder::Note, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:data) { described_class.build(note, user) } let(:data) { described_class.build(note, user) }
let(:fixed_time) { Time.at(1425600000) } # Avoid time precision errors let(:fixed_time) { Time.at(1425600000) } # Avoid time precision errors
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::DataBuilder::Pipeline do describe Gitlab::DataBuilder::Pipeline do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, create(:ci_pipeline,
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::DataBuilder::Push, lib: true do describe Gitlab::DataBuilder::Push, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
describe '.build_sample' do describe '.build_sample' do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Diff::File, lib: true do describe Gitlab::Diff::File, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:commit) { project.commit(sample_commit.id) } let(:commit) { project.commit(sample_commit.id) }
let(:diff) { commit.raw_diffs.first } let(:diff) { commit.raw_diffs.first }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: project.repository) } let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: project.repository) }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Diff::Highlight, lib: true do describe Gitlab::Diff::Highlight, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:commit) { project.commit(sample_commit.id) } let(:commit) { project.commit(sample_commit.id) }
let(:diff) { commit.raw_diffs.first } let(:diff) { commit.raw_diffs.first }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: project.repository) } let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: project.repository) }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Diff::LineMapper, lib: true do describe Gitlab::Diff::LineMapper, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:commit) { project.commit(sample_commit.id) } let(:commit) { project.commit(sample_commit.id) }
let(:diffs) { commit.raw_diffs } let(:diffs) { commit.raw_diffs }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Diff::ParallelDiff, lib: true do describe Gitlab::Diff::ParallelDiff, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:commit) { project.commit(sample_commit.id) } let(:commit) { project.commit(sample_commit.id) }
let(:diffs) { commit.raw_diffs } let(:diffs) { commit.raw_diffs }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Diff::Position, lib: true do describe Gitlab::Diff::Position, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
describe "position for an added file" do describe "position for an added file" do
let(:commit) { project.commit("2ea1f3dec713d940208fb5ce4a38765ecb5d3f73") } let(:commit) { project.commit("2ea1f3dec713d940208fb5ce4a38765ecb5d3f73") }
......
...@@ -51,7 +51,7 @@ describe Gitlab::Diff::PositionTracer, lib: true do ...@@ -51,7 +51,7 @@ describe Gitlab::Diff::PositionTracer, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:current_user) { project.owner } let(:current_user) { project.owner }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:file_name) { "test-file" } let(:file_name) { "test-file" }
......
...@@ -13,7 +13,7 @@ describe Gitlab::Email::Handler::CreateIssueHandler, lib: true do ...@@ -13,7 +13,7 @@ describe Gitlab::Email::Handler::CreateIssueHandler, lib: true do
let(:email_raw) { fixture_file('emails/valid_new_issue.eml') } let(:email_raw) { fixture_file('emails/valid_new_issue.eml') }
let(:namespace) { create(:namespace, path: 'gitlabhq') } let(:namespace) { create(:namespace, path: 'gitlabhq') }
let!(:project) { create(:project, :public, namespace: namespace) } let!(:project) { create(:project, :public, :repository, namespace: namespace) }
let!(:user) do let!(:user) do
create( create(
:user, :user,
......
...@@ -11,7 +11,7 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -11,7 +11,7 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
end end
let(:email_raw) { fixture_file('emails/valid_reply.eml') } let(:email_raw) { fixture_file('emails/valid_reply.eml') }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:note) { create(:diff_note_on_merge_request, project: project) } let(:note) { create(:diff_note_on_merge_request, project: project) }
let(:noteable) { note.noteable } let(:noteable) { note.noteable }
......
...@@ -10,7 +10,7 @@ describe Gitlab::Email::Handler::UnsubscribeHandler, lib: true do ...@@ -10,7 +10,7 @@ describe Gitlab::Email::Handler::UnsubscribeHandler, lib: true do
end end
let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "#{mail_key}+unsubscribe") } let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "#{mail_key}+unsubscribe") }
let(:project) { create(:project, :public) } let(:project) { create(:empty_project, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:noteable) { create(:issue, project: project) } let(:noteable) { create(:issue, project: project) }
......
...@@ -4,7 +4,7 @@ describe Gitlab::Email::Message::RepositoryPush do ...@@ -4,7 +4,7 @@ describe Gitlab::Email::Message::RepositoryPush do
include RepoHelpers include RepoHelpers
let!(:group) { create(:group, name: 'my_group') } let!(:group) { create(:group, name: 'my_group') }
let!(:project) { create(:project, name: 'my_project', namespace: group) } let!(:project) { create(:project, :repository, name: 'my_project', namespace: group) }
let!(:author) { create(:author, name: 'Author') } let!(:author) { create(:author, name: 'Author') }
let(:message) do let(:message) do
......
...@@ -2,8 +2,8 @@ require 'spec_helper' ...@@ -2,8 +2,8 @@ require 'spec_helper'
describe Gitlab::Gfm::ReferenceRewriter do describe Gitlab::Gfm::ReferenceRewriter do
let(:text) { 'some text' } let(:text) { 'some text' }
let(:old_project) { create(:project, name: 'old') } let(:old_project) { create(:empty_project, name: 'old-project') }
let(:new_project) { create(:project, name: 'new') } let(:new_project) { create(:empty_project, name: 'new-project') }
let(:user) { create(:user) } let(:user) { create(:user) }
before { old_project.team << [user, :reporter] } before { old_project.team << [user, :reporter] }
......
...@@ -2,8 +2,8 @@ require 'spec_helper' ...@@ -2,8 +2,8 @@ require 'spec_helper'
describe Gitlab::Gfm::UploadsRewriter do describe Gitlab::Gfm::UploadsRewriter do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:old_project) { create(:project) } let(:old_project) { create(:empty_project) }
let(:new_project) { create(:project) } let(:new_project) { create(:empty_project) }
let(:rewriter) { described_class.new(text, old_project, user) } let(:rewriter) { described_class.new(text, old_project, user) }
context 'text contains links to uploads' do context 'text contains links to uploads' do
......
...@@ -3,7 +3,7 @@ require 'fileutils' ...@@ -3,7 +3,7 @@ require 'fileutils'
describe Gitlab::Git::Hook, lib: true do describe Gitlab::Git::Hook, lib: true do
describe "#trigger" do describe "#trigger" do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
def create_hook(name) def create_hook(name)
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Git::RevList, lib: true do describe Gitlab::Git::RevList, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
context "validations" do context "validations" do
described_class::ALLOWED_VARIABLES.each do |var| described_class::ALLOWED_VARIABLES.each do |var|
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::GitAccess, lib: true do describe Gitlab::GitAccess, lib: true do
let(:access) { Gitlab::GitAccess.new(actor, project, 'web', authentication_abilities: authentication_abilities) } let(:access) { Gitlab::GitAccess.new(actor, project, 'web', authentication_abilities: authentication_abilities) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:actor) { user } let(:actor) { user }
let(:authentication_abilities) do let(:authentication_abilities) do
...@@ -88,7 +88,7 @@ describe Gitlab::GitAccess, lib: true do ...@@ -88,7 +88,7 @@ describe Gitlab::GitAccess, lib: true do
end end
context 'when project is public' do context 'when project is public' do
let(:public_project) { create(:project, :public) } let(:public_project) { create(:project, :public, :repository) }
let(:guest_access) { Gitlab::GitAccess.new(nil, public_project, 'web', authentication_abilities: []) } let(:guest_access) { Gitlab::GitAccess.new(nil, public_project, 'web', authentication_abilities: []) }
subject { guest_access.check('git-upload-pack', '_any') } subject { guest_access.check('git-upload-pack', '_any') }
...@@ -124,19 +124,19 @@ describe Gitlab::GitAccess, lib: true do ...@@ -124,19 +124,19 @@ describe Gitlab::GitAccess, lib: true do
context 'when unauthorized' do context 'when unauthorized' do
context 'from public project' do context 'from public project' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
it { expect(subject).to be_allowed } it { expect(subject).to be_allowed }
end end
context 'from internal project' do context 'from internal project' do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal, :repository) }
it { expect(subject).not_to be_allowed } it { expect(subject).not_to be_allowed }
end end
context 'from private project' do context 'from private project' do
let(:project) { create(:project, :private) } let(:project) { create(:project, :private, :repository) }
it { expect(subject).not_to be_allowed } it { expect(subject).not_to be_allowed }
end end
...@@ -148,7 +148,7 @@ describe Gitlab::GitAccess, lib: true do ...@@ -148,7 +148,7 @@ describe Gitlab::GitAccess, lib: true do
let(:authentication_abilities) { build_authentication_abilities } let(:authentication_abilities) { build_authentication_abilities }
describe 'owner' do describe 'owner' do
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
context 'pull code' do context 'pull code' do
it { expect(subject).to be_allowed } it { expect(subject).to be_allowed }
...@@ -370,19 +370,19 @@ describe Gitlab::GitAccess, lib: true do ...@@ -370,19 +370,19 @@ describe Gitlab::GitAccess, lib: true do
context 'when unauthorized' do context 'when unauthorized' do
context 'to public project' do context 'to public project' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
it { expect(subject).not_to be_allowed } it { expect(subject).not_to be_allowed }
end end
context 'to internal project' do context 'to internal project' do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal, :repository) }
it { expect(subject).not_to be_allowed } it { expect(subject).not_to be_allowed }
end end
context 'to private project' do context 'to private project' do
let(:project) { create(:project) } let(:project) { create(:project, :private, :repository) }
it { expect(subject).not_to be_allowed } it { expect(subject).not_to be_allowed }
end end
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::GitAccessWiki, lib: true do describe Gitlab::GitAccessWiki, lib: true do
let(:access) { Gitlab::GitAccessWiki.new(user, project, 'web', authentication_abilities: authentication_abilities) } let(:access) { Gitlab::GitAccessWiki.new(user, project, 'web', authentication_abilities: authentication_abilities) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:authentication_abilities) do let(:authentication_abilities) do
[ [
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GithubImport::BranchFormatter, lib: true do describe Gitlab::GithubImport::BranchFormatter, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:commit) { create(:commit, project: project) } let(:commit) { create(:commit, project: project) }
let(:repo) { double } let(:repo) { double }
let(:raw) do let(:raw) do
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GithubImport::CommentFormatter, lib: true do describe Gitlab::GithubImport::CommentFormatter, lib: true do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:octocat) { double(id: 123456, login: 'octocat') } let(:octocat) { double(id: 123456, login: 'octocat') }
let(:created_at) { DateTime.strptime('2013-04-10T20:09:31Z') } let(:created_at) { DateTime.strptime('2013-04-10T20:09:31Z') }
let(:updated_at) { DateTime.strptime('2014-03-03T18:58:10Z') } let(:updated_at) { DateTime.strptime('2014-03-03T18:58:10Z') }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GithubImport::IssueFormatter, lib: true do describe Gitlab::GithubImport::IssueFormatter, lib: true do
let!(:project) { create(:project, namespace: create(:namespace, path: 'octocat')) } let!(:project) { create(:empty_project, namespace: create(:namespace, path: 'octocat')) }
let(:octocat) { double(id: 123456, login: 'octocat') } let(:octocat) { double(id: 123456, login: 'octocat') }
let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') } let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') } let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GithubImport::LabelFormatter, lib: true do describe Gitlab::GithubImport::LabelFormatter, lib: true do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:raw) { double(name: 'improvements', color: 'e6e6e6') } let(:raw) { double(name: 'improvements', color: 'e6e6e6') }
subject { described_class.new(project, raw) } subject { described_class.new(project, raw) }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GithubImport::PullRequestFormatter, lib: true do describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:source_sha) { create(:commit, project: project).id } let(:source_sha) { create(:commit, project: project).id }
let(:target_sha) { create(:commit, project: project, git_commit: RepoHelpers.another_sample_commit).id } let(:target_sha) { create(:commit, project: project, git_commit: RepoHelpers.another_sample_commit).id }
let(:repository) { double(id: 1, fork: false) } let(:repository) { double(id: 1, fork: false) }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GithubImport::ReleaseFormatter, lib: true do describe Gitlab::GithubImport::ReleaseFormatter, lib: true do
let!(:project) { create(:project, namespace: create(:namespace, path: 'octocat')) } let!(:project) { create(:empty_project, namespace: create(:namespace, path: 'octocat')) }
let(:octocat) { double(id: 123456, login: 'octocat') } let(:octocat) { double(id: 123456, login: 'octocat') }
let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') } let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
......
...@@ -10,7 +10,7 @@ describe Gitlab::GoogleCodeImport::Importer, lib: true do ...@@ -10,7 +10,7 @@ describe Gitlab::GoogleCodeImport::Importer, lib: true do
'user_map' => { 'thilo...' => "@#{mapped_user.username}" } 'user_map' => { 'thilo...' => "@#{mapped_user.username}" }
} }
end end
let(:project) { create(:project) } let(:project) { create(:empty_project) }
subject { described_class.new(project) } subject { described_class.new(project) }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Graphs::Commits, lib: true do describe Gitlab::Graphs::Commits, lib: true do
let!(:project) { create(:project, :public, :empty_repo) } let!(:project) { create(:empty_project, :public) }
let!(:commit1) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: Time.now) } let!(:commit1) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: Time.now) }
let!(:commit1_yesterday) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: 1.day.ago)} let!(:commit1_yesterday) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: 1.day.ago)}
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Highlight, lib: true do describe Gitlab::Highlight, lib: true do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:commit) { project.commit(sample_commit.id) } let(:commit) { project.commit(sample_commit.id) }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::ImportExport, services: true do describe Gitlab::ImportExport, services: true do
describe 'export filename' do describe 'export filename' do
let(:project) { create(:project, :public, path: 'project-path') } let(:project) { create(:empty_project, :public, path: 'project-path') }
it 'contains the project path' do it 'contains the project path' do
expect(described_class.export_filename(project: project)).to include(project.path) expect(described_class.export_filename(project: project)).to include(project.path)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::MembersMapper, services: true do describe Gitlab::ImportExport::MembersMapper, services: true do
describe 'map members' do describe 'map members' do
let(:user) { create(:admin, authorized_projects_populated: true) } let(:user) { create(:admin, authorized_projects_populated: true) }
let(:project) { create(:project, :public, name: 'searchable_project') } let(:project) { create(:empty_project, :public, name: 'searchable_project') }
let(:user2) { create(:user, authorized_projects_populated: true) } let(:user2) { create(:user, authorized_projects_populated: true) }
let(:exported_user_id) { 99 } let(:exported_user_id) { 99 }
let(:exported_members) do let(:exported_members) do
......
...@@ -151,6 +151,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -151,6 +151,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
project = create(:project, project = create(:project,
:public, :public,
:repository,
issues: [issue], issues: [issue],
snippets: [snippet], snippets: [snippet],
releases: [release], releases: [release],
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::RepoSaver, services: true do describe Gitlab::ImportExport::RepoSaver, services: true do
describe 'bundle a project Git repo' do describe 'bundle a project Git repo' do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project, :public, name: 'searchable_project') } let!(:project) { create(:empty_project, :public, name: 'searchable_project') }
let(:export_path) { "#{Dir::tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir::tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) }
let(:bundler) { described_class.new(project: project, shared: shared) } let(:bundler) { described_class.new(project: project, shared: shared) }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::WikiRepoSaver, services: true do describe Gitlab::ImportExport::WikiRepoSaver, services: true do
describe 'bundle a wiki Git repo' do describe 'bundle a wiki Git repo' do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project, :public, name: 'searchable_project') } let!(:project) { create(:empty_project, :public, name: 'searchable_project') }
let(:export_path) { "#{Dir::tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir::tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) }
let(:wiki_bundler) { described_class.new(project: project, shared: shared) } let(:wiki_bundler) { described_class.new(project: project, shared: shared) }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::ProjectSearchResults, lib: true do describe Gitlab::ProjectSearchResults, lib: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:query) { 'hello world' } let(:query) { 'hello world' }
describe 'initialize with empty ref' do describe 'initialize with empty ref' do
...@@ -22,6 +22,7 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -22,6 +22,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
end end
describe 'blob search' do describe 'blob search' do
let(:project) { create(:project, :repository) }
let(:results) { described_class.new(user, project, 'files').objects('blobs') } let(:results) { described_class.new(user, project, 'files').objects('blobs') }
it 'finds by name' do it 'finds by name' do
...@@ -74,6 +75,7 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -74,6 +75,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
end end
describe 'confidential issues' do describe 'confidential issues' do
let(:project) { create(:empty_project) }
let(:query) { 'issue' } let(:query) { 'issue' }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:assignee) { create(:user) } let(:assignee) { create(:user) }
...@@ -187,7 +189,7 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -187,7 +189,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
# #
shared_examples 'access restricted commits' do shared_examples 'access restricted commits' do
context 'when project is internal' do context 'when project is internal' do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal, :repository) }
it 'does not search if user is not authenticated' do it 'does not search if user is not authenticated' do
commits = described_class.new(nil, project, search_phrase).objects('commits') commits = described_class.new(nil, project, search_phrase).objects('commits')
...@@ -204,7 +206,7 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -204,7 +206,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
context 'when project is private' do context 'when project is private' do
let!(:creator) { create(:user, username: 'private-project-author') } let!(:creator) { create(:user, username: 'private-project-author') }
let!(:private_project) { create(:project, :private, creator: creator, namespace: creator.namespace) } let!(:private_project) { create(:project, :private, :repository, creator: creator, namespace: creator.namespace) }
let(:team_master) do let(:team_master) do
user = create(:user, username: 'private-project-master') user = create(:user, username: 'private-project-master')
private_project.team << [user, :master] private_project.team << [user, :master]
...@@ -246,7 +248,7 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -246,7 +248,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
describe 'commit search' do describe 'commit search' do
context 'by commit message' do context 'by commit message' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:commit) { project.repository.commit('59e29889be61e6e0e5e223bfa9ac2721d31605b8') } let(:commit) { project.repository.commit('59e29889be61e6e0e5e223bfa9ac2721d31605b8') }
let(:message) { 'Sorry, I did a mistake' } let(:message) { 'Sorry, I did a mistake' }
...@@ -269,7 +271,7 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -269,7 +271,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
end end
context 'by commit hash' do context 'by commit hash' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:commit) { project.repository.commit('0b4bc9a') } let(:commit) { project.repository.commit('0b4bc9a') }
commit_hashes = { short: '0b4bc9a', full: '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } commit_hashes = { short: '0b4bc9a', full: '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::ReferenceExtractor, lib: true do describe Gitlab::ReferenceExtractor, lib: true do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
before { project.team << [project.creator, :developer] } before do
project.team << [project.creator, :developer]
end
subject { Gitlab::ReferenceExtractor.new(project, project.creator) } subject { Gitlab::ReferenceExtractor.new(project, project.creator) }
...@@ -78,22 +80,27 @@ describe Gitlab::ReferenceExtractor, lib: true do ...@@ -78,22 +80,27 @@ describe Gitlab::ReferenceExtractor, lib: true do
end end
it 'accesses valid commits' do it 'accesses valid commits' do
project = create(:project, :repository) { |p| p.add_developer(p.creator) }
commit = project.commit('master') commit = project.commit('master')
subject.analyze("this references commits #{commit.sha[0..6]} and 012345") extractor = described_class.new(project, project.creator)
extracted = subject.commits extractor.analyze("this references commits #{commit.sha[0..6]} and 012345")
extracted = extractor.commits
expect(extracted.size).to eq(1) expect(extracted.size).to eq(1)
expect(extracted[0].sha).to eq(commit.sha) expect(extracted[0].sha).to eq(commit.sha)
expect(extracted[0].message).to eq(commit.message) expect(extracted[0].message).to eq(commit.message)
end end
it 'accesses valid commit ranges' do it 'accesses valid commit ranges' do
project = create(:project, :repository) { |p| p.add_developer(p.creator) }
commit = project.commit('master') commit = project.commit('master')
earlier_commit = project.commit('master~2') earlier_commit = project.commit('master~2')
subject.analyze("this references commits #{earlier_commit.sha[0..6]}...#{commit.sha[0..6]}") extractor = described_class.new(project, project.creator)
extractor.analyze("this references commits #{earlier_commit.sha[0..6]}...#{commit.sha[0..6]}")
extracted = extractor.commit_ranges
extracted = subject.commit_ranges
expect(extracted.size).to eq(1) expect(extracted.size).to eq(1)
expect(extracted.first).to be_kind_of(CommitRange) expect(extracted.first).to be_kind_of(CommitRange)
expect(extracted.first.commit_from).to eq earlier_commit expect(extracted.first.commit_from).to eq earlier_commit
...@@ -102,7 +109,6 @@ describe Gitlab::ReferenceExtractor, lib: true do ...@@ -102,7 +109,6 @@ describe Gitlab::ReferenceExtractor, lib: true do
context 'with an external issue tracker' do context 'with an external issue tracker' do
let(:project) { create(:jira_project) } let(:project) { create(:jira_project) }
subject { described_class.new(project, project.creator) }
it 'returns JIRA issues for a JIRA-integrated project' do it 'returns JIRA issues for a JIRA-integrated project' do
subject.analyze('JIRA-123 and FOOBAR-4567') subject.analyze('JIRA-123 and FOOBAR-4567')
...@@ -112,7 +118,7 @@ describe Gitlab::ReferenceExtractor, lib: true do ...@@ -112,7 +118,7 @@ describe Gitlab::ReferenceExtractor, lib: true do
end end
context 'with a project with an underscore' do context 'with a project with an underscore' do
let(:other_project) { create(:project, path: 'test_project') } let(:other_project) { create(:empty_project, path: 'test_project') }
let(:issue) { create(:issue, project: other_project) } let(:issue) { create(:issue, project: other_project) }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::SearchResults do describe Gitlab::SearchResults do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project, name: 'foo') } let!(:project) { create(:empty_project, name: 'foo') }
let!(:issue) { create(:issue, project: project, title: 'foo') } let!(:issue) { create(:issue, project: project, title: 'foo') }
let!(:merge_request) do let!(:merge_request) do
......
...@@ -7,6 +7,7 @@ describe Gitlab::Template::IssueTemplate do ...@@ -7,6 +7,7 @@ describe Gitlab::Template::IssueTemplate do
let(:project) do let(:project) do
create(:project, create(:project,
:repository,
create_template: { create_template: {
user: user, user: user,
access: Gitlab::Access::MASTER, access: Gitlab::Access::MASTER,
......
...@@ -7,6 +7,7 @@ describe Gitlab::Template::MergeRequestTemplate do ...@@ -7,6 +7,7 @@ describe Gitlab::Template::MergeRequestTemplate do
let(:project) do let(:project) do
create(:project, create(:project,
:repository,
create_template: { create_template: {
user: user, user: user,
access: Gitlab::Access::MASTER, access: Gitlab::Access::MASTER,
......
...@@ -99,7 +99,7 @@ describe Gitlab::UrlBuilder, lib: true do ...@@ -99,7 +99,7 @@ describe Gitlab::UrlBuilder, lib: true do
context 'on another object' do context 'on another object' do
it 'returns a proper URL' do it 'returns a proper URL' do
project = build_stubbed(:project) project = build_stubbed(:empty_project)
expect { described_class.build(project) }. expect { described_class.build(project) }.
to raise_error(NotImplementedError, 'No URL builder defined for Project') to raise_error(NotImplementedError, 'No URL builder defined for Project')
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Workhorse, lib: true do describe Gitlab::Workhorse, lib: true do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
def decode_workhorse_header(array) def decode_workhorse_header(array)
......
...@@ -99,7 +99,7 @@ describe Gitlab::UrlBuilder, lib: true do ...@@ -99,7 +99,7 @@ describe Gitlab::UrlBuilder, lib: true do
context 'on another object' do context 'on another object' do
it 'returns a proper URL' do it 'returns a proper URL' do
project = build_stubbed(:project) project = build_stubbed(:empty_project)
expect { described_class.build(project) }. expect { described_class.build(project) }.
to raise_error(NotImplementedError, 'No URL builder defined for Project') to raise_error(NotImplementedError, 'No URL builder defined for Project')
......
require 'spec_helper' require 'spec_helper'
describe RepositoryCache, lib: true do describe RepositoryCache, lib: true do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:backend) { double('backend').as_null_object } let(:backend) { double('backend').as_null_object }
let(:cache) { RepositoryCache.new('example', project.id, backend) } let(:cache) { RepositoryCache.new('example', project.id, backend) }
......
...@@ -217,7 +217,7 @@ describe Issue, models: true do ...@@ -217,7 +217,7 @@ describe Issue, models: true do
end end
it_behaves_like 'an editable mentionable' do it_behaves_like 'an editable mentionable' do
subject { create(:issue) } subject { create(:issue, project: create(:project, :repository)) }
let(:backref_text) { "issue #{subject.to_reference}" } let(:backref_text) { "issue #{subject.to_reference}" }
let(:set_mentionable_text) { ->(txt){ subject.description = txt } } let(:set_mentionable_text) { ->(txt){ subject.description = txt } }
......
...@@ -138,7 +138,7 @@ describe Note, models: true do ...@@ -138,7 +138,7 @@ describe Note, models: true do
it_behaves_like 'an editable mentionable' do it_behaves_like 'an editable mentionable' do
subject { create :note, noteable: issue, project: issue.project } subject { create :note, noteable: issue, project: issue.project }
let(:issue) { create :issue } let(:issue) { create(:issue, project: create(:project, :repository)) }
let(:backref_text) { issue.gfm_reference } let(:backref_text) { issue.gfm_reference }
let(:set_mentionable_text) { ->(txt) { subject.note = txt } } let(:set_mentionable_text) { ->(txt) { subject.note = txt } }
end end
......
...@@ -72,6 +72,25 @@ shared_examples 'a Taskable' do ...@@ -72,6 +72,25 @@ shared_examples 'a Taskable' do
end end
end end
describe 'with tasks that are not formatted correctly' do
before do
subject.description = <<-EOT.strip_heredoc
[ ] task 1
[ ] task 2
- [ ]task 1
-[ ] task 2
EOT
end
it 'returns the correct task status' do
expect(subject.task_status).to match('0 of')
expect(subject.task_status).to match('0 tasks completed')
expect(subject.task_status_short).to match('0/')
expect(subject.task_status_short).to match('0 task')
end
end
describe 'with a complete task' do describe 'with a complete task' do
before do before do
subject.description = <<-EOT.strip_heredoc subject.description = <<-EOT.strip_heredoc
......
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