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
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
Hide 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,13 +480,14 @@ class IssuableFinder
...
@@ -480,13 +480,14 @@ class IssuableFinder
def
by_my_reaction_emoji
(
items
)
def
by_my_reaction_emoji
(
items
)
if
params
[
:my_reaction_emoji
].
present?
&&
current_user
if
params
[
:my_reaction_emoji
].
present?
&&
current_user
if
filter_by_no_reaction?
items
=
items
=
items
.
not_awarded
(
current_user
)
if
filter_by_no_reaction?
elsif
filter_by_any_reaction?
items
.
not_awarded
(
current_user
)
items
=
items
.
awarded_any
(
current_user
)
elsif
filter_by_any_reaction?
else
items
.
awarded
(
current_user
)
items
=
items
.
awarded
(
current_user
,
params
[
:my_reaction_emoji
])
else
end
items
.
awarded
(
current_user
,
params
[
:my_reaction_emoji
])
end
end
end
items
items
...
...
app/models/concerns/awardable.rb
View file @
8df7e602
...
@@ -13,13 +13,13 @@ module Awardable
...
@@ -13,13 +13,13 @@ module Awardable
end
end
class_methods
do
class_methods
do
def
awarded
(
user
,
name
)
def
awarded
(
user
,
name
=
nil
)
sql
=
<<~
EOL
sql
=
<<~
EOL
EXISTS (
EXISTS (
SELECT TRUE
SELECT TRUE
FROM award_emoji
FROM award_emoji
WHERE user_id = :user_id AND
WHERE user_id = :user_id AND
name = :name AND
#{
"name = :name AND"
if
name
.
present?
}
awardable_type = :awardable_type AND
awardable_type = :awardable_type AND
awardable_id =
#{
self
.
arel_table
.
name
}
.id
awardable_id =
#{
self
.
arel_table
.
name
}
.id
)
)
...
@@ -28,20 +28,6 @@ module Awardable
...
@@ -28,20 +28,6 @@ module Awardable
where
(
sql
,
user_id:
user
.
id
,
name:
name
,
awardable_type:
self
.
name
)
where
(
sql
,
user_id:
user
.
id
,
name:
name
,
awardable_type:
self
.
name
)
end
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
)
def
not_awarded
(
user
)
sql
=
<<~
EOL
sql
=
<<~
EOL
NOT EXISTS (
NOT EXISTS (
...
...
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
View file @
8df7e602
...
@@ -92,7 +92,7 @@ describe 'Dropdown emoji', :js do
...
@@ -92,7 +92,7 @@ describe 'Dropdown emoji', :js do
it
'shows the most populated emoji at top of dropdown'
do
it
'shows the most populated emoji at top of dropdown'
do
send_keys_to_filtered_search
(
'my-reaction:'
)
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
end
end
...
@@ -122,18 +122,18 @@ describe 'Dropdown emoji', :js do
...
@@ -122,18 +122,18 @@ describe 'Dropdown emoji', :js do
end
end
it
'selects `None`'
do
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
(
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
expect_filtered_search_input_empty
end
end
it
'selects `Any`'
do
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
(
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
expect_filtered_search_input_empty
end
end
...
@@ -143,7 +143,7 @@ describe 'Dropdown emoji', :js do
...
@@ -143,7 +143,7 @@ describe 'Dropdown emoji', :js do
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_css
(
js_dropdown_emoji
,
visible:
false
)
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
expect_filtered_search_input_empty
end
end
end
end
...
...
spec/models/concerns/awardable_spec.rb
View file @
8df7e602
...
@@ -24,13 +24,29 @@ describe Awardable do
...
@@ -24,13 +24,29 @@ describe Awardable do
end
end
end
end
describe
"
.
awarded"
do
describe
"
#
awarded"
do
it
"filters by user and emoji name"
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
,
"thumbsup"
)).
to
be_empty
expect
(
Issue
.
awarded
(
award_emoji
.
user
,
"thumbsdown"
)).
to
eq
[
issue
]
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
,
"thumbsup"
)).
to
eq
[
issue2
]
expect
(
Issue
.
awarded
(
award_emoji2
.
user
,
"thumbsdown"
)).
to
be_empty
expect
(
Issue
.
awarded
(
award_emoji2
.
user
,
"thumbsdown"
)).
to
be_empty
end
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
end
end
...
...
spec/requests/api/issues_spec.rb
View file @
8df7e602
...
@@ -198,7 +198,7 @@ describe API::Issues do
...
@@ -198,7 +198,7 @@ describe API::Issues do
it
'returns issues reacted by the authenticated user'
do
it
'returns issues reacted by the authenticated user'
do
issue2
=
create
(
:issue
,
project:
project
,
author:
user
,
assignees:
[
user
])
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'
)
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
...
@@ -120,8 +120,12 @@ module FilteredSearchHelpers
create_token
(
'Label'
,
label_name
,
symbol
)
create_token
(
'Label'
,
label_name
,
symbol
)
end
end
def
emoji_token
(
emoji_name
=
nil
)
def
reaction_token
(
reaction_name
=
nil
,
is_emoji
=
true
)
{
name:
'My-Reaction'
,
emoji_name:
emoji_name
}
if
is_emoji
{
name:
'My-Reaction'
,
emoji_name:
reaction_name
}
else
create_token
(
'My-Reaction'
,
reaction_name
)
end
end
end
def
default_placeholder
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