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
Hide 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
end
def
event_preposition
(
event
)
if
event
.
push
?
||
event
.
commented
?
||
event
.
target
if
event
.
push
_action?
||
event
.
commented_action
?
||
event
.
target
"at"
elsif
event
.
milestone?
"in"
...
...
@@ -80,11 +80,11 @@ module EventsHelper
words
<<
event
.
author_name
words
<<
event_action_name
(
event
)
if
event
.
push?
if
event
.
push
_action
?
words
<<
event
.
ref_type
words
<<
event
.
ref_name
words
<<
"at"
elsif
event
.
commented?
elsif
event
.
commented
_action
?
words
<<
event
.
note_target_reference
words
<<
"at"
elsif
event
.
milestone?
...
...
@@ -121,9 +121,9 @@ module EventsHelper
if
event
.
note_target
event_note_target_url
(
event
)
end
elsif
event
.
push?
elsif
event
.
push
_action
?
push_event_feed_url
(
event
)
elsif
event
.
created_project?
elsif
event
.
created_project
_action
?
project_url
(
event
.
project
)
end
end
...
...
@@ -147,7 +147,7 @@ module EventsHelper
def
event_feed_summary
(
event
)
if
event
.
issue?
render
"events/event_issue"
,
issue:
event
.
issue
elsif
event
.
push?
elsif
event
.
push
_action
?
render
"events/event_push"
,
event:
event
elsif
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
raw:
1
,
zip:
2
,
gzip:
3
}
}
,
_suffix:
true
# `file_location` indicates where actual files are stored.
# 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
# Callbacks
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
# Scopes
...
...
@@ -138,11 +138,11 @@ class Event < ApplicationRecord
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
def
visible_to_user?
(
user
=
nil
)
if
push?
||
commit_note?
if
push
_action
?
||
commit_note?
Ability
.
allowed?
(
user
,
:download_code
,
project
)
elsif
membership_changed?
Ability
.
allowed?
(
user
,
:read_project
,
project
)
elsif
created_project?
elsif
created_project
_action
?
Ability
.
allowed?
(
user
,
:read_project
,
project
)
elsif
issue?
||
issue_note?
Ability
.
allowed?
(
user
,
:read_issue
,
note?
?
note_target
:
target
)
...
...
@@ -173,56 +173,56 @@ class Event < ApplicationRecord
target
.
try
(
:title
)
end
def
created?
def
created
_action
?
action
==
CREATED
end
def
push?
def
push
_action
?
false
end
def
merged?
def
merged
_action
?
action
==
MERGED
end
def
closed?
def
closed
_action
?
action
==
CLOSED
end
def
reopened?
def
reopened
_action
?
action
==
REOPENED
end
def
joined?
def
joined
_action
?
action
==
JOINED
end
def
left?
def
left
_action
?
action
==
LEFT
end
def
expired?
def
expired
_action
?
action
==
EXPIRED
end
def
destroyed?
def
destroyed
_action
?
action
==
DESTROYED
end
def
commented?
def
commented
_action
?
action
==
COMMENTED
end
def
membership_changed?
joined
?
||
left?
||
expired
?
joined
_action?
||
left_action?
||
expired_action
?
end
def
created_project?
created?
&&
!
target
&&
target_type
.
nil?
def
created_project
_action
?
created
_action
?
&&
!
target
&&
target_type
.
nil?
end
def
created_target?
created?
&&
target
created
_action
?
&&
target
end
def
milestone?
...
...
@@ -258,23 +258,23 @@ class Event < ApplicationRecord
end
def
action_name
if
push?
if
push
_action
?
push_action_name
elsif
closed?
elsif
closed
_action
?
"closed"
elsif
merged?
elsif
merged
_action
?
"accepted"
elsif
joined?
elsif
joined
_action
?
'joined'
elsif
left?
elsif
left
_action
?
'left'
elsif
expired?
elsif
expired
_action
?
'removed due to membership expiration from'
elsif
destroyed?
elsif
destroyed
_action
?
'destroyed'
elsif
commented?
elsif
commented
_action
?
"commented on"
elsif
created_project?
elsif
created_project
_action
?
created_project_action_name
else
"opened"
...
...
@@ -337,7 +337,7 @@ class Event < ApplicationRecord
end
def
body?
if
push?
if
push
_action
?
push_with_commits?
elsif
note?
true
...
...
app/models/members/group_member.rb
View file @
eb88ca76
...
...
@@ -12,7 +12,7 @@ class GroupMember < Member
validates
:source_type
,
format:
{
with:
/\ANamespace\z/
}
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
}
...
...
app/models/push_event.rb
View file @
eb88ca76
...
...
@@ -69,7 +69,7 @@ class PushEvent < Event
PUSHED
end
def
push?
def
push
_action
?
true
end
...
...
app/services/concerns/users/participable_service.rb
View file @
eb88ca76
...
...
@@ -29,7 +29,7 @@ module Users
def
groups
group_counts
=
GroupMember
.
in
_groups
(
current_user
.
authorized_groups
)
.
of
_groups
(
current_user
.
authorized_groups
)
.
non_request
.
count_users_by_group_id
...
...
app/services/members/destroy_service.rb
View file @
eb88ca76
...
...
@@ -45,7 +45,7 @@ module Members
def
delete_subgroup_members
(
member
)
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
)
end
end
...
...
app/views/events/_event.html.haml
View file @
eb88ca76
...
...
@@ -3,11 +3,11 @@
.event-item-timestamp
#{
time_ago_with_tooltip
(
event
.
created_at
)
}
-
if
event
.
created_project?
-
if
event
.
created_project
_action
?
=
render
"events/event/created_project"
,
event:
event
-
elsif
event
.
push?
-
elsif
event
.
push
_action
?
=
render
"events/event/push"
,
event:
event
-
elsif
event
.
commented?
-
elsif
event
.
commented
_action
?
=
render
"events/event/note"
,
event:
event
-
else
=
render
"events/event/common"
,
event:
event
...
...
app/views/users/calendar_activities.html.haml
View file @
eb88ca76
...
...
@@ -9,7 +9,7 @@
%i
.fa.fa-clock-o
=
event
.
created_at
.
to_time
.
in_time_zone
.
strftime
(
'%-I:%M%P'
)
-
if
event
.
visible_to_user?
(
current_user
)
-
if
event
.
push?
-
if
event
.
push
_action
?
#{
event
.
action_name
}
#{
event
.
ref_type
}
%strong
-
commits_path
=
project_commits_path
(
event
.
project
,
event
.
ref_name
)
...
...
lib/api/entities.rb
View file @
eb88ca76
...
...
@@ -878,7 +878,7 @@ module API
expose
:push_event_payload
,
as: :push_data
,
using:
PushEventPayload
,
if:
->
(
event
,
_
)
{
event
.
push?
}
if:
->
(
event
,
_
)
{
event
.
push
_action
?
}
expose
:author_username
do
|
event
,
options
|
event
.
author
&
.
username
...
...
spec/models/event_spec.rb
View file @
eb88ca76
...
...
@@ -88,7 +88,7 @@ describe Event do
let
(
:event
)
{
create_push_event
(
project
,
user
)
}
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?
(
nil
)).
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
end
end
describe
'#push?'
do
describe
'#push
_action
?'
do
it
'returns true'
do
expect
(
event
).
to
be_push
expect
(
event
).
to
be_push
_action
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