Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

attempt to stabilize flickering spec

ulferts98668125710d
diff --git a/modules/costs/spec/requests/api/work_packages/work_package_form_resource_spec.rb b/modules/costs/spec/requests/api/work_packages/work_package_form_resource_spec.rb
index 5509c1c7b58..1f263309cc2 100644
--- a/modules/costs/spec/requests/api/work_packages/work_package_form_resource_spec.rb
+++ b/modules/costs/spec/requests/api/work_packages/work_package_form_resource_spec.rb
@@ -104,7 +104,6 @@ describe 'API v3 Work package form resource', type: :request do
let(:target_budget) { FactoryBot.create(:cost_object, project: project) }
let(:other_budget) { FactoryBot.create(:cost_object, project: project) }
let(:budget_link) { api_v3_paths.budget target_budget.id }
- let(:other_budget_link) { api_v3_paths.budget other_budget.id }
let(:budget_parameter) { { _links: { costObject: { href: budget_link } } } }
let(:params) { valid_params.merge(budget_parameter) }
@@ -116,10 +115,12 @@ describe 'API v3 Work package form resource', type: :request do
include_context 'post request'
it 'should list the budgets' do
- expect(subject.body).to be_json_eql(budget_link.to_json)
- .at_path("#{links_path}/allowedValues/1/href")
- expect(subject.body).to be_json_eql(other_budget_link.to_json)
- .at_path("#{links_path}/allowedValues/0/href")
+ budgets = project.cost_objects
+
+ budgets.each_with_index do |budget, index|
+ expect(subject.body).to be_json_eql(api_v3_paths.budget(budget.id).to_json)
+ .at_path("#{links_path}/allowedValues/#{index}/href")
+ end
end
end