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
2956f5f5
Commit
2956f5f5
authored
Feb 17, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Returns Milestone::Upcoming for boards with this milestone
parent
3e9820dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
app/models/board.rb
app/models/board.rb
+9
-1
spec/models/board_spec.rb
spec/models/board_spec.rb
+25
-0
No files found.
app/models/board.rb
View file @
2956f5f5
class
Board
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:milestone
has_many
:lists
,
->
{
order
(
:list_type
,
:position
)
},
dependent: :delete_all
belongs_to
:milestone
validates
:name
,
:project
,
presence:
true
def
done_list
lists
.
merge
(
List
.
done
).
take
end
def
milestone
if
milestone_id
===
Milestone
::
Upcoming
.
id
Milestone
::
Upcoming
else
super
end
end
end
spec/models/board_spec.rb
View file @
2956f5f5
...
...
@@ -3,6 +3,8 @@ require 'rails_helper'
describe
Board
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:milestone
)
}
it
{
is_expected
.
to
have_many
(
:lists
).
order
(
list_type: :asc
,
position: :asc
).
dependent
(
:delete_all
)
}
end
...
...
@@ -10,4 +12,27 @@ describe Board do
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
end
describe
'milestone'
do
subject
{
described_class
.
new
}
it
'returns Milestone::Upcoming for upcoming milestone id'
do
subject
.
milestone_id
=
Milestone
::
Upcoming
.
id
expect
(
subject
.
milestone
).
to
eq
Milestone
::
Upcoming
end
it
'returns milestone for valid milestone id'
do
milestone
=
create
(
:milestone
)
subject
.
milestone_id
=
milestone
.
id
expect
(
subject
.
milestone
).
to
eq
milestone
end
it
'returns nil for invalid milestone id'
do
subject
.
milestone_id
=
-
1
expect
(
subject
.
milestone
).
to
be_nil
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