Commit 03538558 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-empty-project-misc' into 'master'

Use `:empty_project` in worker, view, task, serializer, policy, migration, and mailer specs

See merge request !10272
parents 5b84708d 68e67189
......@@ -184,6 +184,7 @@ describe Notify do
end
context 'for merge requests' do
let(:project) { create(:project, :repository) }
let(:merge_author) { create(:user) }
let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) }
let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: FFaker::Lorem.sentence) }
......@@ -334,7 +335,7 @@ describe Notify do
end
describe 'project was moved' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
subject { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
......@@ -460,7 +461,7 @@ describe Notify do
end
describe 'project invitation' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
let(:project_member) { invite_to_project(project, inviter: master) }
......@@ -480,7 +481,7 @@ describe Notify do
end
describe 'project invitation accepted' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:invited_user) { create(:user, name: 'invited user') }
let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
let(:project_member) do
......@@ -505,7 +506,7 @@ describe Notify do
end
describe 'project invitation declined' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
let(:project_member) do
invitee = invite_to_project(project, inviter: master)
......@@ -569,6 +570,7 @@ describe Notify do
end
describe 'on a commit' do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
before(:each) { allow(note).to receive(:noteable).and_return(commit) }
......@@ -636,6 +638,7 @@ describe Notify do
end
context 'items that are noteable, emails for a note on a diff' do
let(:project) { create(:project, :repository) }
let(:note_author) { create(:user, name: 'author_name') }
before :each do
......@@ -977,6 +980,7 @@ describe Notify do
end
describe 'email on push with multiple commits' do
let(:project) { create(:project, :repository) }
let(:example_site_path) { root_path }
let(:user) { create(:user) }
let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) }
......@@ -1070,6 +1074,7 @@ describe Notify do
end
describe 'email on push with a single commit' do
let(:project) { create(:project, :repository) }
let(:example_site_path) { root_path }
let(:user) { create(:user) }
let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_commit.parent_id, sample_commit.id) }
......@@ -1102,7 +1107,7 @@ describe Notify do
end
describe 'HTML emails setting' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
let(:multipart_mail) { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb')
describe MigrateProcessCommitWorkerJobs do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:commit) { project.commit.raw.raw_commit }
......
......@@ -5,7 +5,7 @@ describe IssuePolicy, models: true do
describe '#rules' do
context 'using a regular issue' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:issue) { create(:issue, project: project) }
let(:policies) { described_class.abilities(user, issue).to_set }
......
......@@ -74,7 +74,7 @@ describe ProjectPolicy, models: true do
end
it 'does not include the read_issue permission when the issue author is not a member of the private project' do
project = create(:project, :private)
project = create(:empty_project, :private)
issue = create(:issue, project: project)
user = issue.author
......
......@@ -8,7 +8,7 @@ describe AnalyticsIssueSerializer do
end
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:resource) do
{
total_time: "172802.724419",
......
......@@ -8,7 +8,7 @@ describe AnalyticsMergeRequestSerializer do
end
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:resource) do
{
total_time: "172802.724419",
......
......@@ -6,7 +6,7 @@ describe CommitEntity do
end
let(:request) { double('request') }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
subject { entity.as_json }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe EnvironmentSerializer do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:json) do
described_class
......@@ -11,21 +11,20 @@ describe EnvironmentSerializer do
end
context 'when there is a single object provided' do
before do
create(:ci_build, :manual, name: 'manual1',
pipeline: deployable.pipeline)
end
let(:project) { create(:project, :repository) }
let(:deployable) { create(:ci_build) }
let(:deployment) do
create(:deployment, deployable: deployable,
user: user,
project: project,
sha: project.commit.id)
end
let(:deployable) { create(:ci_build) }
let(:resource) { deployment.environment }
before do
create(:ci_build, :manual, name: 'manual1', pipeline: deployable.pipeline)
end
it 'contains important elements of environment' do
expect(json)
.to include(:name, :external_url, :environment_path, :last_deployment)
......
......@@ -3,7 +3,7 @@ shared_context 'gitlab email notification' do
let(:gitlab_sender) { Gitlab.config.gitlab.email_from }
let(:gitlab_sender_reply_to) { Gitlab.config.gitlab.email_reply_to }
let(:recipient) { create(:user, email: 'recipient@example.com') }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:new_user_address) { 'newguy@example.com' }
before do
......
......@@ -116,7 +116,7 @@ describe 'gitlab:app namespace rake task' do
end
describe 'backup creation and deletion using custom_hooks' do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user_backup_path) { "repositories/#{project.path_with_namespace}" }
before(:each) do
......@@ -224,8 +224,8 @@ describe 'gitlab:app namespace rake task' do
end
context 'multiple repository storages' do
let(:project_a) { create(:project, repository_storage: 'default') }
let(:project_b) { create(:project, repository_storage: 'custom') }
let(:project_a) { create(:project, :repository, repository_storage: 'default') }
let(:project_b) { create(:project, :repository, repository_storage: 'custom') }
before do
FileUtils.mkdir('tmp/tests/default_storage')
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/ci/builds/_build' do
include Devise::Test::ControllerHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', stage_idx: 1, name: 'rspec 0:2', status: :pending) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/generic_commit_statuses/_generic_commit_status.html.haml' do
include Devise::Test::ControllerHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
let(:generic_commit_status) { create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) }
......
require 'spec_helper'
describe 'projects/builds/show', :view do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) do
......
......@@ -4,7 +4,7 @@ describe 'projects/commit/_commit_box.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
before do
assign(:project, project)
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/issues/_related_branches' do
include Devise::Test::ControllerHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:branch) { project.repository.find_branch('feature') }
let!(:pipeline) { create(:ci_pipeline, project: project, sha: branch.dereferenced_target.id, ref: 'feature') }
......
......@@ -4,11 +4,8 @@ describe 'projects/merge_requests/show/_commits.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:target_project) { create(:project) }
let(:source_project) do
create(:project, forked_from_project: target_project)
end
let(:target_project) { create(:project, :repository) }
let(:source_project) { create(:project, :repository, forked_from_project: target_project) }
let(:merge_request) do
create(:merge_request, :simple,
......
......@@ -4,8 +4,8 @@ describe 'projects/merge_requests/edit.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
let(:milestone) { create(:milestone, project: project) }
......
......@@ -4,8 +4,8 @@ describe 'projects/merge_requests/show.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) }
......
require 'spec_helper'
describe 'projects/pipelines/_stage', :view do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:stage) { build(:ci_stage, pipeline: pipeline) }
......
......@@ -4,7 +4,7 @@ describe 'projects/pipelines/show' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, user: user) }
before do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/tree/show' do
include Devise::Test::ControllerHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
before do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe DeleteMergedBranchesWorker do
subject(:worker) { described_class.new }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
describe "#perform" do
it "calls DeleteMergedBranchesService" do
......
......@@ -5,7 +5,7 @@ describe EmailsOnPushWorker do
include EmailHelpers
include EmailSpec::Matchers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
let(:recipients) { user.email }
......
......@@ -3,7 +3,7 @@ require 'fileutils'
require 'spec_helper'
describe GitGarbageCollectWorker do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:shell) { Gitlab::Shell.new }
subject { GitGarbageCollectWorker.new }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe GroupDestroyWorker do
let(:group) { create(:group) }
let(:user) { create(:admin) }
let!(:project) { create(:project, namespace: group) }
let!(:project) { create(:empty_project, namespace: group) }
subject { GroupDestroyWorker.new }
......
require 'spec_helper'
describe PipelineMetricsWorker do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) }
let(:pipeline) do
......
......@@ -11,7 +11,7 @@ describe PipelineNotificationWorker do
status: status)
end
let(:project) { create(:project, public_builds: false) }
let(:project) { create(:project, :repository, public_builds: false) }
let(:user) { create(:user) }
let(:pusher) { user }
let(:watcher) { pusher }
......
......@@ -4,7 +4,7 @@ describe PostReceive do
let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" }
let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") }
let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:key) { create(:key, user: project.owner) }
let(:key_id) { key.shell_id }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe ProcessCommitWorker do
let(:worker) { described_class.new }
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project, author: user) }
let(:commit) { project.commit }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe ProjectCacheWorker do
let(:worker) { described_class.new }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:statistics) { project.statistics }
describe '#perform' do
......
require 'spec_helper'
describe ProjectDestroyWorker do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:path) { project.repository.path_to_repo }
subject { ProjectDestroyWorker.new }
......
......@@ -4,7 +4,7 @@ describe RepositoryCheck::BatchWorker do
subject { described_class.new }
it 'prefers projects that have never been checked' do
projects = create_list(:project, 3, created_at: 1.week.ago)
projects = create_list(:empty_project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 4.months.ago)
projects[2].update_column(:last_repository_check_at, 3.months.ago)
......@@ -12,7 +12,7 @@ describe RepositoryCheck::BatchWorker do
end
it 'sorts projects by last_repository_check_at' do
projects = create_list(:project, 3, created_at: 1.week.ago)
projects = create_list(:empty_project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 2.months.ago)
projects[1].update_column(:last_repository_check_at, 4.months.ago)
projects[2].update_column(:last_repository_check_at, 3.months.ago)
......@@ -21,7 +21,7 @@ describe RepositoryCheck::BatchWorker do
end
it 'excludes projects that were checked recently' do
projects = create_list(:project, 3, created_at: 1.week.ago)
projects = create_list(:empty_project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 2.days.ago)
projects[1].update_column(:last_repository_check_at, 2.months.ago)
projects[2].update_column(:last_repository_check_at, 3.days.ago)
......@@ -40,7 +40,7 @@ describe RepositoryCheck::BatchWorker do
it 'skips projects created less than 24 hours ago' do
project = create(:empty_project)
project.update_column(:created_at, 23.hours.ago)
expect(subject.perform).to eq([])
end
end
require 'spec_helper'
describe RepositoryForkWorker do
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:shell) { Gitlab::Shell.new }
subject { RepositoryForkWorker.new }
......
require 'spec_helper'
describe RepositoryImportWorker do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
subject { described_class.new }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe UpdateMergeRequestsWorker do
include RepoHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
subject { described_class.new }
......
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