summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2018-01-16 13:26:53 +0100
committerBrett Walker <bwalker@gitlab.com>2018-01-22 17:25:11 +0100
commitd1eac40b971b070c252a758f04ce085c9637aeae (patch)
tree49346a82d43534568b95ded21447314f22ad7098
parentffa2230e9a298705e06f822fdaa1b9e2cc0bb2a8 (diff)
downloadgitlab-ce-d1eac40b971b070c252a758f04ce085c9637aeae.tar.gz
addressed various feedback in MR request
-rw-r--r--qa/qa.rb3
-rw-r--r--qa/qa/factory/base.rb2
-rw-r--r--qa/qa/factory/product.rb7
-rw-r--r--qa/qa/factory/resource/personal_access_token.rb17
-rw-r--r--qa/qa/runtime/session.rb15
-rw-r--r--qa/qa/specs/features/api/users_spec.rb2
-rw-r--r--qa/qa/specs/runner.rb2
-rw-r--r--qa/qa/support/api_helpers.rb2
8 files changed, 24 insertions, 26 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 062f281f2b3..acd1a327848 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -1,8 +1,5 @@
$: << File.expand_path(File.dirname(__FILE__))
-require 'rspec/core'
-require 'airborne'
-
module QA
##
# GitLab QA runtime classes, mostly singletons.
diff --git a/qa/qa/factory/base.rb b/qa/qa/factory/base.rb
index afaa96b4541..bd66b74a164 100644
--- a/qa/qa/factory/base.rb
+++ b/qa/qa/factory/base.rb
@@ -22,7 +22,7 @@ module QA
factory.fabricate!(*args)
- return Factory::Product.populate!(factory)
+ return Factory::Product.populate!(self)
end
end
diff --git a/qa/qa/factory/product.rb b/qa/qa/factory/product.rb
index dbe02d37f22..937bae7ac11 100644
--- a/qa/qa/factory/product.rb
+++ b/qa/qa/factory/product.rb
@@ -8,8 +8,7 @@ module QA
Attribute = Struct.new(:name, :block)
- def initialize(factory)
- @factory = factory
+ def initialize
@location = current_url
end
@@ -18,8 +17,8 @@ module QA
end
def self.populate!(factory)
- new(factory).tap do |product|
- factory.class.attributes.each_value do |attribute|
+ new.tap do |product|
+ factory.attributes.each_value do |attribute|
product.instance_exec(&attribute.block).tap do |value|
product.define_singleton_method(attribute.name) { value }
end
diff --git a/qa/qa/factory/resource/personal_access_token.rb b/qa/qa/factory/resource/personal_access_token.rb
index cfe845214f6..aebfda6510d 100644
--- a/qa/qa/factory/resource/personal_access_token.rb
+++ b/qa/qa/factory/resource/personal_access_token.rb
@@ -1,19 +1,24 @@
-# Create a personal access token that can be used by the api
-# set the environment variable PERSONAL_ACCESS_TOKEN to use a
-# specific access token rather than create one from the UI
module QA
module Factory
module Resource
+ ##
+ # Create a personal access token that can be used by the api
+ # set the environment variable PERSONAL_ACCESS_TOKEN to use a
+ # specific access token rather than create one from the UI
+ #
class PersonalAccessToken < Factory::Base
attr_accessor :name
product :access_token do
- Page::Profile::PersonalAccessTokens.act { created_access_token }
+ if Runtime::Env.personal_access_token
+ Runtime::Env.personal_access_token
+ else
+ Page::Profile::PersonalAccessTokens.act { created_access_token }
+ end
end
def fabricate!(sign_in_address = :gitlab)
- access_token = Runtime::Env.personal_access_token
- return if access_token
+ return if Runtime::Env.personal_access_token
if sign_in_address
Runtime::Browser.visit(sign_in_address, Page::Main::Login)
diff --git a/qa/qa/runtime/session.rb b/qa/qa/runtime/session.rb
index 1a92455221a..afcafea1dbb 100644
--- a/qa/qa/runtime/session.rb
+++ b/qa/qa/runtime/session.rb
@@ -9,17 +9,10 @@ module QA
end
def host
- @instance.is_a?(Symbol) ? Runtime::Scenario.send("#{@instance}_address") : @instance.to_s
- end
-
- def add_query_values(args)
- if args.any?
- query_string = Hash(*args).map { |key, value| "#{key}=#{value}" }.join('&')
-
- if query_string
- @address << (@address.index('?') ? '&' : '?')
- @address << query_string
- end
+ if @instance.is_a?(Symbol)
+ Runtime::Scenario.send("#{@instance}_address")
+ else
+ @instance.to_s
end
end
end
diff --git a/qa/qa/specs/features/api/users_spec.rb b/qa/qa/specs/features/api/users_spec.rb
index 4e7f5a92f84..813aaf90cf2 100644
--- a/qa/qa/specs/features/api/users_spec.rb
+++ b/qa/qa/specs/features/api/users_spec.rb
@@ -15,7 +15,7 @@ module QA
end
scenario 'returns an empty response when an invalid `username` parameter is passed' do
- get session.address, { params: {username: 'invalid'} }
+ get session.address, { params: { username: 'invalid' } }
expect_status(200)
expect(json_body).to be_an Array
expect(json_body.size).to eq(0)
diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb
index 9ede404c90e..3f7b75df986 100644
--- a/qa/qa/specs/runner.rb
+++ b/qa/qa/specs/runner.rb
@@ -1,3 +1,5 @@
+require 'rspec/core'
+
module QA
module Specs
class Runner < Scenario::Template
diff --git a/qa/qa/support/api_helpers.rb b/qa/qa/support/api_helpers.rb
index 1cd73565250..ccabf7fe809 100644
--- a/qa/qa/support/api_helpers.rb
+++ b/qa/qa/support/api_helpers.rb
@@ -1,3 +1,5 @@
+require 'airborne'
+
module QA
module Support
module ApiHelpers