Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/graphql/mutations/users/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Update < BaseMutation
String,
required: false,
description: 'New password repeat for the user to check for typos, required if password is set.'
argument :readme, String, required: false, description: 'New readme for the user.'
argument :username, String, required: false, description: 'New username for the user.'

argument :mfa, Types::Input::MfaInput, required: false, description: 'The data of the mfa validation'
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/user_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class UserType < Types::BaseObject
authorize: :read_email
field :firstname, String, null: true, description: 'Firstname of the user'
field :lastname, String, null: true, description: 'Lastname of the user'
field :readme, String, null: true, description: 'Readme of the user'
field :username, String, null: false, description: 'Username of the user'

field :namespace_memberships, Types::NamespaceMemberType.connection_type,
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20260509183408_add_readme_to_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddReadmeToUser < Code0::ZeroTrack::Database::Migration[1.0]
def change
add_column :users, :readme, :text, null: true, limit: 5000
end
end
1 change: 1 addition & 0 deletions db/schema_migrations/20260509183408
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
80d9fdf9c4750b00b13bd15ea77bb053c3adf998670c519fb3f49b23ee029511
2 changes: 2 additions & 0 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ CREATE TABLE users (
admin boolean DEFAULT false NOT NULL,
totp_secret text,
email_verified_at timestamp with time zone,
readme text,
CONSTRAINT check_11461c37fb CHECK ((char_length(readme) <= 5000)),
CONSTRAINT check_3bedaaa612 CHECK ((char_length(email) <= 255)),
CONSTRAINT check_56606ce552 CHECK ((char_length(username) <= 50)),
CONSTRAINT check_60346c5299 CHECK ((char_length(lastname) <= 50)),
Expand Down
1 change: 1 addition & 0 deletions docs/graphql/mutation/usersupdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Update an existing user.
| `mfa` | [`MfaInput`](../input_object/mfainput.md) | The data of the mfa validation |
| `password` | [`String`](../scalar/string.md) | New password for the user. |
| `passwordRepeat` | [`String`](../scalar/string.md) | New password repeat for the user to check for typos, required if password is set. |
| `readme` | [`String`](../scalar/string.md) | New readme for the user. |
| `userId` | [`UserID!`](../scalar/userid.md) | ID of the user to update. |
| `username` | [`String`](../scalar/string.md) | New username for the user. |

Expand Down
1 change: 1 addition & 0 deletions docs/graphql/object/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Represents a user
| `mfaStatus` | [`MfaStatus`](../object/mfastatus.md) | Multi-factor authentication status of this user |
| `namespace` | [`Namespace`](../object/namespace.md) | Namespace of this user |
| `namespaceMemberships` | [`NamespaceMemberConnection!`](../object/namespacememberconnection.md) | Namespace Memberships of this user |
| `readme` | [`String`](../scalar/string.md) | Readme of the user |
| `sessions` | [`UserSessionConnection!`](../object/usersessionconnection.md) | Sessions of this user |
| `updatedAt` | [`Time!`](../scalar/time.md) | Time when this User was last updated |
| `userAbilities` | [`UserUserAbilities!`](../object/useruserabilities.md) | Abilities for the current user on this User |
Expand Down
1 change: 1 addition & 0 deletions spec/graphql/types/user_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace
firstname
lastname
readme
admin
namespaceMemberships
avatarPath
Expand Down
6 changes: 5 additions & 1 deletion spec/requests/graphql/mutation/users/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
user {
id
username
readme
admin
}
}
Expand All @@ -26,6 +27,7 @@
{
userId: current_user.to_global_id.to_s,
username: name,
readme: "# Hello\n\nThis is my profile README.",
}
end

Expand All @@ -38,16 +40,18 @@

it 'updates user' do
expect(graphql_data_at(:users_update, :user, :id)).to be_present
expect(graphql_data_at(:users_update, :user, :readme)).to be_present
user = SagittariusSchema.object_from_id(graphql_data_at(:users_update, :user, :id))

expect(user.username).to eq(input[:username])
expect(user.readme).to eq(input[:readme])

is_expected.to create_audit_event(
:user_updated,
author_id: current_user.id,
entity_id: user.id,
entity_type: 'User',
details: { username: input[:username] },
details: { username: input[:username], readme: input[:readme] },
target_id: user.id,
target_type: 'User'
)
Expand Down