From fd99aa33706ed2e3ffac93f3c09d20ae228896d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 15 Mar 2021 14:35:18 +0100 Subject: [PATCH] Add test for changing status --- .../api/v3/user/update_form_resource_spec.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 {