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
52badfa0
Commit
52badfa0
authored
Sep 22, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial models/associations
parent
205fdac9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
48 deletions
+114
-48
app/models/board_filter.rb
app/models/board_filter.rb
+21
-0
app/models/board_filter_label.rb
app/models/board_filter_label.rb
+8
-0
app/models/board_filter_label_spec.rb
app/models/board_filter_label_spec.rb
+16
-0
ee/app/models/ee/board.rb
ee/app/models/ee/board.rb
+2
-11
spec/ee/spec/models/ee/board_spec.rb
spec/ee/spec/models/ee/board_spec.rb
+0
-37
spec/factories/board_filter_labels.rb
spec/factories/board_filter_labels.rb
+6
-0
spec/factories/board_filters.rb
spec/factories/board_filters.rb
+8
-0
spec/models/board_filter_spec.rb
spec/models/board_filter_spec.rb
+53
-0
No files found.
app/models/board_filter.rb
0 → 100644
View file @
52badfa0
class
BoardFilter
<
ActiveRecord
::
Base
belongs_to
:board
belongs_to
:milestone
belongs_to
:author
,
class_name:
'User'
belongs_to
:assignee
,
class_name:
'User'
has_many
:board_filter_labels
has_many
:labels
,
through: :board_filter_labels
validates
:board
,
presence:
true
def
milestone
return
nil
unless
board
.
parent
.
feature_available?
(
:scoped_issue_board
)
if
milestone_id
==
::
Milestone
::
Upcoming
.
id
::
Milestone
::
Upcoming
else
super
end
end
end
app/models/board_filter_label.rb
0 → 100644
View file @
52badfa0
class
BoardFilterLabel
<
ActiveRecord
::
Base
belongs_to
:board_filter
belongs_to
:label
validates
:board_filter
,
presence:
true
validates
:label
,
presence:
true
validates
:board_filter
,
uniqueness:
{
scope: :label_id
}
end
\ No newline at end of file
app/models/board_filter_label_spec.rb
0 → 100644
View file @
52badfa0
require
'spec_helper'
describe
BoardFilterLabel
,
type: :model
do
describe
'validations'
do
subject
{
create
(
:board_filter_label
)
}
it
{
is_expected
.
to
validate_presence_of
(
:board_filter
)
}
it
{
is_expected
.
to
validate_presence_of
(
:label
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:board_filter
).
scoped_to
(
:label_id
)
}
end
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:board_filter
)
}
it
{
is_expected
.
to
belong_to
(
:label
)
}
end
end
\ No newline at end of file
ee/app/models/ee/board.rb
View file @
52badfa0
...
...
@@ -3,7 +3,8 @@ module EE
extend
ActiveSupport
::
Concern
prepended
do
belongs_to
:milestone
has_one
:board_filter
belongs_to
:group
validates
:name
,
presence:
true
...
...
@@ -14,16 +15,6 @@ module EE
!
group
end
def
milestone
return
nil
unless
parent
.
feature_available?
(
:issue_board_milestone
)
if
milestone_id
==
::
Milestone
::
Upcoming
.
id
::
Milestone
::
Upcoming
else
super
end
end
def
parent
@parent
||=
group
||
project
end
...
...
spec/ee/spec/models/ee/board_spec.rb
View file @
52badfa0
...
...
@@ -16,41 +16,4 @@ describe Board do
it
{
is_expected
.
not_to
validate_presence_of
(
:group
)
}
end
end
describe
'milestone'
do
subject
(
:board
)
{
build
(
:board
)
}
context
'when the feature is available'
do
before
do
stub_licensed_features
(
issue_board_milestone:
true
)
end
it
'returns Milestone::Upcoming for upcoming milestone id'
do
board
.
milestone_id
=
Milestone
::
Upcoming
.
id
expect
(
board
.
milestone
).
to
eq
Milestone
::
Upcoming
end
it
'returns milestone for valid milestone id'
do
milestone
=
create
(
:milestone
)
board
.
milestone_id
=
milestone
.
id
expect
(
board
.
milestone
).
to
eq
milestone
end
it
'returns nil for invalid milestone id'
do
board
.
milestone_id
=
-
1
expect
(
board
.
milestone
).
to
be_nil
end
end
it
'returns nil when the feature is not available'
do
stub_licensed_features
(
issue_board_milestone:
false
)
milestone
=
create
(
:milestone
)
board
.
milestone_id
=
milestone
.
id
expect
(
board
.
milestone
).
to
be_nil
end
end
end
spec/factories/board_filter_labels.rb
0 → 100644
View file @
52badfa0
FactoryGirl
.
define
do
factory
:board_filter_label
do
association
:board_filter
association
:label
end
end
spec/factories/board_filters.rb
0 → 100644
View file @
52badfa0
FactoryGirl
.
define
do
factory
:board_filter
do
association
:board
association
:milestone
association
:author
,
factory: :user
association
:assignee
,
factory: :user
end
end
spec/models/board_filter_spec.rb
0 → 100644
View file @
52badfa0
require
'spec_helper'
describe
BoardFilter
,
type: :model
do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:board
)
}
end
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:board
)
}
it
{
is_expected
.
to
belong_to
(
:milestone
)
}
it
{
is_expected
.
to
belong_to
(
:author
).
class_name
(
'User'
)
}
it
{
is_expected
.
to
belong_to
(
:assignee
).
class_name
(
'User'
)
}
it
{
is_expected
.
to
have_many
(
:board_filter_labels
)
}
it
{
is_expected
.
to
have_many
(
:labels
).
through
(
:board_filter_labels
)
}
end
describe
'milestone'
do
subject
(
:board_filter
)
{
build
(
:board_filter
)
}
context
'when the feature is available'
do
before
do
stub_licensed_features
(
scoped_issue_board:
true
)
end
it
'returns Milestone::Upcoming for upcoming milestone id'
do
board_filter
.
milestone_id
=
Milestone
::
Upcoming
.
id
expect
(
board_filter
.
milestone
).
to
eq
Milestone
::
Upcoming
end
it
'returns milestone for valid milestone id'
do
milestone
=
create
(
:milestone
)
board_filter
.
milestone_id
=
milestone
.
id
expect
(
board_filter
.
milestone
).
to
eq
milestone
end
it
'returns nil for invalid milestone id'
do
board_filter
.
milestone_id
=
-
1
expect
(
board_filter
.
milestone
).
to
be_nil
end
end
it
'returns nil when the feature is not available'
do
stub_licensed_features
(
scoped_issue_board:
false
)
milestone
=
create
(
:milestone
)
board_filter
.
milestone_id
=
milestone
.
id
expect
(
board_filter
.
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