Fix default routes

pull/6827/head
Oliver Günther 7 years ago
parent e82530e0a9
commit 634b63e28e
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 6
      app/controllers/costlog_controller.rb
  2. 4
      spec/controllers/costlog_controller_spec.rb
  3. 2
      spec/lib/api/v3/queries/schemas/cost_object_dependency_representer_spec.rb

@ -97,7 +97,7 @@ class CostlogController < ApplicationController
elsif @cost_entry.save elsif @cost_entry.save
flash[:notice] = t(:notice_cost_logged_successfully) 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 else
render action: 'edit' render action: 'edit'
@ -114,7 +114,7 @@ class CostlogController < ApplicationController
elsif @cost_entry.save elsif @cost_entry.save
flash[:notice] = t(:notice_successful_update) 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 else
render action: 'edit' render action: 'edit'
@ -134,7 +134,7 @@ class CostlogController < ApplicationController
redirect_to :back redirect_to :back
end end
rescue ::ActionController::RedirectBackError 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 end
def get_cost_type_unit_plural def get_cost_type_unit_plural

@ -282,7 +282,7 @@ describe CostlogController, type: :controller do
end end
# is this really usefull, shouldn't it redirect to the creating work_package by default? # 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 { expect(assigns(:cost_entry)).not_to be_new_record }
it_should_behave_like 'assigns' it_should_behave_like 'assigns'
it { expect(flash[:notice]).to eql('Unit cost logged successfully.') } it { expect(flash[:notice]).to eql('Unit cost logged successfully.') }
@ -507,7 +507,7 @@ describe CostlogController, type: :controller do
put :update, params: params put :update, params: params
end 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 { expect(assigns(:cost_entry)).to eq(cost_entry) }
it_should_behave_like 'assigns' it_should_behave_like 'assigns'
it { expect(assigns(:cost_entry)).not_to be_changed } it { expect(assigns(:cost_entry)).not_to be_changed }

@ -23,7 +23,7 @@ describe ::API::V3::Queries::Schemas::CostObjectFilterDependencyRepresenter, cle
include ::API::V3::Utilities::PathHelper include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) } 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(:form_embedded) { false }
let(:instance) do let(:instance) do

Loading…
Cancel
Save