Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e45661a1
Commit
e45661a1
authored
Sep 22, 2021
by
Jonas Wälter
Committed by
Mayra Cabrera
Sep 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project Topic: Add avatar and description to the model
parent
d519789a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
0 deletions
+40
-0
app/models/projects/topic.rb
app/models/projects/topic.rb
+3
-0
db/migrate/20210915070423_add_avatar_and_description_to_topic.rb
...ate/20210915070423_add_avatar_and_description_to_topic.rb
+15
-0
db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb
...104446_add_text_limit_to_topics_description_and_avatar.rb
+15
-0
db/schema_migrations/20210915070423
db/schema_migrations/20210915070423
+1
-0
db/schema_migrations/20210920104446
db/schema_migrations/20210920104446
+1
-0
db/structure.sql
db/structure.sql
+4
-0
spec/models/projects/topic_spec.rb
spec/models/projects/topic_spec.rb
+1
-0
No files found.
app/models/projects/topic.rb
View file @
e45661a1
...
...
@@ -2,7 +2,10 @@
module
Projects
class
Topic
<
ApplicationRecord
include
Avatarable
validates
:name
,
presence:
true
,
uniqueness:
true
,
length:
{
maximum:
255
}
validates
:description
,
length:
{
maximum:
1024
}
has_many
:project_topics
,
class_name:
'Projects::ProjectTopic'
has_many
:projects
,
through: :project_topics
...
...
db/migrate/20210915070423_add_avatar_and_description_to_topic.rb
0 → 100644
View file @
e45661a1
# frozen_string_literal: true
class
AddAvatarAndDescriptionToTopic
<
Gitlab
::
Database
::
Migration
[
1.0
]
# rubocop:disable Migration/AddLimitToTextColumns
def
up
add_column
:topics
,
:avatar
,
:text
add_column
:topics
,
:description
,
:text
end
# rubocop:enable Migration/AddLimitToTextColumns
def
down
remove_column
:topics
,
:avatar
remove_column
:topics
,
:description
end
end
db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb
0 → 100644
View file @
e45661a1
# frozen_string_literal: true
class
AddTextLimitToTopicsDescriptionAndAvatar
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
add_text_limit
:topics
,
:description
,
1024
add_text_limit
:topics
,
:avatar
,
255
end
def
down
remove_text_limit
:topics
,
:avatar
remove_text_limit
:topics
,
:description
end
end
db/schema_migrations/20210915070423
0 → 100644
View file @
e45661a1
f11b237fab6b4133c73f1d6105d85c8db1548b6d0753b2fd96f613c90a4fa3c1
\ No newline at end of file
db/schema_migrations/20210920104446
0 → 100644
View file @
e45661a1
e7e9b13874081a7df42d07ccc9a54fb81973210d1c175cd995300f6339d57495
\ No newline at end of file
db/structure.sql
View file @
e45661a1
...
...
@@ -19613,6 +19613,10 @@ CREATE TABLE topics (
name text NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
avatar text,
description text,
CONSTRAINT check_26753fb43a CHECK ((char_length(avatar) <= 255)),
CONSTRAINT check_5d1a07c8c8 CHECK ((char_length(description) <= 1024)),
CONSTRAINT check_7a90d4c757 CHECK ((char_length(name) <= 255))
);
spec/models/projects/topic_spec.rb
View file @
e45661a1
...
...
@@ -18,5 +18,6 @@ RSpec.describe Projects::Topic do
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:name
)
}
it
{
is_expected
.
to
validate_length_of
(
:name
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_length_of
(
:description
).
is_at_most
(
1024
)
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment