Commit ddb90d88 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '55583-rename-method-conflicts' into 'master'

Rename methods that conflict in Rails 5.2

Closes #55583

See merge request gitlab-org/gitlab-ce!28281
parents deccdd72 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
......
......@@ -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
......
......@@ -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
......
......@@ -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 }
......
......@@ -69,7 +69,7 @@ class PushEvent < Event
PUSHED
end
def push?
def push_action?
true
end
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment