Commit a10d8adf authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename location to uri; Handle uri for HTTP; Fix pushing remote

parent 1421469e
......@@ -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
......
......@@ -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 }
......
......@@ -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(':')
......
......@@ -15,8 +15,7 @@ module QA
end
end
def location=(address)
@location = address
def uri=(address)
@uri = URI(address)
end
......
......@@ -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 }
......
......@@ -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
......
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