summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <ddavison@gitlab.com>2019-07-22 22:29:15 +0000
committerDan Davison <ddavison@gitlab.com>2019-07-22 22:29:15 +0000
commit18221f955e26f98190e1b743102d2eb553d64852 (patch)
tree44a4800645c504a6428cdf8f3d19aff23294dc76
parent5595c9ded4d3e019c346f18de0f8509ded4a1b5d (diff)
parent510d03fec26ac64c1ec643f492676c02f4099a56 (diff)
downloadgitlab-ce-18221f955e26f98190e1b743102d2eb553d64852.tar.gz
Merge branch 'pl-flat_map-qa' into 'master'
QA: Prefer `flat_map` over `map` + `flatten` See merge request gitlab-org/gitlab-ce!30883
-rw-r--r--qa/qa/page/base.rb4
-rw-r--r--qa/qa/page/validator.rb6
-rw-r--r--qa/qa/scenario/test/sanity/selectors.rb2
-rw-r--r--qa/spec/specs/runner_spec.rb4
4 files changed, 7 insertions, 9 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 80ce23d5c38..45496c6b245 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -181,11 +181,11 @@ module QA
return ["Page class does not have views / elements defined!"]
end
- views.map(&:errors).flatten
+ views.flat_map(&:errors)
end
def self.elements
- views.map(&:elements).flatten
+ views.flat_map(&:elements)
end
def send_keys_to_element(name, keys)
diff --git a/qa/qa/page/validator.rb b/qa/qa/page/validator.rb
index edd12665f1e..9b2d0a1a41d 100644
--- a/qa/qa/page/validator.rb
+++ b/qa/qa/page/validator.rb
@@ -22,16 +22,14 @@ module QA
end
def descendants
- @descendants ||= constants.map do |const|
+ @descendants ||= constants.flat_map do |const|
case const
when Class
const if const < Page::Base
when Module
Page::Validator.new(const).descendants
end
- end
-
- @descendants.flatten.compact
+ end.compact
end
def errors
diff --git a/qa/qa/scenario/test/sanity/selectors.rb b/qa/qa/scenario/test/sanity/selectors.rb
index e05269e8d55..b4d70fc191a 100644
--- a/qa/qa/scenario/test/sanity/selectors.rb
+++ b/qa/qa/scenario/test/sanity/selectors.rb
@@ -14,7 +14,7 @@ module QA
Page::Validator.new(pages)
end
- validators.map(&:errors).flatten.tap do |errors|
+ validators.flat_map(&:errors).tap do |errors|
break if errors.none?
warn <<~EOS
diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb
index 6c533c6dc7d..3d98f03a982 100644
--- a/qa/spec/specs/runner_spec.rb
+++ b/qa/spec/specs/runner_spec.rb
@@ -125,9 +125,9 @@ describe QA::Specs::Runner do
end
def excluded_feature_tags_except(tag)
- QA::Runtime::Env.supported_features.except(tag).map do |tag, _|
+ QA::Runtime::Env.supported_features.except(tag).flat_map do |tag, _|
['--tag', "~requires_#{tag}"]
- end.flatten
+ end
end
def expect_rspec_runner_arguments(arguments)