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
eb88ca76
Commit
eb88ca76
authored
May 12, 2019
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename methods that conflict in Rails 5.2
Adds suffix to enum methods and changes `in_groups` to `of_groups`
parent
74511b04
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
46 additions
and
46 deletions
+46
-46
app/helpers/events_helper.rb
app/helpers/events_helper.rb
+6
-6
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+1
-1
app/models/event.rb
app/models/event.rb
+27
-27
app/models/members/group_member.rb
app/models/members/group_member.rb
+1
-1
app/models/push_event.rb
app/models/push_event.rb
+1
-1
app/services/concerns/users/participable_service.rb
app/services/concerns/users/participable_service.rb
+1
-1
app/services/members/destroy_service.rb
app/services/members/destroy_service.rb
+1
-1
app/views/events/_event.html.haml
app/views/events/_event.html.haml
+3
-3
app/views/users/calendar_activities.html.haml
app/views/users/calendar_activities.html.haml
+1
-1
lib/api/entities.rb
lib/api/entities.rb
+1
-1
spec/models/event_spec.rb
spec/models/event_spec.rb
+1
-1
spec/models/push_event_spec.rb
spec/models/push_event_spec.rb
+2
-2
No files found.
app/helpers/events_helper.rb
View file @
eb88ca76
...
@@ -68,7 +68,7 @@ module EventsHelper
...
@@ -68,7 +68,7 @@ module EventsHelper
end
end
def
event_preposition
(
event
)
def
event_preposition
(
event
)
if
event
.
push
?
||
event
.
commented
?
||
event
.
target
if
event
.
push
_action?
||
event
.
commented_action
?
||
event
.
target
"at"
"at"
elsif
event
.
milestone?
elsif
event
.
milestone?
"in"
"in"
...
@@ -80,11 +80,11 @@ module EventsHelper
...
@@ -80,11 +80,11 @@ module EventsHelper
words
<<
event
.
author_name
words
<<
event
.
author_name
words
<<
event_action_name
(
event
)
words
<<
event_action_name
(
event
)
if
event
.
push?
if
event
.
push
_action
?
words
<<
event
.
ref_type
words
<<
event
.
ref_type
words
<<
event
.
ref_name
words
<<
event
.
ref_name
words
<<
"at"
words
<<
"at"
elsif
event
.
commented?
elsif
event
.
commented
_action
?
words
<<
event
.
note_target_reference
words
<<
event
.
note_target_reference
words
<<
"at"
words
<<
"at"
elsif
event
.
milestone?
elsif
event
.
milestone?
...
@@ -121,9 +121,9 @@ module EventsHelper
...
@@ -121,9 +121,9 @@ module EventsHelper
if
event
.
note_target
if
event
.
note_target
event_note_target_url
(
event
)
event_note_target_url
(
event
)
end
end
elsif
event
.
push?
elsif
event
.
push
_action
?
push_event_feed_url
(
event
)
push_event_feed_url
(
event
)
elsif
event
.
created_project?
elsif
event
.
created_project
_action
?
project_url
(
event
.
project
)
project_url
(
event
.
project
)
end
end
end
end
...
@@ -147,7 +147,7 @@ module EventsHelper
...
@@ -147,7 +147,7 @@ module EventsHelper
def
event_feed_summary
(
event
)
def
event_feed_summary
(
event
)
if
event
.
issue?
if
event
.
issue?
render
"events/event_issue"
,
issue:
event
.
issue
render
"events/event_issue"
,
issue:
event
.
issue
elsif
event
.
push?
elsif
event
.
push
_action
?
render
"events/event_push"
,
event:
event
render
"events/event_push"
,
event:
event
elsif
event
.
merge_request?
elsif
event
.
merge_request?
render
"events/event_merge_request"
,
merge_request:
event
.
merge_request
render
"events/event_merge_request"
,
merge_request:
event
.
merge_request
...
...
app/models/ci/job_artifact.rb
View file @
eb88ca76
...
@@ -99,7 +99,7 @@ module Ci
...
@@ -99,7 +99,7 @@ module Ci
raw:
1
,
raw:
1
,
zip:
2
,
zip:
2
,
gzip:
3
gzip:
3
}
}
,
_suffix:
true
# `file_location` indicates where actual files are stored.
# `file_location` indicates where actual files are stored.
# Ideally, actual files should be stored in the same directory, and use the same
# Ideally, actual files should be stored in the same directory, and use the same
...
...
app/models/event.rb
View file @
eb88ca76
...
@@ -68,7 +68,7 @@ class Event < ApplicationRecord
...
@@ -68,7 +68,7 @@ class Event < ApplicationRecord
# Callbacks
# Callbacks
after_create
:reset_project_activity
after_create
:reset_project_activity
after_create
:set_last_repository_updated_at
,
if: :push?
after_create
:set_last_repository_updated_at
,
if: :push
_action
?
after_create
:track_user_interacted_projects
after_create
:track_user_interacted_projects
# Scopes
# Scopes
...
@@ -138,11 +138,11 @@ class Event < ApplicationRecord
...
@@ -138,11 +138,11 @@ class Event < ApplicationRecord
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/PerceivedComplexity
def
visible_to_user?
(
user
=
nil
)
def
visible_to_user?
(
user
=
nil
)
if
push?
||
commit_note?
if
push
_action
?
||
commit_note?
Ability
.
allowed?
(
user
,
:download_code
,
project
)
Ability
.
allowed?
(
user
,
:download_code
,
project
)
elsif
membership_changed?
elsif
membership_changed?
Ability
.
allowed?
(
user
,
:read_project
,
project
)
Ability
.
allowed?
(
user
,
:read_project
,
project
)
elsif
created_project?
elsif
created_project
_action
?
Ability
.
allowed?
(
user
,
:read_project
,
project
)
Ability
.
allowed?
(
user
,
:read_project
,
project
)
elsif
issue?
||
issue_note?
elsif
issue?
||
issue_note?
Ability
.
allowed?
(
user
,
:read_issue
,
note?
?
note_target
:
target
)
Ability
.
allowed?
(
user
,
:read_issue
,
note?
?
note_target
:
target
)
...
@@ -173,56 +173,56 @@ class Event < ApplicationRecord
...
@@ -173,56 +173,56 @@ class Event < ApplicationRecord
target
.
try
(
:title
)
target
.
try
(
:title
)
end
end
def
created?
def
created
_action
?
action
==
CREATED
action
==
CREATED
end
end
def
push?
def
push
_action
?
false
false
end
end
def
merged?
def
merged
_action
?
action
==
MERGED
action
==
MERGED
end
end
def
closed?
def
closed
_action
?
action
==
CLOSED
action
==
CLOSED
end
end
def
reopened?
def
reopened
_action
?
action
==
REOPENED
action
==
REOPENED
end
end
def
joined?
def
joined
_action
?
action
==
JOINED
action
==
JOINED
end
end
def
left?
def
left
_action
?
action
==
LEFT
action
==
LEFT
end
end
def
expired?
def
expired
_action
?
action
==
EXPIRED
action
==
EXPIRED
end
end
def
destroyed?
def
destroyed
_action
?
action
==
DESTROYED
action
==
DESTROYED
end
end
def
commented?
def
commented
_action
?
action
==
COMMENTED
action
==
COMMENTED
end
end
def
membership_changed?
def
membership_changed?
joined
?
||
left?
||
expired
?
joined
_action?
||
left_action?
||
expired_action
?
end
end
def
created_project?
def
created_project
_action
?
created?
&&
!
target
&&
target_type
.
nil?
created
_action
?
&&
!
target
&&
target_type
.
nil?
end
end
def
created_target?
def
created_target?
created?
&&
target
created
_action
?
&&
target
end
end
def
milestone?
def
milestone?
...
@@ -258,23 +258,23 @@ class Event < ApplicationRecord
...
@@ -258,23 +258,23 @@ class Event < ApplicationRecord
end
end
def
action_name
def
action_name
if
push?
if
push
_action
?
push_action_name
push_action_name
elsif
closed?
elsif
closed
_action
?
"closed"
"closed"
elsif
merged?
elsif
merged
_action
?
"accepted"
"accepted"
elsif
joined?
elsif
joined
_action
?
'joined'
'joined'
elsif
left?
elsif
left
_action
?
'left'
'left'
elsif
expired?
elsif
expired
_action
?
'removed due to membership expiration from'
'removed due to membership expiration from'
elsif
destroyed?
elsif
destroyed
_action
?
'destroyed'
'destroyed'
elsif
commented?
elsif
commented
_action
?
"commented on"
"commented on"
elsif
created_project?
elsif
created_project
_action
?
created_project_action_name
created_project_action_name
else
else
"opened"
"opened"
...
@@ -337,7 +337,7 @@ class Event < ApplicationRecord
...
@@ -337,7 +337,7 @@ class Event < ApplicationRecord
end
end
def
body?
def
body?
if
push?
if
push
_action
?
push_with_commits?
push_with_commits?
elsif
note?
elsif
note?
true
true
...
...
app/models/members/group_member.rb
View file @
eb88ca76
...
@@ -12,7 +12,7 @@ class GroupMember < Member
...
@@ -12,7 +12,7 @@ class GroupMember < Member
validates
:source_type
,
format:
{
with:
/\ANamespace\z/
}
validates
:source_type
,
format:
{
with:
/\ANamespace\z/
}
default_scope
{
where
(
source_type:
SOURCE_TYPE
)
}
default_scope
{
where
(
source_type:
SOURCE_TYPE
)
}
scope
:
in
_groups
,
->
(
groups
)
{
where
(
source_id:
groups
.
select
(
:id
))
}
scope
:
of
_groups
,
->
(
groups
)
{
where
(
source_id:
groups
.
select
(
:id
))
}
scope
:count_users_by_group_id
,
->
{
joins
(
:user
).
group
(
:source_id
).
count
}
scope
:count_users_by_group_id
,
->
{
joins
(
:user
).
group
(
:source_id
).
count
}
...
...
app/models/push_event.rb
View file @
eb88ca76
...
@@ -69,7 +69,7 @@ class PushEvent < Event
...
@@ -69,7 +69,7 @@ class PushEvent < Event
PUSHED
PUSHED
end
end
def
push?
def
push
_action
?
true
true
end
end
...
...
app/services/concerns/users/participable_service.rb
View file @
eb88ca76
...
@@ -29,7 +29,7 @@ module Users
...
@@ -29,7 +29,7 @@ module Users
def
groups
def
groups
group_counts
=
GroupMember
group_counts
=
GroupMember
.
in
_groups
(
current_user
.
authorized_groups
)
.
of
_groups
(
current_user
.
authorized_groups
)
.
non_request
.
non_request
.
count_users_by_group_id
.
count_users_by_group_id
...
...
app/services/members/destroy_service.rb
View file @
eb88ca76
...
@@ -45,7 +45,7 @@ module Members
...
@@ -45,7 +45,7 @@ module Members
def
delete_subgroup_members
(
member
)
def
delete_subgroup_members
(
member
)
groups
=
member
.
group
.
descendants
groups
=
member
.
group
.
descendants
GroupMember
.
in
_groups
(
groups
).
with_user
(
member
.
user
).
each
do
|
group_member
|
GroupMember
.
of
_groups
(
groups
).
with_user
(
member
.
user
).
each
do
|
group_member
|
self
.
class
.
new
(
current_user
).
execute
(
group_member
,
skip_authorization:
@skip_auth
,
skip_subresources:
true
)
self
.
class
.
new
(
current_user
).
execute
(
group_member
,
skip_authorization:
@skip_auth
,
skip_subresources:
true
)
end
end
end
end
...
...
app/views/events/_event.html.haml
View file @
eb88ca76
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
.event-item-timestamp
.event-item-timestamp
#{
time_ago_with_tooltip
(
event
.
created_at
)
}
#{
time_ago_with_tooltip
(
event
.
created_at
)
}
-
if
event
.
created_project?
-
if
event
.
created_project
_action
?
=
render
"events/event/created_project"
,
event:
event
=
render
"events/event/created_project"
,
event:
event
-
elsif
event
.
push?
-
elsif
event
.
push
_action
?
=
render
"events/event/push"
,
event:
event
=
render
"events/event/push"
,
event:
event
-
elsif
event
.
commented?
-
elsif
event
.
commented
_action
?
=
render
"events/event/note"
,
event:
event
=
render
"events/event/note"
,
event:
event
-
else
-
else
=
render
"events/event/common"
,
event:
event
=
render
"events/event/common"
,
event:
event
...
...
app/views/users/calendar_activities.html.haml
View file @
eb88ca76
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
%i
.fa.fa-clock-o
%i
.fa.fa-clock-o
=
event
.
created_at
.
to_time
.
in_time_zone
.
strftime
(
'%-I:%M%P'
)
=
event
.
created_at
.
to_time
.
in_time_zone
.
strftime
(
'%-I:%M%P'
)
-
if
event
.
visible_to_user?
(
current_user
)
-
if
event
.
visible_to_user?
(
current_user
)
-
if
event
.
push?
-
if
event
.
push
_action
?
#{
event
.
action_name
}
#{
event
.
ref_type
}
#{
event
.
action_name
}
#{
event
.
ref_type
}
%strong
%strong
-
commits_path
=
project_commits_path
(
event
.
project
,
event
.
ref_name
)
-
commits_path
=
project_commits_path
(
event
.
project
,
event
.
ref_name
)
...
...
lib/api/entities.rb
View file @
eb88ca76
...
@@ -878,7 +878,7 @@ module API
...
@@ -878,7 +878,7 @@ module API
expose
:push_event_payload
,
expose
:push_event_payload
,
as: :push_data
,
as: :push_data
,
using:
PushEventPayload
,
using:
PushEventPayload
,
if:
->
(
event
,
_
)
{
event
.
push?
}
if:
->
(
event
,
_
)
{
event
.
push
_action
?
}
expose
:author_username
do
|
event
,
options
|
expose
:author_username
do
|
event
,
options
|
event
.
author
&
.
username
event
.
author
&
.
username
...
...
spec/models/event_spec.rb
View file @
eb88ca76
...
@@ -88,7 +88,7 @@ describe Event do
...
@@ -88,7 +88,7 @@ describe Event do
let
(
:event
)
{
create_push_event
(
project
,
user
)
}
let
(
:event
)
{
create_push_event
(
project
,
user
)
}
it
do
it
do
expect
(
event
.
push?
).
to
be_truthy
expect
(
event
.
push
_action
?
).
to
be_truthy
expect
(
event
.
visible_to_user?
(
user
)).
to
be_truthy
expect
(
event
.
visible_to_user?
(
user
)).
to
be_truthy
expect
(
event
.
visible_to_user?
(
nil
)).
to
be_falsey
expect
(
event
.
visible_to_user?
(
nil
)).
to
be_falsey
expect
(
event
.
tag?
).
to
be_falsey
expect
(
event
.
tag?
).
to
be_falsey
...
...
spec/models/push_event_spec.rb
View file @
eb88ca76
...
@@ -123,9 +123,9 @@ describe PushEvent do
...
@@ -123,9 +123,9 @@ describe PushEvent do
end
end
end
end
describe
'#push?'
do
describe
'#push
_action
?'
do
it
'returns true'
do
it
'returns true'
do
expect
(
event
).
to
be_push
expect
(
event
).
to
be_push
_action
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