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
add language to user api (#8812)
ulferts8175dc4acdd3
diff --git a/app/contracts/users/base_contract.rb b/app/contracts/users/base_contract.rbindex c9ffd7ead54..7d964b7e449 100644--- a/app/contracts/users/base_contract.rb+++ b/app/contracts/users/base_contract.rb@@ -39,6 +39,7 @@ module Usersattribute :nameattribute :mailattribute :admin+ attribute :languageattribute :auth_source_idattribute :identity_urldiff --git a/lib/api/v3/users/user_representer.rb b/lib/api/v3/users/user_representer.rbindex ad718cb1197..e48750284d2 100644--- a/lib/api/v3/users/user_representer.rb+++ b/lib/api/v3/users/user_representer.rb@@ -159,6 +159,13 @@ module APIrender_nil: true,cache_if: -> { current_user_is_admin_or_self }+ property :language,+ exec_context: :decorator,+ render_nil: false,+ getter: ->(*) { represented.language },+ setter: ->(fragment:, represented:, **) { represented.language = fragment },+ cache_if: -> { current_user_is_admin_or_self }+# Write-only propertiesproperty :password,diff --git a/spec/lib/api/v3/users/user_representer_spec.rb b/spec/lib/api/v3/users/user_representer_spec.rbindex 9b617a1672f..8d8cb722ddc 100644--- a/spec/lib/api/v3/users/user_representer_spec.rb+++ b/spec/lib/api/v3/users/user_representer_spec.rb@@ -54,6 +54,7 @@ describe ::API::V3::Users::UserRepresenter dois_expected.not_to have_json_path('createdAt')is_expected.not_to have_json_path('status')is_expected.not_to have_json_path('email')+ is_expected.not_to have_json_path('language')endend@@ -70,6 +71,7 @@ describe ::API::V3::Users::UserRepresenter dois_expected.to have_json_path('createdAt')is_expected.to have_json_path('status')is_expected.to have_json_path('email')+ is_expected.to have_json_path('language')is_expected.not_to have_json_path('admin')end@@ -87,6 +89,7 @@ describe ::API::V3::Users::UserRepresenter dois_expected.to have_json_path('status')is_expected.to have_json_path('email')is_expected.to have_json_path('admin')+ is_expected.to have_json_path('language')endit_behaves_like 'has UTC ISO 8601 date and time' dodiff --git a/spec/requests/api/v3/user/create_user_resource_spec.rb b/spec/requests/api/v3/user/create_user_resource_spec.rbindex 4e5d7e30f3b..b179c7002f5 100644--- a/spec/requests/api/v3/user/create_user_resource_spec.rb+++ b/spec/requests/api/v3/user/create_user_resource_spec.rb@@ -91,7 +91,8 @@ describe ::API::V3::Users::UsersAPI, type: :request dologin: 'myusername',firstName: 'Foo',lastName: 'Bar',- email: '[email protected]'+ email: '[email protected]',+ language: 'de'}}diff --git a/spec/requests/api/v3/user/update_user_resource_spec.rb b/spec/requests/api/v3/user/update_user_resource_spec.rbindex 6a7598d35b4..326b46b1e79 100644--- a/spec/requests/api/v3/user/update_user_resource_spec.rb+++ b/spec/requests/api/v3/user/update_user_resource_spec.rb@@ -69,8 +69,8 @@ describe ::API::V3::Users::UsersAPI, type: :request doenddescribe 'attribute change' do- let(:parameters) { { email: '[email protected]' } }- it_behaves_like 'successful update', mail: '[email protected]'+ let(:parameters) { { email: '[email protected]', language: 'de' } }+ it_behaves_like 'successful update', mail: '[email protected]', language: 'de'enddescribe 'password update' do