Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Leitzen <pleitzen@gitlab.com>2019-07-24 11:19:15 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-07-24 11:19:15 +0300
commit163a43629c9018beb5f2a474ce63a0065445471b (patch)
tree3081baef63fcb1bdc30c35972793e49b750be859 /spec/lib/gitlab/prometheus
parent2524cb1016cc54b82bcbf01e4df5fad46b980912 (diff)
Prefer `flat_map` over `map` + `flatten` in specs
Although `flat_map` is equivalent to `map` + `flatten(1)` (note the level 1) we can apply this same refactoring to all cases.
Diffstat (limited to 'spec/lib/gitlab/prometheus')
-rw-r--r--spec/lib/gitlab/prometheus/metric_group_spec.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/spec/lib/gitlab/prometheus/metric_group_spec.rb b/spec/lib/gitlab/prometheus/metric_group_spec.rb
index 5cc6827488b..a45dd0af91e 100644
--- a/spec/lib/gitlab/prometheus/metric_group_spec.rb
+++ b/spec/lib/gitlab/prometheus/metric_group_spec.rb
@@ -17,7 +17,7 @@ describe Gitlab::Prometheus::MetricGroup do
end
it 'returns exactly three metric queries' do
- expect(subject.map(&:metrics).flatten.map(&:id)).to contain_exactly(
+ expect(subject.flat_map(&:metrics).map(&:id)).to contain_exactly(
common_metric_group_a.id, common_metric_group_b_q1.id,
common_metric_group_b_q2.id)
end
@@ -37,7 +37,7 @@ describe Gitlab::Prometheus::MetricGroup do
subject do
described_class.for_project(other_project)
- .map(&:metrics).flatten
+ .flat_map(&:metrics)
.map(&:id)
end