OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#41299] updated placeholder user api spec
Eric Schubert1d77a71a615b
diff --git a/docs/api/apiv3/components/schemas/group_model.yml b/docs/api/apiv3/components/schemas/group_model.ymlindex 00c68d09675..e5818c4f088 100644--- a/docs/api/apiv3/components/schemas/group_model.yml+++ b/docs/api/apiv3/components/schemas/group_model.yml@@ -4,8 +4,13 @@ allOf:- $ref: './principal_model.yml'- type: objectrequired:+ - _type- _embeddedproperties:+ _type:+ type: string+ enum:+ - Group_embedded:type: objectproperties:diff --git a/docs/api/apiv3/components/schemas/placeholder_user_model.yml b/docs/api/apiv3/components/schemas/placeholder_user_model.ymlindex 563758b9542..7193afd18cc 100644--- a/docs/api/apiv3/components/schemas/placeholder_user_model.yml+++ b/docs/api/apiv3/components/schemas/placeholder_user_model.yml@@ -3,7 +3,21 @@allOf:- $ref: './principal_model.yml'- type: object+ required:+ - _typeproperties:+ _type:+ type: string+ enum:+ - PlaceholderUser+ status:+ type: string+ description: |-+ The current activation status of the placeholder user.++ # Conditions++ - User has `manage_placeholder_user` permission globally_links:type: objectrequired:diff --git a/docs/api/apiv3/components/schemas/user_model.yml b/docs/api/apiv3/components/schemas/user_model.ymlindex 4cce47faa1a..97a850cb8a4 100644--- a/docs/api/apiv3/components/schemas/user_model.yml+++ b/docs/api/apiv3/components/schemas/user_model.yml@@ -4,8 +4,13 @@ allOf:- $ref: './principal_model.yml'- type: objectrequired:+ - _type- avatarproperties:+ _type:+ type: string+ enum:+ - Useravatar:type: stringformat: uridiff --git a/docs/api/apiv3/paths/group.yml b/docs/api/apiv3/paths/group.ymlindex 2e181bd0daa..f45dd4465fb 100644--- a/docs/api/apiv3/paths/group.yml+++ b/docs/api/apiv3/paths/group.yml@@ -17,7 +17,7 @@ delete:responses:'202':description: |-- Returned if the group was successfully deleted+ Returned if the group was marked for deletion.Note that the response body is empty as of now. In future versions of the API a body*might* be returned, indicating the progress of deletion.diff --git a/docs/api/apiv3/paths/placeholder_user.yml b/docs/api/apiv3/paths/placeholder_user.ymlindex 693abca4b10..f4609c601da 100644--- a/docs/api/apiv3/paths/placeholder_user.yml+++ b/docs/api/apiv3/paths/placeholder_user.yml@@ -15,8 +15,12 @@ delete:schema:type: integerresponses:- '204':- description: Returned if the placeholder user was deleted successfully.+ '202':+ description: |-+ Returned if the group was marked for deletion.++ Note that the response body is empty as of now. In future versions of the API a body+ *might* be returned, indicating the progress of deletion.'403':content:application/hal+json:diff --git a/lib/api/v3/placeholder_users/placeholder_user_representer.rb b/lib/api/v3/placeholder_users/placeholder_user_representer.rbindex 758b3f662ec..f783a96eda8 100644--- a/lib/api/v3/placeholder_users/placeholder_user_representer.rb+++ b/lib/api/v3/placeholder_users/placeholder_user_representer.rb@@ -55,10 +55,21 @@ module API}end+ property :status,+ getter: ->(*) { represented.status },+ setter: ->(fragment:, represented:, **) { represented.status = User.statuses[fragment.to_sym] },+ exec_context: :decorator,+ render_nil: true,+ cache_if: -> { current_user_can_manage? }+def _type'PlaceholderUser'end+ def current_user_can_see_date_properties?+ current_user_can_manage?+ end+def current_user_can_manage?current_user&.allowed_globally?(:manage_placeholder_user)enddiff --git a/lib/api/v3/placeholder_users/placeholder_users_api.rb b/lib/api/v3/placeholder_users/placeholder_users_api.rbindex 012293616a5..4b986ac0e5d 100644--- a/lib/api/v3/placeholder_users/placeholder_users_api.rb+++ b/lib/api/v3/placeholder_users/placeholder_users_api.rb@@ -49,7 +49,7 @@ module APIget &::API::V3::Utilities::Endpoints::Show.new(model: PlaceholderUser).mountpatch &::API::V3::Utilities::Endpoints::Update.new(model: PlaceholderUser).mount- delete &::API::V3::Utilities::Endpoints::Delete.new(model: PlaceholderUser, success_status: 204).mount+ delete &::API::V3::Utilities::Endpoints::Delete.new(model: PlaceholderUser, success_status: 202).mountendendenddiff --git a/lib/api/v3/principals/principal_representer.rb b/lib/api/v3/principals/principal_representer.rbindex c02ef31d3db..7a9c07b6a36 100644--- a/lib/api/v3/principals/principal_representer.rb+++ b/lib/api/v3/principals/principal_representer.rb@@ -63,10 +63,14 @@ module APIrender_nil: truedate_time_property :created_at,- cache_if: -> { current_user_is_admin_or_self }+ cache_if: -> { current_user_can_see_date_properties? }date_time_property :updated_at,- cache_if: -> { current_user_is_admin_or_self }+ cache_if: -> { current_user_can_see_date_properties? }++ def current_user_can_see_date_properties?+ current_user_is_admin_or_self+ enddef current_user_is_admin_or_selfcurrent_user_is_admin? || current_user_is_self?diff --git a/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rb b/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rbindex 3648a4f8441..030fa8d2c30 100644--- a/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rb+++ b/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rb@@ -140,15 +140,15 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderinglet(:value) { 'PlaceholderUser' }end- context 'as regular user' do- it_behaves_like 'property', :id do- let(:value) { placeholder_user.id }- end+ it_behaves_like 'property', :id do+ let(:value) { placeholder_user.id }+ end- it_behaves_like 'property', :name do- let(:value) { placeholder_user.name }- end+ it_behaves_like 'property', :name do+ let(:value) { placeholder_user.name }+ end+ context 'as regular user' doit 'hides the updatedAt property' doexpect(subject).not_to have_json_path('updatedAt')end@@ -158,15 +158,11 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingendend- context 'as admin' do- let(:current_user) { build_stubbed(:admin) }-- it_behaves_like 'property', :id do- let(:value) { placeholder_user.id }- end+ context 'if user is allowed to manage placeholder users' do+ let(:global_permissions) { [:manage_placeholder_user] }- it_behaves_like 'property', :name do- let(:value) { placeholder_user.name }+ it_behaves_like 'property', :status do+ let(:value) { 'active' }endit_behaves_like 'datetime property', :createdAt dodiff --git a/spec/requests/api/v3/placeholder_users/delete_resource_examples.rb b/spec/requests/api/v3/placeholder_users/delete_resource_examples.rbindex 562f0dbf73b..41478c989d3 100644--- a/spec/requests/api/v3/placeholder_users/delete_resource_examples.rb+++ b/spec/requests/api/v3/placeholder_users/delete_resource_examples.rb@@ -26,8 +26,8 @@# See COPYRIGHT and LICENSE files for more details.RSpec.shared_examples 'deletion allowed' do- it 'responds with 204' do- expect(last_response.status).to eq 204+ it 'responds with 202' do+ expect(last_response.status).to eq 202endit 'locks the account and mark for deletion' do