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
c3f45828
Commit
c3f45828
authored
Jan 21, 2022
by
Donald Cook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated label description to accept empty string
Removed unneeded lookup hack
parent
d7793c0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
23 deletions
+12
-23
app/models/label.rb
app/models/label.rb
+6
-2
lib/gitlab/import_export/group/object_builder.rb
lib/gitlab/import_export/group/object_builder.rb
+0
-9
spec/lib/gitlab/import_export/group/object_builder_spec.rb
spec/lib/gitlab/import_export/group/object_builder_spec.rb
+0
-12
spec/models/label_spec.rb
spec/models/label_spec.rb
+6
-0
No files found.
app/models/label.rb
View file @
c3f45828
...
...
@@ -217,11 +217,15 @@ class Label < ApplicationRecord
end
def
title
=
(
value
)
write_attribute
(
:title
,
sanitize_value
(
value
))
if
value
.
present?
super
if
value
.
blank?
write_attribute
(
:title
,
sanitize_value
(
value
))
end
def
description
=
(
value
)
write_attribute
(
:description
,
sanitize_value
(
value
))
if
value
.
present?
return
super
if
value
.
blank?
write_attribute
(
:description
,
sanitize_value
(
value
))
end
##
...
...
lib/gitlab/import_export/group/object_builder.rb
View file @
c3f45828
...
...
@@ -13,21 +13,12 @@ module Gitlab
super
@group
=
@attributes
[
'group'
]
update_description
end
private
attr_reader
:group
# Convert description empty string to nil
# due to existing object being saved with description: nil
# Which makes object lookup to fail since nil != ''
def
update_description
attributes
[
'description'
]
=
nil
if
attributes
[
'description'
]
==
''
end
def
where_clauses
[
where_clause_base
,
...
...
spec/lib/gitlab/import_export/group/object_builder_spec.rb
View file @
c3f45828
...
...
@@ -51,16 +51,4 @@ RSpec.describe Gitlab::ImportExport::Group::ObjectBuilder do
expect
(
milestone
.
persisted?
).
to
be
true
end
end
describe
'#initialize'
do
context
'when attributes contain description as empty string'
do
let
(
:attributes
)
{
base_attributes
.
merge
(
'description'
=>
''
)
}
it
'converts empty string to nil'
do
builder
=
described_class
.
new
(
Label
,
attributes
)
expect
(
builder
.
send
(
:attributes
)).
to
include
({
'description'
=>
nil
})
end
end
end
end
spec/models/label_spec.rb
View file @
c3f45828
...
...
@@ -104,6 +104,12 @@ RSpec.describe Label do
label
=
described_class
.
new
(
description:
'<b>foo & bar?</b>'
)
expect
(
label
.
description
).
to
eq
(
'foo & bar?'
)
end
it
'accepts an empty string'
do
label
=
described_class
.
new
(
title:
'foo'
,
description:
'bar'
)
label
.
update!
(
description:
''
)
expect
(
label
.
description
).
to
eq
(
''
)
end
end
describe
'priorization'
do
...
...
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