Commit 93fcad8e authored by Imre Farkas's avatar Imre Farkas

Merge branch 'fix-flaky-specs' into 'master'

Fix flaky specs expecting fixed array order

See merge request gitlab-org/gitlab!44127
parents 96ec18bd c6c3b6b2
...@@ -42,7 +42,7 @@ RSpec.describe LabelsFinder do ...@@ -42,7 +42,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user) finder = described_class.new(user)
expect(finder.execute).to eq [group_label_2, group_label_3, project_label_1, group_label_1, project_label_2, project_label_4] expect(finder.execute).to match_array([group_label_2, group_label_3, project_label_1, group_label_1, project_label_2, project_label_4])
end end
it 'returns labels available if nil title is supplied' do it 'returns labels available if nil title is supplied' do
...@@ -50,7 +50,7 @@ RSpec.describe LabelsFinder do ...@@ -50,7 +50,7 @@ RSpec.describe LabelsFinder do
# params[:title] will return `nil` regardless whether it is specified # params[:title] will return `nil` regardless whether it is specified
finder = described_class.new(user, title: nil) finder = described_class.new(user, title: nil)
expect(finder.execute).to eq [group_label_2, group_label_3, project_label_1, group_label_1, project_label_2, project_label_4] expect(finder.execute).to match_array([group_label_2, group_label_3, project_label_1, group_label_1, project_label_2, project_label_4])
end end
end end
...@@ -60,7 +60,7 @@ RSpec.describe LabelsFinder do ...@@ -60,7 +60,7 @@ RSpec.describe LabelsFinder do
::Projects::UpdateService.new(project_1, user, archived: true).execute ::Projects::UpdateService.new(project_1, user, archived: true).execute
finder = described_class.new(user, **group_params(group_1)) finder = described_class.new(user, **group_params(group_1))
expect(finder.execute).to eq [group_label_2, group_label_1, project_label_5] expect(finder.execute).to match_array([group_label_2, group_label_1, project_label_5])
end end
context 'when only_group_labels is true' do context 'when only_group_labels is true' do
...@@ -69,7 +69,7 @@ RSpec.describe LabelsFinder do ...@@ -69,7 +69,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user, only_group_labels: true, **group_params(group_1)) finder = described_class.new(user, only_group_labels: true, **group_params(group_1))
expect(finder.execute).to eq [group_label_2, group_label_1] expect(finder.execute).to match_array([group_label_2, group_label_1])
end end
end end
...@@ -86,7 +86,7 @@ RSpec.describe LabelsFinder do ...@@ -86,7 +86,7 @@ RSpec.describe LabelsFinder do
it 'returns group labels' do it 'returns group labels' do
finder = described_class.new(user, **group_params(empty_group)) finder = described_class.new(user, **group_params(empty_group))
expect(finder.execute).to eq [empty_group_label_1, empty_group_label_2] expect(finder.execute).to match_array([empty_group_label_1, empty_group_label_2])
end end
end end
end end
...@@ -98,7 +98,7 @@ RSpec.describe LabelsFinder do ...@@ -98,7 +98,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user, **group_params(private_subgroup_1), only_group_labels: true, include_ancestor_groups: true) finder = described_class.new(user, **group_params(private_subgroup_1), only_group_labels: true, include_ancestor_groups: true)
expect(finder.execute).to eq [private_group_label_1, private_subgroup_label_1] expect(finder.execute).to match_array([private_group_label_1, private_subgroup_label_1])
end end
it 'ignores labels from groups which user can not read' do it 'ignores labels from groups which user can not read' do
...@@ -106,7 +106,7 @@ RSpec.describe LabelsFinder do ...@@ -106,7 +106,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user, **group_params(private_subgroup_1), only_group_labels: true, include_ancestor_groups: true) finder = described_class.new(user, **group_params(private_subgroup_1), only_group_labels: true, include_ancestor_groups: true)
expect(finder.execute).to eq [private_subgroup_label_1] expect(finder.execute).to match_array([private_subgroup_label_1])
end end
end end
...@@ -117,7 +117,7 @@ RSpec.describe LabelsFinder do ...@@ -117,7 +117,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user, **group_params(private_group_1), only_group_labels: true, include_descendant_groups: true) finder = described_class.new(user, **group_params(private_group_1), only_group_labels: true, include_descendant_groups: true)
expect(finder.execute).to eq [private_group_label_1, private_subgroup_label_1] expect(finder.execute).to match_array([private_group_label_1, private_subgroup_label_1])
end end
it 'ignores labels from groups which user can not read' do it 'ignores labels from groups which user can not read' do
...@@ -125,7 +125,7 @@ RSpec.describe LabelsFinder do ...@@ -125,7 +125,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user, **group_params(private_group_1), only_group_labels: true, include_descendant_groups: true) finder = described_class.new(user, **group_params(private_group_1), only_group_labels: true, include_descendant_groups: true)
expect(finder.execute).to eq [private_subgroup_label_1] expect(finder.execute).to match_array([private_subgroup_label_1])
end end
end end
...@@ -140,13 +140,13 @@ RSpec.describe LabelsFinder do ...@@ -140,13 +140,13 @@ RSpec.describe LabelsFinder do
shared_examples 'with full visibility' do shared_examples 'with full visibility' do
it 'returns all projects labels' do it 'returns all projects labels' do
expect(finder.execute).to eq [group_label_1, limited_visibility_label, visible_label] expect(finder.execute).to match_array([group_label_1, limited_visibility_label, visible_label])
end end
end end
shared_examples 'with limited visibility' do shared_examples 'with limited visibility' do
it 'returns only authorized projects labels' do it 'returns only authorized projects labels' do
expect(finder.execute).to eq [group_label_1, visible_label] expect(finder.execute).to match_array([group_label_1, visible_label])
end end
end end
...@@ -249,7 +249,7 @@ RSpec.describe LabelsFinder do ...@@ -249,7 +249,7 @@ RSpec.describe LabelsFinder do
it 'returns labels available for the project' do it 'returns labels available for the project' do
finder = described_class.new(user, project_id: project_1.id) finder = described_class.new(user, project_id: project_1.id)
expect(finder.execute).to eq [group_label_2, project_label_1, group_label_1] expect(finder.execute).to match_array([group_label_2, project_label_1, group_label_1])
end end
context 'as an administrator' do context 'as an administrator' do
...@@ -272,13 +272,13 @@ RSpec.describe LabelsFinder do ...@@ -272,13 +272,13 @@ RSpec.describe LabelsFinder do
it 'returns label with that title' do it 'returns label with that title' do
finder = described_class.new(user, title: 'Group Label 2') finder = described_class.new(user, title: 'Group Label 2')
expect(finder.execute).to eq [group_label_2] expect(finder.execute).to match_array([group_label_2])
end end
it 'returns label with title alias' do it 'returns label with title alias' do
finder = described_class.new(user, name: 'Group Label 2') finder = described_class.new(user, name: 'Group Label 2')
expect(finder.execute).to eq [group_label_2] expect(finder.execute).to match_array([group_label_2])
end end
it 'returns no labels if empty title is supplied' do it 'returns no labels if empty title is supplied' do
...@@ -304,19 +304,19 @@ RSpec.describe LabelsFinder do ...@@ -304,19 +304,19 @@ RSpec.describe LabelsFinder do
it 'returns labels with a partially matching title' do it 'returns labels with a partially matching title' do
finder = described_class.new(user, search: '(group)') finder = described_class.new(user, search: '(group)')
expect(finder.execute).to eq [group_label_1] expect(finder.execute).to match_array([group_label_1])
end end
it 'returns labels with a partially matching description' do it 'returns labels with a partially matching description' do
finder = described_class.new(user, search: 'awesome') finder = described_class.new(user, search: 'awesome')
expect(finder.execute).to eq [project_label_1] expect(finder.execute).to match_array([project_label_1])
end end
it 'returns labels matching a single character' do it 'returns labels matching a single character' do
finder = described_class.new(user, search: '(') finder = described_class.new(user, search: '(')
expect(finder.execute).to eq [group_label_1] expect(finder.execute).to match_array([group_label_1])
end end
end end
...@@ -326,7 +326,7 @@ RSpec.describe LabelsFinder do ...@@ -326,7 +326,7 @@ RSpec.describe LabelsFinder do
finder = described_class.new(user, subscribed: 'true') finder = described_class.new(user, subscribed: 'true')
expect(finder.execute).to eq [project_label_1] expect(finder.execute).to match_array([project_label_1])
end end
end end
......
...@@ -138,7 +138,7 @@ RSpec.describe Projects::AutocompleteService do ...@@ -138,7 +138,7 @@ RSpec.describe Projects::AutocompleteService do
def expect_labels_to_equal(labels, expected_labels) def expect_labels_to_equal(labels, expected_labels)
expect(labels.size).to eq(expected_labels.size) expect(labels.size).to eq(expected_labels.size)
extract_title = lambda { |label| label['title'] } extract_title = lambda { |label| label['title'] }
expect(labels.map(&extract_title)).to eq(expected_labels.map(&extract_title)) expect(labels.map(&extract_title)).to match_array(expected_labels.map(&extract_title))
end end
let(:user) { create(:user) } let(:user) { create(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment