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

Inline helper methods

parent 2e9b6b53
...@@ -11,38 +11,41 @@ module QA ...@@ -11,38 +11,41 @@ module QA
end end
end end
def fabricate_runner after do
Service::Runner.new(runner_name).remove!
end
scenario 'user sets up a deploy key to clone code using pipelines' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Factory::Resource::Runner.fabricate! do |resource| Factory::Resource::Runner.fabricate! do |resource|
resource.project = project resource.project = project
resource.name = runner_name resource.name = runner_name
resource.tags = %w[qa docker] resource.tags = %w[qa docker]
resource.image = 'gitlab/gitlab-runner:ubuntu' resource.image = 'gitlab/gitlab-runner:ubuntu'
end end
end
def fabricate_deploy_key
Factory::Resource::DeployKey.fabricate! do |resource| Factory::Resource::DeployKey.fabricate! do |resource|
resource.project = project resource.project = project
resource.title = 'deploy key title' resource.title = 'deploy key title'
resource.key = key.public_key resource.key = key.public_key
end end
end
def fabricate_secret_variable
Factory::Resource::SecretVariable.fabricate! do |resource| Factory::Resource::SecretVariable.fabricate! do |resource|
resource.project = project resource.project = project
resource.key = 'DEPLOY_KEY' resource.key = 'DEPLOY_KEY'
resource.value = key.to_pem resource.value = key.to_pem
end end
end
def fabricate_gitlab_ci project.visit!
repository_uri = Page::Project::Show.act do repository_uri = Page::Project::Show.act do
choose_repository_clone_ssh choose_repository_clone_ssh
repository_location_uri repository_location_uri
end end
<<~YAML gitlab_ci = <<~YAML
cat-config: cat-config:
script: script:
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
...@@ -55,33 +58,14 @@ module QA ...@@ -55,33 +58,14 @@ module QA
- qa - qa
- docker - docker
YAML YAML
end
def fabricate_push(gitlab_ci)
Factory::Repository::Push.fabricate! do |resource| Factory::Repository::Push.fabricate! do |resource|
resource.project = project resource.project = project
resource.file_name = '.gitlab-ci.yml' resource.file_name = '.gitlab-ci.yml'
resource.commit_message = 'Add .gitlab-ci.yml' resource.commit_message = 'Add .gitlab-ci.yml'
resource.file_content = gitlab_ci resource.file_content = gitlab_ci
end end
end
after do
Service::Runner.new(runner_name).remove!
end
scenario 'user sets up a deploy key to clone code using pipelines' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
fabricate_runner
fabricate_deploy_key
fabricate_secret_variable
project.visit!
gitlab_ci = fabricate_gitlab_ci
fabricate_push(gitlab_ci)
sha1sum = Digest::SHA1.hexdigest(gitlab_ci) sha1sum = Digest::SHA1.hexdigest(gitlab_ci)
Page::Project::Show.act { wait_for_push } Page::Project::Show.act { wait_for_push }
......
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