diff --git a/app/graphql/types/namespace_role_type.rb b/app/graphql/types/namespace_role_type.rb index 15d9e5d8..f880abf0 100644 --- a/app/graphql/types/namespace_role_type.rb +++ b/app/graphql/types/namespace_role_type.rb @@ -15,6 +15,9 @@ class NamespaceRoleType < BaseObject field :assigned_projects, Types::NamespaceProjectType.connection_type, description: 'The projects this role is assigned to' + field :assigned_members, Types::NamespaceProjectType.connection_type, + description: 'The projects this role is assigned to' + expose_abilities %i[ assign_role_abilities assign_role_projects diff --git a/app/services/error_code.rb b/app/services/error_code.rb index 29c7c867..1dddcf7c 100644 --- a/app/services/error_code.rb +++ b/app/services/error_code.rb @@ -64,6 +64,7 @@ def self.error_codes namespace_project_not_found: { description: 'The namespace project with the given identifier was not found' }, namespace_member_not_found: { description: 'The namespace member with the given identifier was not found' }, license_not_found: { description: 'The namespace license with the given identifier was not found' }, + flow_type_not_found: { description: 'The flow type with the given identifier was not found' }, primary_level_not_found: { description: '', deprecation_reason: 'Outdated concept' }, secondary_level_not_found: { description: '', deprecation_reason: 'Outdated concept' }, tertiary_level_exceeds_parameters: { description: '', deprecation_reason: 'Outdated concept' }, diff --git a/app/services/files/upload_service.rb b/app/services/files/upload_service.rb index df68acf7..0cc400c3 100644 --- a/app/services/files/upload_service.rb +++ b/app/services/files/upload_service.rb @@ -27,8 +27,8 @@ def execute object.send(attachment_name).attach attachment unless object.save - ServiceResponse.error(message: 'Failed to save object', error_code: :invalid_attachment, - details: object.errors) + return ServiceResponse.error(message: 'Failed to save object', error_code: :invalid_attachment, + details: object.errors) end AuditService.audit( diff --git a/app/services/users/identity/register_service.rb b/app/services/users/identity/register_service.rb index 00812541..c6b592cb 100644 --- a/app/services/users/identity/register_service.rb +++ b/app/services/users/identity/register_service.rb @@ -57,7 +57,7 @@ def execute end user_session = UserSession.create(user: user) unless user_session.persisted? - t.rollback_and_return! ServiceResponse.error(message: :invalid_user_session, + t.rollback_and_return! ServiceResponse.error(error_code: :invalid_user_session, details: user_session.errors) end diff --git a/app/services/users/logout_service.rb b/app/services/users/logout_service.rb index 201b3804..5f4759c0 100644 --- a/app/services/users/logout_service.rb +++ b/app/services/users/logout_service.rb @@ -23,7 +23,7 @@ def execute ServiceResponse.success(message: 'Logged out session', payload: user_session) else logger.warn(message: 'Failed to log out session', session_id: user_session.id, user_id: user_session.user_id) - ServiceResponse.error(error_code: user_session.errors) + ServiceResponse.error(error_code: :invalid_user_session, details: user_session.errors) end end end diff --git a/spec/services/users/identity/register_service_spec.rb b/spec/services/users/identity/register_service_spec.rb index 8bab4f8d..18472dac 100644 --- a/spec/services/users/identity/register_service_spec.rb +++ b/spec/services/users/identity/register_service_spec.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true + # frozen_string_literal: true require 'rails_helper' @@ -58,7 +58,7 @@ def setup_identity_provider(identity) shared_examples 'invalid user' do |error_code| it { is_expected.not_to be_success } - it { expect(service_response[:error_code]).to eq(error_code) } + it { expect(service_response.payload[:error_code]).to eq(error_code) } it { expect { service_response }.not_to create_audit_event } end @@ -183,7 +183,7 @@ def setup_identity_provider(identity) end it { is_expected.not_to be_success } - it { expect(service_response[:error_code]).to eq(:invalid_user_identity) } + it { expect(service_response.payload[:error_code]).to eq(:invalid_user_identity) } it { expect { service_response }.not_to create_audit_event } it { expect(service_response.payload[:details].full_messages).to include('Identifier has already been taken') } end diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 979f0fae..3b8c78cc 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -78,10 +78,10 @@ def error_query %( errors { errorCode - details { - ...on ActiveModelError { attribute type } - ...on MessageError { message } - } + details { + ...on ActiveModelError { attribute type } + ...on MessageError { message } + } } ) end