diff --git a/spec/requests/api/v3/user/update_form_resource_spec.rb b/spec/requests/api/v3/user/update_form_resource_spec.rb index c6c7fa81fc5b..18ddbb8f1c14 100644 --- a/spec/requests/api/v3/user/update_form_resource_spec.rb +++ b/spec/requests/api/v3/user/update_form_resource_spec.rb @@ -92,6 +92,38 @@ end end + describe 'with a non-writable status' do + let(:payload) do + { + "status": 'locked' + } + end + + it 'returns an invalid form', :aggregate_failures do + expect(response.status).to eq(200) + expect(response.body).to be_json_eql('Form'.to_json).at_path('_type') + + expect(body) + .to be_json_eql('locked'.to_json) + .at_path('_embedded/payload/status') + + expect(subject.body) + .to have_json_size(1) + .at_path('_embedded/validationErrors') + + expect(subject.body) + .to have_json_path('_embedded/validationErrors/status') + + expect(body) + .to be_json_eql('urn:openproject-org:api:v3:errors:PropertyIsReadOnly'.to_json) + .at_path('_embedded/validationErrors/status/errorIdentifier') + + # Does not change the user's status + user.reload + expect(user.status).to eq 'active' + end + end + describe 'with an empty firstname' do let(:payload) do {