From 0f51d17e71cd1812a980d3a2e7bb254d28d481f1 Mon Sep 17 00:00:00 2001 From: Anna Topalidi Date: Sun, 8 Sep 2024 19:23:07 +0200 Subject: [PATCH] fix tests --- decidim-budgets/spec/types/budget_type_spec.rb | 9 ++++++--- .../shared_examples/endorsable_interface_examples.rb | 4 +++- .../spec/types/initiative_api_type_spec.rb | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/decidim-budgets/spec/types/budget_type_spec.rb b/decidim-budgets/spec/types/budget_type_spec.rb index 4e1405c25070..e111c29df662 100644 --- a/decidim-budgets/spec/types/budget_type_spec.rb +++ b/decidim-budgets/spec/types/budget_type_spec.rb @@ -54,9 +54,12 @@ module Budgets let(:query) { "{ projects { id } }" } it "returns the budget projects" do - ids = response["projects"].map { |project| project["id"] } - expect(ids).to include(*model.projects.map(&:id).map(&:to_s)) - expect(ids).not_to include(*budget2.projects.map(&:id).map(&:to_s)) + ids = response["projects"].map { |project| project["id"].to_s } + model_project_ids = model.projects.map(&:id).map(&:to_s) + budget2_project_ids = budget2.projects.map(&:id).map(&:to_s) + + expect(ids).to match_array(model_project_ids) + expect(ids & budget2_project_ids).to be_empty end end end diff --git a/decidim-core/lib/decidim/core/test/shared_examples/endorsable_interface_examples.rb b/decidim-core/lib/decidim/core/test/shared_examples/endorsable_interface_examples.rb index aa7812c07668..6f27a69aaf0f 100644 --- a/decidim-core/lib/decidim/core/test/shared_examples/endorsable_interface_examples.rb +++ b/decidim-core/lib/decidim/core/test/shared_examples/endorsable_interface_examples.rb @@ -16,7 +16,9 @@ it "returns the endorsements this query has received" do endorsement_names = response["endorsements"].map { |endorsement| endorsement["name"] } - expect(endorsement_names).to include(*model.endorsements.map(&:author).map(&:name)) + expected_names = model.endorsements.map(&:author).map(&:name) + + expect(endorsement_names).to match_array(expected_names) end end end diff --git a/decidim-initiatives/spec/types/initiative_api_type_spec.rb b/decidim-initiatives/spec/types/initiative_api_type_spec.rb index 33851887a398..a5cd68916bc0 100644 --- a/decidim-initiatives/spec/types/initiative_api_type_spec.rb +++ b/decidim-initiatives/spec/types/initiative_api_type_spec.rb @@ -127,8 +127,8 @@ module Initiatives let(:initiatives) { create_list(:initiative, initiatives_type: model, organization: :current_organization) } it "returns the initiatives" do - ids = response["initiatives"].map { |item| item["id"] } - expect(ids).to include(*model.initiatives.map(&:id).map(&:to_s)) + ids = response["initiatives"].map { |item| item["id"].to_s } + expect(ids).to match_array(model.initiatives.map(&:id).map(&:to_s)) end end end