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
Boxiang Sun
gitlab-ce
Commits
7a4e7ad0
Commit
7a4e7ad0
authored
May 12, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests and wrong choices during merge
parent
2bbe781d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
12 deletions
+58
-12
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+8
-0
app/models/note.rb
app/models/note.rb
+1
-1
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+1
-1
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+4
-2
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+30
-0
spec/services/notes/create_service_spec.rb
spec/services/notes/create_service_spec.rb
+12
-0
spec/services/toggle_award_emoji_service_spec.rb
spec/services/toggle_award_emoji_service_spec.rb
+2
-8
No files found.
app/models/concerns/issuable.rb
View file @
7a4e7ad0
...
...
@@ -100,6 +100,14 @@ module Issuable
order_by
(
method
)
end
end
def
with_label
(
title
)
if
title
.
is_a?
(
Array
)
&&
title
.
size
>
1
joins
(
:labels
).
where
(
labels:
{
title:
title
}).
group
(
arel_table
[
:id
]).
having
(
"COUNT(DISTINCT labels.title) =
#{
title
.
size
}
"
)
else
joins
(
:labels
).
where
(
labels:
{
title:
title
})
end
end
end
def
today?
...
...
app/models/note.rb
View file @
7a4e7ad0
...
...
@@ -343,6 +343,6 @@ class Note < ActiveRecord::Base
def
award_emoji_name
original_name
=
note
.
match
(
Banzai
::
Filter
::
EmojiFilter
.
emoji_pattern
)[
1
]
Gitlab
::
AwardEmoji
.
norm
i
lize_emoji_name
(
original_name
)
Gitlab
::
AwardEmoji
.
norm
a
lize_emoji_name
(
original_name
)
end
end
app/services/notes/create_service.rb
View file @
7a4e7ad0
...
...
@@ -7,7 +7,7 @@ module Notes
if
note
.
award_emoji?
return
ToggleAwardEmojiService
.
new
(
project
,
current_user
,
params
).
execute
(
note
.
award_emoji_name
,
note
.
not
e
)
execute
(
note
.
noteable
,
note
.
award_emoji_nam
e
)
end
return
unless
valid_project?
(
note
)
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
7a4e7ad0
...
...
@@ -258,8 +258,10 @@ describe Projects::IssuesController do
end
it
"toggles the award emoji"
do
expect
{
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
issue
.
iid
,
name:
"thumbsup"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
1
)
expect
do
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
issue
.
iid
,
name:
"thumbsup"
)
end
.
to
change
{
AwardEmoji
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
spec/models/concerns/issuable_spec.rb
View file @
7a4e7ad0
...
...
@@ -214,4 +214,34 @@ describe Issue, "Issuable" do
expect
(
issue
.
downvotes
).
to
eq
(
1
)
end
end
describe
".with_label"
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
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
issue1
.
labels
<<
bug
issue1
.
labels
<<
feature
issue2
.
labels
<<
bug
issue2
.
labels
<<
enhancement
issue3
.
labels
<<
feature
end
it
'finds the correct issue containing just enhancement label'
do
expect
(
Issue
.
with_label
(
enhancement
.
title
)).
to
match_array
([
issue2
])
end
it
'finds the correct issues containing the same label'
do
expect
(
Issue
.
with_label
(
bug
.
title
)).
to
match_array
([
issue1
,
issue2
])
end
it
'finds the correct issues containing only both labels'
do
expect
(
Issue
.
with_label
([
bug
.
title
,
enhancement
.
title
])).
to
match_array
([
issue2
])
end
end
end
spec/services/notes/create_service_spec.rb
View file @
7a4e7ad0
...
...
@@ -51,5 +51,17 @@ describe Notes::CreateService, services: true do
expect
(
note
).
to
be_valid
expect
(
note
.
note
).
to
eq
(
opts
[
:note
])
end
it
"normalizes the emoji name"
do
opts
=
{
note:
':+1:'
,
noteable_type:
'Issue'
,
noteable_id:
issue
.
id
}
expect_any_instance_of
(
ToggleAwardEmojiService
).
to
receive
(
:execute
).
with
(
issue
,
"thumbsup"
)
Notes
::
CreateService
.
new
(
project
,
user
,
opts
).
execute
end
end
end
spec/services/toggle_award_emoji_service_spec.rb
View file @
7a4e7ad0
...
...
@@ -16,23 +16,17 @@ describe ToggleAwardEmoji, services: true do
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"thumbsdown"
)
end
it
'normalizes the emoji name'
do
expect
(
issue
).
to
receive
(
:toggle_award_emoji
).
with
(
"thumbsup"
,
user
)
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
":+1:"
)
end
context
'when the emoji is set'
do
it
'removes the emoji'
do
create
(
:award_emoji
,
awardable:
issue
,
user:
user
)
expect
{
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"
:+1:
"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
-
1
)
expect
{
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"
thumbsup
"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
-
1
)
end
end
context
'when the award is not set yet'
do
it
'awards the emoji'
do
expect
{
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"
:+1:
"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
1
)
expect
{
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"
thumbsup
"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
1
)
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