Skip to content

Commit 300765b

Browse files
committed
fix some suggestions from copilot
1 parent 749ceb5 commit 300765b

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

app/graphql/types/namespace_role_type.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class NamespaceRoleType < BaseObject
1515
field :assigned_projects, Types::NamespaceProjectType.connection_type,
1616
description: 'The projects this role is assigned to'
1717

18+
field :assigned_members, Types::NamespaceProjectType.connection_type,
19+
description: 'The projects this role is assigned to'
20+
1821
expose_abilities %i[
1922
assign_role_abilities
2023
assign_role_projects

app/services/error_code.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def self.error_codes
6464
namespace_project_not_found: { description: 'The namespace project with the given identifier was not found' },
6565
namespace_member_not_found: { description: 'The namespace member with the given identifier was not found' },
6666
license_not_found: { description: 'The namespace license with the given identifier was not found' },
67+
flow_type_not_found: { description: 'The flow type with the given identifier was not found' },
6768
primary_level_not_found: { description: '', deprecation_reason: 'Outdated concept' },
6869
secondary_level_not_found: { description: '', deprecation_reason: 'Outdated concept' },
6970
tertiary_level_exceeds_parameters: { description: '', deprecation_reason: 'Outdated concept' },

app/services/files/upload_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def execute
2727
object.send(attachment_name).attach attachment
2828

2929
unless object.save
30-
ServiceResponse.error(message: 'Failed to save object', error_code: :invalid_attachment,
31-
details: object.errors)
30+
return ServiceResponse.error(message: 'Failed to save object', error_code: :invalid_attachment,
31+
details: object.errors)
3232
end
3333

3434
AuditService.audit(

app/services/users/identity/register_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def execute
5757
end
5858
user_session = UserSession.create(user: user)
5959
unless user_session.persisted?
60-
t.rollback_and_return! ServiceResponse.error(message: :invalid_user_session,
60+
t.rollback_and_return! ServiceResponse.error(error_code: :invalid_user_session,
6161
details: user_session.errors)
6262
end
6363

app/services/users/logout_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def execute
2323
ServiceResponse.success(message: 'Logged out session', payload: user_session)
2424
else
2525
logger.warn(message: 'Failed to log out session', session_id: user_session.id, user_id: user_session.user_id)
26-
ServiceResponse.error(error_code: user_session.errors)
26+
ServiceResponse.error(error_code: :invalid_user_session, details: user_session.errors)
2727
end
2828
end
2929
end

spec/services/users/identity/register_service_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# frozen_string_literal: true
1+
# frozen_string_literal: true
22

33
require 'rails_helper'
44

@@ -58,7 +58,7 @@ def setup_identity_provider(identity)
5858

5959
shared_examples 'invalid user' do |error_code|
6060
it { is_expected.not_to be_success }
61-
it { expect(service_response[:error_code]).to eq(error_code) }
61+
it { expect(service_response.payload[:error_code]).to eq(error_code) }
6262
it { expect { service_response }.not_to create_audit_event }
6363
end
6464

@@ -183,7 +183,7 @@ def setup_identity_provider(identity)
183183
end
184184

185185
it { is_expected.not_to be_success }
186-
it { expect(service_response[:error_code]).to eq(:invalid_user_identity) }
186+
it { expect(service_response.payload[:error_code]).to eq(:invalid_user_identity) }
187187
it { expect { service_response }.not_to create_audit_event }
188188
it { expect(service_response.payload[:details].full_messages).to include('Identifier has already been taken') }
189189
end

spec/support/helpers/graphql_helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def error_query
7979
errors {
8080
errorCode
8181
details {
82-
...on ActiveModelError { attribute type }
83-
...on MessageError { message }
82+
...on ActiveModelError { attribute type }
83+
...on MessageError { message }
8484
}
8585
}
8686
)

0 commit comments

Comments
 (0)