Commit 18c5983b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-empty_project-lib' into 'master'

Use `:empty_project` where possible throughout spec/lib

See merge request !8767
parents de08c73f 80a6d2fd
...@@ -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 }
...@@ -364,19 +364,19 @@ describe Gitlab::GitAccess, lib: true do ...@@ -364,19 +364,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
......
...@@ -4,7 +4,7 @@ describe Gitlab::Template::IssueTemplate do ...@@ -4,7 +4,7 @@ describe Gitlab::Template::IssueTemplate do
subject { described_class } subject { described_class }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:file_path_1) { '.gitlab/issue_templates/bug.md' } let(:file_path_1) { '.gitlab/issue_templates/bug.md' }
let(:file_path_2) { '.gitlab/issue_templates/template_test.md' } let(:file_path_2) { '.gitlab/issue_templates/template_test.md' }
let(:file_path_3) { '.gitlab/issue_templates/feature_proposal.md' } let(:file_path_3) { '.gitlab/issue_templates/feature_proposal.md' }
......
...@@ -4,7 +4,7 @@ describe Gitlab::Template::MergeRequestTemplate do ...@@ -4,7 +4,7 @@ describe Gitlab::Template::MergeRequestTemplate do
subject { described_class } subject { described_class }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:file_path_1) { '.gitlab/merge_request_templates/bug.md' } let(:file_path_1) { '.gitlab/merge_request_templates/bug.md' }
let(:file_path_2) { '.gitlab/merge_request_templates/template_test.md' } let(:file_path_2) { '.gitlab/merge_request_templates/template_test.md' }
let(:file_path_3) { '.gitlab/merge_request_templates/feature_proposal.md' } let(:file_path_3) { '.gitlab/merge_request_templates/feature_proposal.md' }
......
...@@ -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) }
......
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