summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-06 15:38:09 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-06 15:38:09 +0200
commit150fc0cc68759f370f38c730b09fa19e650bd16d (patch)
treecaad32c740726b46fee3ef63ce1e0fdcde3e187d /spec
parent6d775ddae4e561b9a932177fdaf5f6a4a16030a2 (diff)
parentb33d4bc2f1d26ee3526b9d7f530f468a9d5b5a5e (diff)
downloadgitlab-ce-150fc0cc68759f370f38c730b09fa19e650bd16d.tar.gz
Merge branch 'master' into mentioned_inside_mr
Diffstat (limited to 'spec')
-rw-r--r--spec/models/event_spec.rb3
-rw-r--r--spec/models/gitlab_ci_service_spec.rb4
-rw-r--r--spec/requests/api/repositories_spec.rb3
-rw-r--r--spec/services/git_push_service_spec.rb2
-rw-r--r--spec/support/test_env.rb45
5 files changed, 44 insertions, 13 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 1fdd959da9d..204ae9da704 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -36,7 +36,7 @@ describe Event do
@user = project.owner
data = {
- before: "0000000000000000000000000000000000000000",
+ before: Gitlab::Git::BLANK_SHA,
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
ref: "refs/heads/master",
user_id: @user.id,
@@ -60,7 +60,6 @@ describe Event do
it { @event.push?.should be_true }
it { @event.proper?.should be_true }
- it { @event.new_branch?.should be_true }
it { @event.tag?.should be_false }
it { @event.branch_name.should == "master" }
it { @event.author.should == @user }
diff --git a/spec/models/gitlab_ci_service_spec.rb b/spec/models/gitlab_ci_service_spec.rb
index ebc377047be..83277058fbb 100644
--- a/spec/models/gitlab_ci_service_spec.rb
+++ b/spec/models/gitlab_ci_service_spec.rb
@@ -34,11 +34,11 @@ describe GitlabCiService do
end
describe :commit_status_path do
- it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/builds/2ab7834c/status.json?token=verySecret"}
+ it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret"}
end
describe :build_page do
- it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/builds/2ab7834c"}
+ it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c"}
end
end
end
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index dd7a0fc6cc8..beae71c02d9 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -37,8 +37,7 @@ describe API::API, api: true do
context 'annotated tag' do
it 'should create a new annotated tag' do
# Identity must be set in .gitconfig to create annotated tag.
- repo_path = File.join(Gitlab.config.gitlab_shell.repos_path,
- project.path_with_namespace + '.git')
+ repo_path = project.repository.path_to_repo
system(*%W(git --git-dir=#{repo_path} config user.name #{user.name}))
system(*%W(git --git-dir=#{repo_path} config user.email #{user.email}))
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 4ef053a767f..19b442573f4 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -8,7 +8,7 @@ describe GitPushService do
let (:service) { GitPushService.new }
before do
- @blankrev = '0000000000000000000000000000000000000000'
+ @blankrev = Gitlab::Git::BLANK_SHA
@oldrev = sample_commit.parent_id
@newrev = sample_commit.id
@ref = 'refs/heads/master'
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 5f55871dc4a..e6db410fb1c 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -3,6 +3,16 @@ require 'rspec/mocks'
module TestEnv
extend self
+ # When developing the seed repository, comment out the branch you will modify.
+ BRANCH_SHA = {
+ 'feature' => '0b4bc9a',
+ 'feature_conflict' => 'bb5206f',
+ 'fix' => '12d65c8',
+ 'improve/awesome' => '5937ac0',
+ 'markdown' => '0ed8c6c',
+ 'master' => '5937ac0'
+ }
+
# Test environment
#
# See gitlab.yml.example test section for paths
@@ -18,13 +28,13 @@ module TestEnv
if File.directory?(tmp_test_path)
Dir.entries(tmp_test_path).each do |entry|
- unless ['.', '..', 'gitlab-shell'].include?(entry)
+ unless ['.', '..', 'gitlab-shell', factory_repo_name].include?(entry)
FileUtils.rm_r(File.join(tmp_test_path, entry))
end
end
end
- FileUtils.mkdir_p(tmp_test_path)
+ FileUtils.mkdir_p(repos_path)
# Setup GitLab shell for test instance
setup_gitlab_shell
@@ -49,13 +59,32 @@ module TestEnv
clone_url = "https://gitlab.com/gitlab-org/#{factory_repo_name}.git"
unless File.directory?(factory_repo_path)
- git_cmd = %W(git clone --bare #{clone_url} #{factory_repo_path})
- system(*git_cmd)
+ system(*%W(git clone #{clone_url} #{factory_repo_path}))
+ end
+
+ Dir.chdir(factory_repo_path) do
+ BRANCH_SHA.each do |branch, sha|
+ # Try to reset without fetching to avoid using the network.
+ reset = %W(git update-ref refs/heads/#{branch} #{sha})
+ unless system(*reset)
+ if system(*%w(git fetch origin))
+ unless system(*reset)
+ raise 'The fetched test seed '\
+ 'does not contain the required revision.'
+ end
+ else
+ raise 'Could not fetch test seed repository.'
+ end
+ end
+ end
end
+
+ # We must copy bare repositories because we will push to them.
+ system(*%W(git clone --bare #{factory_repo_path} #{factory_repo_path_bare}))
end
def copy_repo(project)
- base_repo_path = File.expand_path(factory_repo_path)
+ base_repo_path = File.expand_path(factory_repo_path_bare)
target_repo_path = File.expand_path(repos_path + "/#{project.namespace.path}/#{project.path}.git")
FileUtils.mkdir_p(target_repo_path)
FileUtils.cp_r("#{base_repo_path}/.", target_repo_path)
@@ -69,7 +98,11 @@ module TestEnv
private
def factory_repo_path
- @factory_repo_path ||= repos_path + "/root/#{factory_repo_name}.git"
+ @factory_repo_path ||= Rails.root.join('tmp', 'tests', factory_repo_name)
+ end
+
+ def factory_repo_path_bare
+ factory_repo_path.to_s + '_bare'
end
def factory_repo_name