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