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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
252e93c9
Commit
252e93c9
authored
Jul 31, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Title of a list is either the label name, or Backlog, or Done
parent
b07c5f23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
app/models/list.rb
app/models/list.rb
+6
-0
spec/models/list_spec.rb
spec/models/list_spec.rb
+24
-0
No files found.
app/models/list.rb
View file @
252e93c9
...
@@ -7,4 +7,10 @@ class List < ActiveRecord::Base
...
@@ -7,4 +7,10 @@ class List < ActiveRecord::Base
validates
:board
,
:list_type
,
presence:
true
validates
:board
,
:list_type
,
presence:
true
validates
:label
,
:position
,
presence:
true
,
if: :label?
validates
:label
,
:position
,
presence:
true
,
if: :label?
validates
:position
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
},
if: :label?
validates
:position
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
},
if: :label?
delegate
:name
,
to: :label
,
allow_nil:
true
,
prefix:
true
def
title
label?
?
label_name
:
list_type
.
humanize
end
end
end
spec/models/list_spec.rb
View file @
252e93c9
...
@@ -6,6 +6,10 @@ describe List do
...
@@ -6,6 +6,10 @@ describe List do
it
{
is_expected
.
to
belong_to
(
:label
)
}
it
{
is_expected
.
to
belong_to
(
:label
)
}
end
end
describe
'delegate methods'
do
it
{
is_expected
.
to
delegate_method
(
:name
).
to
(
:label
).
with_prefix
}
end
describe
'validations'
do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:board
)
}
it
{
is_expected
.
to
validate_presence_of
(
:board
)
}
it
{
is_expected
.
to
validate_presence_of
(
:label
)
}
it
{
is_expected
.
to
validate_presence_of
(
:label
)
}
...
@@ -27,4 +31,24 @@ describe List do
...
@@ -27,4 +31,24 @@ describe List do
it
{
is_expected
.
not_to
validate_presence_of
(
:position
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:position
)
}
end
end
end
end
describe
'#title'
do
it
'returns label name when list_type is set to label'
do
subject
.
list_type
=
:label
subject
.
label
=
Label
.
new
(
name:
'Development'
)
expect
(
subject
.
title
).
to
eq
'Development'
end
it
'returns Backlog when list_type is set to backlog'
do
subject
.
list_type
=
:backlog
expect
(
subject
.
title
).
to
eq
'Backlog'
end
it
'returns Done when list_type is set to done'
do
subject
.
list_type
=
:done
expect
(
subject
.
title
).
to
eq
'Done'
end
end
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