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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
b09b175d
Commit
b09b175d
authored
Apr 21, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored specs based on feedback
parent
2d2b73ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
31 deletions
+18
-31
spec/features/issues/filter_by_labels_spec.rb
spec/features/issues/filter_by_labels_spec.rb
+0
-4
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+18
-27
No files found.
spec/features/issues/filter_by_labels_spec.rb
View file @
b09b175d
...
@@ -6,12 +6,8 @@ feature 'Issue filtering by Labels', feature: true do
...
@@ -6,12 +6,8 @@ feature 'Issue filtering by Labels', feature: true do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let!
(
:user
)
{
create
(
:user
)}
let!
(
:user
)
{
create
(
:user
)}
let!
(
:label
)
{
create
(
:label
,
project:
project
)
}
let!
(
:label
)
{
create
(
:label
,
project:
project
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
let
(
:feature
)
{
create
(
:label
,
project:
project
,
title:
'feature'
)
}
let
(
:enhancement
)
{
create
(
:label
,
project:
project
,
title:
'enhancement'
)
}
before
do
before
do
bug
=
create
(
:label
,
project:
project
,
title:
'bug'
)
bug
=
create
(
:label
,
project:
project
,
title:
'bug'
)
feature
=
create
(
:label
,
project:
project
,
title:
'feature'
)
feature
=
create
(
:label
,
project:
project
,
title:
'feature'
)
enhancement
=
create
(
:label
,
project:
project
,
title:
'enhancement'
)
enhancement
=
create
(
:label
,
project:
project
,
title:
'enhancement'
)
...
...
spec/models/concerns/issuable_spec.rb
View file @
b09b175d
...
@@ -214,41 +214,32 @@ describe Issue, "Issuable" do
...
@@ -214,41 +214,32 @@ describe Issue, "Issuable" do
end
end
describe
".with_label"
do
describe
".with_label"
do
let
(
:example_label
)
{
'test1'
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:example_labels
)
{
[
'test1'
,
'test2'
]
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
let
(
:feature
)
{
create
(
:label
,
project:
project
,
title:
'feature'
)
}
let
(
:enhancement
)
{
create
(
:label
,
project:
project
,
title:
'enhancement'
)
}
let
(
:issue1
)
{
create
(
:issue
,
title:
"Bugfix1"
,
project:
project
)
}
let
(
:issue2
)
{
create
(
:issue
,
title:
"Bugfix2"
,
project:
project
)
}
let
(
:issue3
)
{
create
(
:issue
,
title:
"Feature1"
,
project:
project
)
}
before
(
:each
)
do
before
(
:each
)
do
setup_other_issue
issue1
.
labels
<<
bug
issue1
.
labels
<<
feature
issue2
.
labels
<<
bug
issue2
.
labels
<<
enhancement
issue3
.
labels
<<
feature
end
end
it
'finds the correct issue with 1 label'
do
it
'finds the correct issue containing just enhancement label'
do
setup_labels
([
example_label
])
expect
(
Issue
.
with_label
(
enhancement
.
title
)).
to
match_array
([
issue2
])
expect
(
Issue
.
with_label
(
example_label
)).
to
eq
([
issue
])
end
it
'finds the correct issue with 2 labels'
do
setup_labels
(
example_labels
)
expect
(
Issue
.
with_label
(
example_labels
)).
to
eq
([
issue
])
end
end
it
'finds the correct issue with 1 of 2 labels'
do
it
'finds the correct issues containing the same label'
do
setup_labels
(
example_labels
)
expect
(
Issue
.
with_label
(
bug
.
title
)).
to
match_array
([
issue1
,
issue2
])
expect
(
Issue
.
with_label
(
example_label
)).
to
eq
([
issue
])
end
def
setup_labels
(
label_names
)
labels
=
label_names
.
map
do
|
label
|
create
(
:label
,
project:
issue
.
project
,
title:
label
)
end
issue
.
labels
<<
labels
end
end
def
setup_other_issue
it
'finds the correct issues containing only both labels'
do
issue2
=
create
(
:issue
)
expect
(
Issue
.
with_label
([
bug
.
title
,
enhancement
.
title
])).
to
match_array
([
issue2
])
issue2
.
labels
<<
create
(
:label
,
project:
issue2
.
project
,
title:
'other_label'
)
end
end
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