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
Jérome Perrin
gitlab-ce
Commits
4b75c750
Commit
4b75c750
authored
Jul 31, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The lists: Backlog, and Done cannot be destroyed
parent
252e93c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
app/models/board.rb
app/models/board.rb
+1
-1
app/models/list.rb
app/models/list.rb
+8
-0
spec/models/board_spec.rb
spec/models/board_spec.rb
+1
-1
spec/models/list_spec.rb
spec/models/list_spec.rb
+21
-0
No files found.
app/models/board.rb
View file @
4b75c750
class
Board
<
ActiveRecord
::
Base
belongs_to
:project
has_many
:lists
,
->
{
order
(
:list_type
,
:position
)
},
dependent: :de
stroy
has_many
:lists
,
->
{
order
(
:list_type
,
:position
)
},
dependent: :de
lete_all
validates
:project
,
presence:
true
end
app/models/list.rb
View file @
4b75c750
...
...
@@ -10,7 +10,15 @@ class List < ActiveRecord::Base
delegate
:name
,
to: :label
,
allow_nil:
true
,
prefix:
true
before_destroy
:can_be_destroyed
,
unless: :label?
def
title
label?
?
label_name
:
list_type
.
humanize
end
private
def
can_be_destroyed
false
end
end
spec/models/board_spec.rb
View file @
4b75c750
...
...
@@ -3,7 +3,7 @@ require 'rails_helper'
describe
Board
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
have_many
(
:lists
).
order
(
list_type: :asc
,
position: :asc
).
dependent
(
:de
stroy
)
}
it
{
is_expected
.
to
have_many
(
:lists
).
order
(
list_type: :asc
,
position: :asc
).
dependent
(
:de
lete_all
)
}
end
describe
'validations'
do
...
...
spec/models/list_spec.rb
View file @
4b75c750
...
...
@@ -31,6 +31,27 @@ describe List do
it
{
is_expected
.
not_to
validate_presence_of
(
:position
)
}
end
end
describe
'#destroy'
do
it
'can be destroyed when when list_type is set to label'
do
subject
=
create
(
:label_list
)
expect
(
subject
.
destroy
).
to
be_truthy
end
it
'can not be destroyed when list_type is set to backlog'
do
subject
=
create
(
:backlog_list
)
expect
(
subject
.
destroy
).
to
be_falsey
end
it
'can not be destroyed when when list_type is set to done'
do
subject
=
create
(
:done_list
)
expect
(
subject
.
destroy
).
to
be_falsey
end
end
describe
'#title'
do
it
'returns label name when list_type is set to label'
do
subject
.
list_type
=
:label
...
...
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