summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-15 15:30:26 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-15 15:30:26 +0800
commit0f7851b7beb868511d7208a8170be905aecc731b (patch)
tree83612a416b8d62cb52e80def25fcb6d6393ea287 /spec/workers
parentabd7943636715b0ea4c861135a02db97b6bcfb7e (diff)
parentbdb6f1e6fa756ae0db57e0474706685b6115c1e1 (diff)
downloadgitlab-ce-0f7851b7beb868511d7208a8170be905aecc731b.tar.gz
Merge remote-tracking branch 'upstream/master' into new-issue-by-email
* upstream/master: (1547 commits) Add margin between buttons if both retry and cancel are present Add margin between labels; remove underline hover style on status button udpated JS based on feedback Use default cursor for table header of project files (!5165) Fix duplicated entry in changelog [ci skip] Improves left static sidebar behaviour Include default callback URL (OAuth) Cleanup feature proposal template Simplify regex for string-based multi-word label surrounded in quotes Revert "Merge branch '18193-developers-can-merge' into 'master' " Upgrade Rails from 4.2.6 to 4.2.7. some JS magic to fix empty URL bug formats my test properly Update CHANGELOG Doesn't match empty label references surrounded in quotes Fix markdown rendering for label references that contains `.` Fix markdown rendering for label references that begin with a digit Fix markdown rendering for consecutive label references Stub omniauth provider for GitLab Update CHANGELOG ...
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/expire_build_artifacts_worker_spec.rb12
-rw-r--r--spec/workers/git_garbage_collect_worker_spec.rb24
-rw-r--r--spec/workers/merge_worker_spec.rb2
-rw-r--r--spec/workers/post_receive_spec.rb2
-rw-r--r--spec/workers/project_cache_worker_spec.rb1
-rw-r--r--spec/workers/repository_check/single_repository_worker_spec.rb29
-rw-r--r--spec/workers/repository_fork_worker_spec.rb9
7 files changed, 73 insertions, 6 deletions
diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb
index e3827cae9a6..7d6668920c0 100644
--- a/spec/workers/expire_build_artifacts_worker_spec.rb
+++ b/spec/workers/expire_build_artifacts_worker_spec.rb
@@ -20,6 +20,10 @@ describe ExpireBuildArtifactsWorker do
it 'does remove files' do
expect(build.reload.artifacts_file.exists?).to be_falsey
end
+
+ it 'does nullify artifacts_file column' do
+ expect(build.reload.artifacts_file_identifier).to be_nil
+ end
end
context 'with not yet expired artifacts' do
@@ -32,6 +36,10 @@ describe ExpireBuildArtifactsWorker do
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
+
+ it 'does not nullify artifacts_file column' do
+ expect(build.reload.artifacts_file_identifier).not_to be_nil
+ end
end
context 'without expire date' do
@@ -44,6 +52,10 @@ describe ExpireBuildArtifactsWorker do
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
+
+ it 'does not nullify artifacts_file column' do
+ expect(build.reload.artifacts_file_identifier).not_to be_nil
+ end
end
context 'for expired artifacts' do
diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb
new file mode 100644
index 00000000000..a9cce8b8b59
--- /dev/null
+++ b/spec/workers/git_garbage_collect_worker_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe GitGarbageCollectWorker do
+ let(:project) { create(:project) }
+ let(:shell) { Gitlab::Shell.new }
+
+ subject { GitGarbageCollectWorker.new }
+
+ before do
+ allow(subject).to receive(:gitlab_shell).and_return(shell)
+ end
+
+ describe "#perform" do
+ it "runs `git gc`" do
+ expect(shell).to receive(:gc).with(
+ project.repository_storage_path,
+ project.path_with_namespace).
+ and_return(true)
+ expect_any_instance_of(Repository).to receive(:after_create_branch)
+
+ subject.perform(project.id)
+ end
+ end
+end
diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb
index 1abd87d7d33..b5e1fdb8ded 100644
--- a/spec/workers/merge_worker_spec.rb
+++ b/spec/workers/merge_worker_spec.rb
@@ -9,7 +9,7 @@ describe MergeWorker do
before do
source_project.team << [author, :master]
- source_project.repository.expire_branch_names
+ source_project.repository.expire_branches_cache
end
it 'clears cache of source repo after removing source branch' do
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index b8e73682c91..20b1a343c27 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -91,6 +91,6 @@ describe PostReceive do
end
def pwd(project)
- File.join(Gitlab.config.gitlab_shell.repos_path, project.path_with_namespace)
+ File.join(Gitlab.config.repositories.storages.default, project.path_with_namespace)
end
end
diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb
index 7e59bd2fced..5785a6a06ff 100644
--- a/spec/workers/project_cache_worker_spec.rb
+++ b/spec/workers/project_cache_worker_spec.rb
@@ -7,7 +7,6 @@ describe ProjectCacheWorker do
describe '#perform' do
it 'updates project cache data' do
-
expect_any_instance_of(Repository).to receive(:size)
expect_any_instance_of(Repository).to receive(:commit_count)
diff --git a/spec/workers/repository_check/single_repository_worker_spec.rb b/spec/workers/repository_check/single_repository_worker_spec.rb
index 5a03bb77ebd..05e07789dac 100644
--- a/spec/workers/repository_check/single_repository_worker_spec.rb
+++ b/spec/workers/repository_check/single_repository_worker_spec.rb
@@ -4,6 +4,26 @@ require 'fileutils'
describe RepositoryCheck::SingleRepositoryWorker do
subject { described_class.new }
+ it 'passes when the project has no push events' do
+ project = create(:project_empty_repo, wiki_enabled: false)
+ project.events.destroy_all
+ break_repo(project)
+
+ subject.perform(project.id)
+
+ expect(project.reload.last_repository_check_failed).to eq(false)
+ end
+
+ it 'fails when the project has push events and a broken repository' do
+ project = create(:project_empty_repo)
+ create_push_event(project)
+ break_repo(project)
+
+ subject.perform(project.id)
+
+ expect(project.reload.last_repository_check_failed).to eq(true)
+ end
+
it 'fails if the wiki repository is broken' do
project = create(:project_empty_repo, wiki_enabled: true)
project.create_wiki
@@ -39,6 +59,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
it 'does not create a wiki if the main repo does not exist at all' do
project = create(:project_empty_repo)
+ create_push_event(project)
FileUtils.rm_rf(project.repository.path_to_repo)
FileUtils.rm_rf(wiki_path(project))
@@ -54,4 +75,12 @@ describe RepositoryCheck::SingleRepositoryWorker do
def wiki_path(project)
project.wiki.repository.path_to_repo
end
+
+ def create_push_event(project)
+ project.events.create(action: Event::PUSHED, author_id: create(:user).id)
+ end
+
+ def break_repo(project)
+ FileUtils.rm_rf(File.join(project.repository.path_to_repo, 'objects'))
+ end
end
diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb
index 4ef05eb29d2..5f762282b5e 100644
--- a/spec/workers/repository_fork_worker_spec.rb
+++ b/spec/workers/repository_fork_worker_spec.rb
@@ -14,6 +14,7 @@ describe RepositoryForkWorker do
describe "#perform" do
it "creates a new repository from a fork" do
expect(shell).to receive(:fork_repository).with(
+ project.repository_storage_path,
project.path_with_namespace,
fork_project.namespace.path
).and_return(true)
@@ -25,9 +26,11 @@ describe RepositoryForkWorker do
end
it 'flushes various caches' do
- expect(shell).to receive(:fork_repository).
- with(project.path_with_namespace, fork_project.namespace.path).
- and_return(true)
+ expect(shell).to receive(:fork_repository).with(
+ project.repository_storage_path,
+ project.path_with_namespace,
+ fork_project.namespace.path
+ ).and_return(true)
expect_any_instance_of(Repository).to receive(:expire_emptiness_caches).
and_call_original