diff --git a/app/controllers/costlog_controller.rb b/app/controllers/costlog_controller.rb index 645d36bd34..9c687d1a0c 100644 --- a/app/controllers/costlog_controller.rb +++ b/app/controllers/costlog_controller.rb @@ -97,7 +97,7 @@ class CostlogController < ApplicationController elsif @cost_entry.save flash[:notice] = t(:notice_cost_logged_successfully) - redirect_back_or_default action: 'index', project_id: @cost_entry.project + redirect_back_or_default action: 'index', work_package_id: @cost_entry.work_package.id else render action: 'edit' @@ -114,7 +114,7 @@ class CostlogController < ApplicationController elsif @cost_entry.save flash[:notice] = t(:notice_successful_update) - redirect_back_or_default action: 'index', project_id: @cost_entry.project + redirect_back_or_default action: 'index', work_package_id: @cost_entry.work_package.id else render action: 'edit' @@ -134,7 +134,7 @@ class CostlogController < ApplicationController redirect_to :back end rescue ::ActionController::RedirectBackError - redirect_to action: 'index', project_id: @cost_entry.project + redirect_to action: 'index', work_package_id: @cost_entry.work_package.id end def get_cost_type_unit_plural diff --git a/spec/controllers/costlog_controller_spec.rb b/spec/controllers/costlog_controller_spec.rb index de80d4433b..814c6cea76 100644 --- a/spec/controllers/costlog_controller_spec.rb +++ b/spec/controllers/costlog_controller_spec.rb @@ -282,7 +282,7 @@ describe CostlogController, type: :controller do end # is this really usefull, shouldn't it redirect to the creating work_package by default? - it { expect(response).to redirect_to(controller: 'costlog', action: 'index', project_id: project) } + it { expect(response).to redirect_to(controller: 'costlog', action: 'index', work_package_id: cost_entry.work_package.id) } it { expect(assigns(:cost_entry)).not_to be_new_record } it_should_behave_like 'assigns' it { expect(flash[:notice]).to eql('Unit cost logged successfully.') } @@ -507,7 +507,7 @@ describe CostlogController, type: :controller do put :update, params: params end - it { expect(response).to redirect_to(controller: 'costlog', action: 'index', project_id: project) } + it { expect(response).to redirect_to(controller: 'costlog', action: 'index', work_package_id: expected_work_package.id) } it { expect(assigns(:cost_entry)).to eq(cost_entry) } it_should_behave_like 'assigns' it { expect(assigns(:cost_entry)).not_to be_changed } diff --git a/spec/lib/api/v3/queries/schemas/cost_object_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/cost_object_dependency_representer_spec.rb index 5e761721d6..31b76541ad 100644 --- a/spec/lib/api/v3/queries/schemas/cost_object_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/cost_object_dependency_representer_spec.rb @@ -23,7 +23,7 @@ describe ::API::V3::Queries::Schemas::CostObjectFilterDependencyRepresenter, cle include ::API::V3::Utilities::PathHelper let(:project) { FactoryGirl.build_stubbed(:project) } - let(:filter) { OpenProject::Costs::WorkPackageFilter.new(context: project) } + let(:filter) { OpenProject::Costs::WorkPackageFilter.create!(context: project) } let(:form_embedded) { false } let(:instance) do