diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-05-27 14:02:20 +1200 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-05-27 14:02:20 +1200 |
commit | f31efe747376ae1b4505dd6a7aca6c71db82714f (patch) | |
tree | 08366fa01e46072372b79d060663518effcc5f4c /qa | |
parent | e59c3f8e3ad2e9b6a3431fa94d629eb6d5043972 (diff) | |
download | gitlab-ce-f31efe747376ae1b4505dd6a7aca6c71db82714f.tar.gz |
Move public class methods out of privateqa-public-class-methods
private modifier by itself does nothing for class methods (need
`private_class_method` for that). As these are documented to be public
methods in README, move them to the top.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/resource/base.rb | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb index 523d92c7ef3..283fc6cdbcb 100644 --- a/qa/qa/resource/base.rb +++ b/qa/qa/resource/base.rb @@ -15,6 +15,38 @@ module QA def_delegators :evaluator, :attribute + def self.fabricate!(*args, &prepare_block) + fabricate_via_api!(*args, &prepare_block) + rescue NotImplementedError + fabricate_via_browser_ui!(*args, &prepare_block) + end + + def self.fabricate_via_browser_ui!(*args, &prepare_block) + options = args.extract_options! + resource = options.fetch(:resource) { new } + parents = options.fetch(:parents) { [] } + + do_fabricate!(resource: resource, prepare_block: prepare_block, parents: parents) do + log_fabrication(:browser_ui, resource, parents, args) { resource.fabricate!(*args) } + + current_url + end + end + + def self.fabricate_via_api!(*args, &prepare_block) + options = args.extract_options! + resource = options.fetch(:resource) { new } + parents = options.fetch(:parents) { [] } + + raise NotImplementedError unless resource.api_support? + + resource.eager_load_api_client! + + do_fabricate!(resource: resource, prepare_block: prepare_block, parents: parents) do + log_fabrication(:api, resource, parents, args) { resource.fabricate_via_api! } + end + end + def fabricate!(*_args) raise NotImplementedError end @@ -55,38 +87,6 @@ module QA QA::Runtime::Logger.info "<#{self.class}> Attribute #{name.inspect} has both API response `#{api_value}` and a block. API response will be picked. Block will be ignored." end - def self.fabricate!(*args, &prepare_block) - fabricate_via_api!(*args, &prepare_block) - rescue NotImplementedError - fabricate_via_browser_ui!(*args, &prepare_block) - end - - def self.fabricate_via_browser_ui!(*args, &prepare_block) - options = args.extract_options! - resource = options.fetch(:resource) { new } - parents = options.fetch(:parents) { [] } - - do_fabricate!(resource: resource, prepare_block: prepare_block, parents: parents) do - log_fabrication(:browser_ui, resource, parents, args) { resource.fabricate!(*args) } - - current_url - end - end - - def self.fabricate_via_api!(*args, &prepare_block) - options = args.extract_options! - resource = options.fetch(:resource) { new } - parents = options.fetch(:parents) { [] } - - raise NotImplementedError unless resource.api_support? - - resource.eager_load_api_client! - - do_fabricate!(resource: resource, prepare_block: prepare_block, parents: parents) do - log_fabrication(:api, resource, parents, args) { resource.fabricate_via_api! } - end - end - def self.do_fabricate!(resource:, prepare_block:, parents: []) prepare_block.call(resource) if prepare_block |