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
hide user status in api
ulferts3a4b05b92720
diff --git a/lib/api/v3/users/user_representer.rb b/lib/api/v3/users/user_representer.rbindex f3b4a49c21c..a4a4128d43d 100644--- a/lib/api/v3/users/user_representer.rb+++ b/lib/api/v3/users/user_representer.rb@@ -147,7 +147,8 @@ module APIproperty :status,getter: ->(*) { status_name },setter: ->(fragment:, represented:, **) { represented.status = User::STATUSES[fragment.to_sym] },- render_nil: true+ render_nil: true,+ cache_if: -> { current_user_is_admin_or_self }property :identity_url,exec_context: :decorator,diff --git a/spec/lib/api/v3/users/user_representer_spec.rb b/spec/lib/api/v3/users/user_representer_spec.rbindex 49649a746ab..88d8e96ef3f 100644--- a/spec/lib/api/v3/users/user_representer_spec.rb+++ b/spec/lib/api/v3/users/user_representer_spec.rb@@ -51,6 +51,7 @@ describe ::API::V3::Users::UserRepresenter dois_expected.not_to have_json_path('admin')is_expected.not_to have_json_path('updatedAt')is_expected.not_to have_json_path('createdAt')+ is_expected.not_to have_json_path('status')endend@@ -65,6 +66,7 @@ describe ::API::V3::Users::UserRepresenter dois_expected.to have_json_path('lastName')is_expected.to have_json_path('updatedAt')is_expected.to have_json_path('createdAt')+ is_expected.to have_json_path('status')is_expected.not_to have_json_path('admin')end@@ -79,6 +81,7 @@ describe ::API::V3::Users::UserRepresenter dois_expected.to have_json_path('firstName')is_expected.to have_json_path('lastName')is_expected.to have_json_path('name')+ is_expected.to have_json_path('status')endit_behaves_like 'has UTC ISO 8601 date and time' do@@ -113,6 +116,9 @@ describe ::API::V3::Users::UserRepresenter doenddescribe 'status' do+ # as only admin or self can see the status+ let(:current_user) { user }+it 'contains the name of the account status' dois_expected.to be_json_eql('active'.to_json).at_path('status')end