summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-04-24 21:50:57 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-04-24 21:50:57 +0800
commita10d8adf315b4945c7e3149ce81b0ea7c35ba376 (patch)
tree8b712d55c49bf400c89b7aead93f34f3f1823bdb /qa
parent1421469e221a14b9250d162f42e3b418528a501d (diff)
downloadgitlab-ce-a10d8adf315b4945c7e3149ce81b0ea7c35ba376.tar.gz
Rename location to uri; Handle uri for HTTP; Fix pushing remote
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/factory/repository/push.rb23
-rw-r--r--qa/qa/factory/resource/branch.rb4
-rw-r--r--qa/qa/git/location.rb2
-rw-r--r--qa/qa/git/repository.rb3
-rw-r--r--qa/qa/specs/features/repository/clone_spec.rb8
-rw-r--r--qa/qa/specs/features/repository/protected_branches_spec.rb2
6 files changed, 24 insertions, 18 deletions
diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb
index a091ae119b3..01a9d0428ea 100644
--- a/qa/qa/factory/repository/push.rb
+++ b/qa/qa/factory/repository/push.rb
@@ -2,7 +2,8 @@ module QA
module Factory
module Repository
class Push < Factory::Base
- attr_writer :file_name, :file_content, :commit_message, :branch_name, :new_branch
+ attr_accessor :file_name, :file_content, :commit_message,
+ :branch_name, :new_branch, :remote_branch
dependency Factory::Resource::Project, as: :project do |project|
project.name = 'project-with-code'
@@ -17,28 +18,32 @@ module QA
@new_branch = true
end
+ def remote_branch
+ @remote_branch ||= branch_name
+ end
+
def fabricate!
project.visit!
Git::Repository.perform do |repository|
- repository.location = Page::Project::Show.act do
+ repository.uri = Page::Project::Show.act do
choose_repository_clone_http
- repository_location.git_uri
+ repository_location.uri
end
repository.use_default_credentials
repository.clone
repository.configure_identity('GitLab QA', 'root@gitlab.com')
- if @new_branch
- repository.checkout_new_branch(@branch_name)
+ if new_branch
+ repository.checkout_new_branch(branch_name)
else
- repository.checkout(@branch_name)
+ repository.checkout(branch_name)
end
- repository.add_file(@file_name, @file_content)
- repository.commit(@commit_message)
- repository.push_changes(@branch_name)
+ repository.add_file(file_name, file_content)
+ repository.commit(commit_message)
+ repository.push_changes("#{branch_name}:#{remote_branch}")
end
end
end
diff --git a/qa/qa/factory/resource/branch.rb b/qa/qa/factory/resource/branch.rb
index d0ef142e90d..d6bfdfa2356 100644
--- a/qa/qa/factory/resource/branch.rb
+++ b/qa/qa/factory/resource/branch.rb
@@ -39,7 +39,9 @@ module QA
resource.project = project
resource.file_name = 'README.md'
resource.commit_message = 'Add readme'
- resource.branch_name = "master:#{@branch_name}"
+ resource.branch_name = 'master'
+ resource.new_branch = false
+ resource.remote_branch = @branch_name
end
Page::Project::Show.act { wait_for_push }
diff --git a/qa/qa/git/location.rb b/qa/qa/git/location.rb
index 30538388530..b74f38f3ae3 100644
--- a/qa/qa/git/location.rb
+++ b/qa/qa/git/location.rb
@@ -14,7 +14,7 @@ module QA
def initialize(git_uri)
@git_uri = git_uri
@uri =
- if git_uri.start_with?('ssh://')
+ if git_uri =~ %r{\A(?:ssh|http|https)://}
URI.parse(git_uri)
else
*rest, path = git_uri.split(':')
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
index 7aef0fd4c7a..1367671e3ca 100644
--- a/qa/qa/git/repository.rb
+++ b/qa/qa/git/repository.rb
@@ -15,8 +15,7 @@ module QA
end
end
- def location=(address)
- @location = address
+ def uri=(address)
@uri = URI(address)
end
diff --git a/qa/qa/specs/features/repository/clone_spec.rb b/qa/qa/specs/features/repository/clone_spec.rb
index 2fc467b1df4..bc9eb57bdb4 100644
--- a/qa/qa/specs/features/repository/clone_spec.rb
+++ b/qa/qa/specs/features/repository/clone_spec.rb
@@ -4,7 +4,7 @@ module QA
given(:location) do
Page::Project::Show.act do
choose_repository_clone_http
- repository_location.git_uri
+ repository_location
end
end
@@ -18,7 +18,7 @@ module QA
end
Git::Repository.perform do |repository|
- repository.location = location
+ repository.uri = location.uri
repository.use_default_credentials
repository.act do
@@ -33,7 +33,7 @@ module QA
scenario 'user performs a deep clone' do
Git::Repository.perform do |repository|
- repository.location = location
+ repository.uri = location.uri
repository.use_default_credentials
repository.act { clone }
@@ -44,7 +44,7 @@ module QA
scenario 'user performs a shallow clone' do
Git::Repository.perform do |repository|
- repository.location = location
+ repository.uri = location.uri
repository.use_default_credentials
repository.act { shallow_clone }
diff --git a/qa/qa/specs/features/repository/protected_branches_spec.rb b/qa/qa/specs/features/repository/protected_branches_spec.rb
index 88fa4994e32..89f0e0673af 100644
--- a/qa/qa/specs/features/repository/protected_branches_spec.rb
+++ b/qa/qa/specs/features/repository/protected_branches_spec.rb
@@ -42,7 +42,7 @@ module QA
project.visit!
Git::Repository.perform do |repository|
- repository.location = location
+ repository.uri = location.uri
repository.use_default_credentials
repository.act do