Merge pull request #855 from opf/fix/api_planning_elements_update_do_not_accept_journal_notes_3774

[FIX] API planning elements update do not accept journal notes 3774
pull/825/head
sschu 11 years ago
commit b3e0f44724
  1. 4
      app/controllers/api/v2/planning_elements_controller.rb
  2. 36
      spec/controllers/api/v2/planning_elements_controller_spec.rb

@ -92,7 +92,9 @@ module Api
def update
@planning_element = WorkPackage.find(params[:id])
@planning_element.attributes = permitted_params.planning_element
@planning_element.attributes = permitted_params.planning_element.except :note
@planning_element.add_journal(User.current, permitted_params.planning_element[:note])
successfully_updated = @planning_element.save

@ -601,6 +601,7 @@ describe Api::V2::PlanningElementsController do
describe 'update.xml' do
let(:project) { FactoryGirl.create(:project, :is_public => false) }
let(:work_package) { FactoryGirl.create(:work_package) }
become_admin
@ -621,6 +622,41 @@ describe Api::V2::PlanningElementsController do
it_should_behave_like "a controller action which needs project permissions"
end
describe 'empty' do
before do
put :update,
project_id: work_package.project_id,
id: work_package.id,
format: :xml
end
it { expect(response.status).to eq(400) }
end
describe 'notes' do
let(:note) { "A note set by API" }
before do
put :update,
project_id: work_package.project_id,
id: work_package.id,
planning_element: { note: note },
format: :xml
end
it { expect(response.status).to eq(204) }
describe 'journals' do
subject { work_package.reload.journals }
it { expect(subject.count).to eq(2) }
it { expect(subject.last.notes).to eq(note) }
it { expect(subject.last.user).to eq(User.current) }
end
end
describe 'with custom fields' do
let(:type) { Type.find_by_name("None") || FactoryGirl.create(:type_standard) }

Loading…
Cancel
Save