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 ...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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 }
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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)
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
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