diff options
author | Nick Thomas <nick@gitlab.com> | 2018-03-07 14:32:47 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-03-07 14:32:47 +0000 |
commit | 07432373efc89746ec16ec4397f6d53c56352adf (patch) | |
tree | 407eaab436fb229120b0c68c7dfe58eb4b8780f0 /spec | |
parent | 195a2ac9cef9bef6b38876e4914d710a55394b73 (diff) | |
parent | b0e5906d190ce1de499a553132f25de9135a1449 (diff) | |
download | gitlab-ce-07432373efc89746ec16ec4397f6d53c56352adf.tar.gz |
Merge branch 'tc-geo-local-only-counts-matcher' into 'master'
Backport of "Geo: Ignore remote stored objects when calculating counts"
See merge request gitlab-org/gitlab-ce!17581
Diffstat (limited to 'spec')
-rw-r--r-- | spec/support/matchers/match_ids.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/support/matchers/match_ids.rb b/spec/support/matchers/match_ids.rb new file mode 100644 index 00000000000..d8424405b96 --- /dev/null +++ b/spec/support/matchers/match_ids.rb @@ -0,0 +1,24 @@ +RSpec::Matchers.define :match_ids do |*expected| + match do |actual| + actual_ids = map_ids(actual) + expected_ids = map_ids(expected) + + expect(actual_ids).to match_array(expected_ids) + end + + description do + 'matches elements by ids' + end + + def map_ids(elements) + elements = elements.flatten if elements.respond_to?(:flatten) + + if elements.respond_to?(:map) + elements.map(&:id) + elsif elements.respond_to?(:id) + [elements.id] + else + raise ArgumentError, "could not map elements to ids: #{elements}" + end + end +end |