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
Léo-Paul Géneau
gitlab-ce
Commits
8df7e602
Commit
8df7e602
authored
Oct 27, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
69dcab23
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
33 deletions
+40
-33
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+8
-7
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+2
-16
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
+6
-6
spec/models/concerns/awardable_spec.rb
spec/models/concerns/awardable_spec.rb
+17
-1
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+1
-1
spec/support/helpers/filtered_search_helpers.rb
spec/support/helpers/filtered_search_helpers.rb
+6
-2
No files found.
app/finders/issuable_finder.rb
View file @
8df7e602
...
...
@@ -480,12 +480,13 @@ class IssuableFinder
def
by_my_reaction_emoji
(
items
)
if
params
[
:my_reaction_emoji
].
present?
&&
current_user
items
=
if
filter_by_no_reaction?
items
=
items
.
not_awarded
(
current_user
)
items
.
not_awarded
(
current_user
)
elsif
filter_by_any_reaction?
items
=
items
.
awarded_any
(
current_user
)
items
.
awarded
(
current_user
)
else
items
=
items
.
awarded
(
current_user
,
params
[
:my_reaction_emoji
])
items
.
awarded
(
current_user
,
params
[
:my_reaction_emoji
])
end
end
...
...
app/models/concerns/awardable.rb
View file @
8df7e602
...
...
@@ -13,13 +13,13 @@ module Awardable
end
class_methods
do
def
awarded
(
user
,
name
)
def
awarded
(
user
,
name
=
nil
)
sql
=
<<~
EOL
EXISTS (
SELECT TRUE
FROM award_emoji
WHERE user_id = :user_id AND
name = :name AND
#{
"name = :name AND"
if
name
.
present?
}
awardable_type = :awardable_type AND
awardable_id =
#{
self
.
arel_table
.
name
}
.id
)
...
...
@@ -28,20 +28,6 @@ module Awardable
where
(
sql
,
user_id:
user
.
id
,
name:
name
,
awardable_type:
self
.
name
)
end
def
awarded_any
(
user
)
sql
=
<<~
EOL
EXISTS (
SELECT TRUE
FROM award_emoji
WHERE user_id = :user_id AND
awardable_type = :awardable_type AND
awardable_id =
#{
self
.
arel_table
.
name
}
.id
)
EOL
where
(
sql
,
user_id:
user
.
id
,
awardable_type:
self
.
name
)
end
def
not_awarded
(
user
)
sql
=
<<~
EOL
NOT EXISTS (
...
...
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
View file @
8df7e602
...
...
@@ -92,7 +92,7 @@ describe 'Dropdown emoji', :js do
it
'shows the most populated emoji at top of dropdown'
do
send_keys_to_filtered_search
(
'my-reaction:'
)
expect
(
first
(
'#js-dropdown-my-reaction li'
)).
to
have_content
(
award_emoji_star
.
name
)
expect
(
first
(
'#js-dropdown-my-reaction
.filter-dropdown
li'
)).
to
have_content
(
award_emoji_star
.
name
)
end
end
...
...
@@ -122,18 +122,18 @@ describe 'Dropdown emoji', :js do
end
it
'selects `None`'
do
find
(
'#js-dropdown-
assignee
.filter-dropdown-item'
,
text:
'None'
).
click
find
(
'#js-dropdown-
my-reaction
.filter-dropdown-item'
,
text:
'None'
).
click
expect
(
page
).
to
have_css
(
js_dropdown_emoji
,
visible:
false
)
expect_tokens
([
emoji_token
(
'none'
)])
expect_tokens
([
reaction_token
(
'none'
,
false
)])
expect_filtered_search_input_empty
end
it
'selects `Any`'
do
find
(
'#js-dropdown-
assignee
.filter-dropdown-item'
,
text:
'Any'
).
click
find
(
'#js-dropdown-
my-reaction
.filter-dropdown-item'
,
text:
'Any'
).
click
expect
(
page
).
to
have_css
(
js_dropdown_emoji
,
visible:
false
)
expect_tokens
([
emoji_token
(
'any'
)])
expect_tokens
([
reaction_token
(
'any'
,
false
)])
expect_filtered_search_input_empty
end
...
...
@@ -143,7 +143,7 @@ describe 'Dropdown emoji', :js do
wait_for_requests
expect
(
page
).
to
have_css
(
js_dropdown_emoji
,
visible:
false
)
expect_tokens
([
emoji
_token
(
'thumbsup'
)])
expect_tokens
([
reaction
_token
(
'thumbsup'
)])
expect_filtered_search_input_empty
end
end
...
...
spec/models/concerns/awardable_spec.rb
View file @
8df7e602
...
...
@@ -24,13 +24,29 @@ describe Awardable do
end
end
describe
"
.
awarded"
do
describe
"
#
awarded"
do
it
"filters by user and emoji name"
do
expect
(
Issue
.
awarded
(
award_emoji
.
user
,
"thumbsup"
)).
to
be_empty
expect
(
Issue
.
awarded
(
award_emoji
.
user
,
"thumbsdown"
)).
to
eq
[
issue
]
expect
(
Issue
.
awarded
(
award_emoji2
.
user
,
"thumbsup"
)).
to
eq
[
issue2
]
expect
(
Issue
.
awarded
(
award_emoji2
.
user
,
"thumbsdown"
)).
to
be_empty
end
it
"filters by user and any emoji"
do
issue3
=
create
(
:issue
)
create
(
:award_emoji
,
awardable:
issue3
,
name:
"star"
,
user:
award_emoji
.
user
)
create
(
:award_emoji
,
awardable:
issue3
,
name:
"star"
,
user:
award_emoji2
.
user
)
expect
(
Issue
.
awarded
(
award_emoji
.
user
)).
to
eq
[
issue
,
issue3
]
expect
(
Issue
.
awarded
(
award_emoji2
.
user
)).
to
eq
[
issue2
,
issue3
]
end
end
describe
"#not_awarded"
do
it
"returns issues not awarded by user"
do
expect
(
Issue
.
not_awarded
(
award_emoji
.
user
)).
to
eq
[
issue2
]
expect
(
Issue
.
not_awarded
(
award_emoji2
.
user
)).
to
eq
[
issue
]
end
end
end
...
...
spec/requests/api/issues_spec.rb
View file @
8df7e602
...
...
@@ -198,7 +198,7 @@ describe API::Issues do
it
'returns issues reacted by the authenticated user'
do
issue2
=
create
(
:issue
,
project:
project
,
author:
user
,
assignees:
[
user
])
award_emoji
=
create
(
:award_emoji
,
awardable:
issue2
,
user:
user2
,
name:
'star'
)
create
(
:award_emoji
,
awardable:
issue2
,
user:
user2
,
name:
'star'
)
create
(
:award_emoji
,
awardable:
issue
,
user:
user2
,
name:
'thumbsup'
)
...
...
spec/support/helpers/filtered_search_helpers.rb
View file @
8df7e602
...
...
@@ -120,8 +120,12 @@ module FilteredSearchHelpers
create_token
(
'Label'
,
label_name
,
symbol
)
end
def
emoji_token
(
emoji_name
=
nil
)
{
name:
'My-Reaction'
,
emoji_name:
emoji_name
}
def
reaction_token
(
reaction_name
=
nil
,
is_emoji
=
true
)
if
is_emoji
{
name:
'My-Reaction'
,
emoji_name:
reaction_name
}
else
create_token
(
'My-Reaction'
,
reaction_name
)
end
end
def
default_placeholder
...
...
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