diff --git a/lib/api/v3/users/user_representer.rb b/lib/api/v3/users/user_representer.rb index ff2e3a4ace2b..fd96edb90761 100644 --- a/lib/api/v3/users/user_representer.rb +++ b/lib/api/v3/users/user_representer.rb @@ -137,7 +137,7 @@ class UserRepresenter < ::API::V3::Principals::PrincipalRepresenter getter: ->(*) { represented.mail }, setter: ->(fragment:, represented:, **) { represented.mail = fragment }, exec_context: :decorator, - cache_if: -> { !represented.pref.hide_mail || represented.new_record? } + cache_if: -> { !represented.pref.hide_mail || represented.new_record? || current_user_can_manage? } property :avatar, exec_context: :decorator, @@ -149,10 +149,7 @@ class UserRepresenter < ::API::V3::Principals::PrincipalRepresenter setter: ->(fragment:, represented:, **) { represented.status = User.statuses[fragment.to_sym] }, exec_context: :decorator, render_nil: true, - cache_if: -> { - binding.pry - current_user_can_manage? - } + cache_if: -> { current_user_can_manage? } property :identity_url, exec_context: :decorator, diff --git a/spec/lib/api/v3/principals/principal_representer_factory_spec.rb b/spec/lib/api/v3/principals/principal_representer_factory_spec.rb index a8f4e3de637d..d6746bfc07ff 100644 --- a/spec/lib/api/v3/principals/principal_representer_factory_spec.rb +++ b/spec/lib/api/v3/principals/principal_representer_factory_spec.rb @@ -83,7 +83,7 @@ class TestRepresenter < ::API::Decorators::Single describe '.create_link_lambda' do subject(:link) do TestRepresenter - .new(represented, current_user: nil) + .new(represented, current_user: current_user) .instance_exec(&described_class.create_link_lambda('association')) end @@ -127,7 +127,7 @@ class TestRepresenter < ::API::Decorators::Single describe '.create_getter_lambda' do subject(:getter) do TestRepresenter - .new(represented, current_user: nil, embed_links: embed_links) + .new(represented, current_user: current_user, embed_links: embed_links) .instance_exec(&described_class.create_getter_lambda('association')) end diff --git a/spec/requests/api/v3/user/create_user_common_examples.rb b/spec/requests/api/v3/user/create_user_common_examples.rb index 9403287010e7..5ecd186251ce 100644 --- a/spec/requests/api/v3/user/create_user_common_examples.rb +++ b/spec/requests/api/v3/user/create_user_common_examples.rb @@ -70,7 +70,7 @@ expect(errors.count).to eq(5) expect(errors.collect { |el| el['_embedded']['details']['attribute'] }) - .to contain_exactly('password', 'login', 'firstname', 'lastname', 'email') + .to contain_exactly('password', 'login', 'firstName', 'lastName', 'email') expect(last_response.body) .to be_json_eql('urn:openproject-org:api:v3:errors:MultipleErrors'.to_json) @@ -131,7 +131,7 @@ expect(errors.count).to eq 4 attributes = errors.map { |error| error.dig('_embedded', 'details', 'attribute') } - expect(attributes).to contain_exactly('login', 'firstname', 'lastname', 'email') + expect(attributes).to contain_exactly('login', 'firstName', 'lastName', 'email') end end end