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

[31739] Use withCredentials: true in budget forms

Oliver Günther4bd704a3e568
diff --git a/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts b/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts
index 27a161cdd6b..e824b3bdaf6 100644
--- a/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts
+++ b/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts
@@ -86,7 +86,8 @@ export class RemoteFieldUpdaterComponent implements OnInit {
{
params: params,
headers: headers,
- responseType: (this.htmlMode ? 'text' : 'json') as any
+ responseType: (this.htmlMode ? 'text' : 'json') as any,
+ withCredentials: true
}
);
}
diff --git a/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.ts b/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.ts
index e0e3c1df817..93f781395ce 100644
--- a/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.ts
+++ b/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.ts
@@ -80,7 +80,13 @@ export class CostBudgetSubformAugmentService {
let request = this.buildRefreshRequest(row, row_identifier);
this.http
- .post(el.attr('update-url')!, request, { headers: { 'Accept': 'application/json' } })
+ .post(
+ el.attr('update-url')!,
+ request,
+ {
+ headers: { 'Accept': 'application/json' },
+ withCredentials: true
+ })
.subscribe(
(data:any) => {
_.each(data, (val:string, selector:string) => {
diff --git a/modules/costs/spec/features/budgets/add_budget_spec.rb b/modules/costs/spec/features/budgets/add_budget_spec.rb
index 2b68c2720b9..7649627b90d 100644
--- a/modules/costs/spec/features/budgets/add_budget_spec.rb
+++ b/modules/costs/spec/features/budgets/add_budget_spec.rb
@@ -37,6 +37,38 @@ describe 'adding a new budget', type: :feature, js: true do
expect(page).to have_content "Subject"
end
+ describe 'with multiple cost types' do
+ let!(:cost_type_1) do
+ FactoryBot.create :cost_type, name: 'Post-war', unit: 'cap', unit_plural: 'caps'
+ end
+
+ let!(:cost_type_2) do
+ FactoryBot.create :cost_type, name: 'Foobar', unit: 'bar', unit_plural: 'bars'
+ end
+
+
+ it 'can switch between them' do
+ visit projects_cost_objects_path(project)
+
+ click_on("Add budget")
+ expect(page).to have_content "New budget"
+
+ fill_in 'Subject', with: 'My subject'
+ fill_in 'cost_object_new_material_budget_item_attributes_0_units', with: 15
+
+ # change cost type
+ select 'Foobar', from: 'cost_object_new_material_budget_item_attributes_0_cost_type_id'
+
+ click_on "Create"
+
+ expect(page).to have_content "Successful creation"
+ expect(page).to have_content "My subject"
+
+ expect(page).to have_selector('.material_budget_items td.units', text: '15.00')
+ expect(page).to have_selector('.material_budget_items td', text: 'Foobar')
+ end
+ end
+
it 'create the budget' do
visit new_projects_cost_object_path(project)