Read about our upcoming Code of Conduct on this issue

Commit a3f645ef authored by skv's avatar skv
Browse files

Remove deprecated finders

parent fd7bd12feb01
...@@ -14,7 +14,6 @@ gem "protected_attributes" ...@@ -14,7 +14,6 @@ gem "protected_attributes"
gem 'rails-observers' gem 'rails-observers'
gem 'actionpack-page_caching' gem 'actionpack-page_caching'
gem 'actionpack-action_caching' gem 'actionpack-action_caching'
gem 'activerecord-deprecated_finders'
# Supported DBs # Supported DBs
gem "mysql2", group: :mysql gem "mysql2", group: :mysql
......
...@@ -549,7 +549,6 @@ PLATFORMS ...@@ -549,7 +549,6 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
actionpack-action_caching actionpack-action_caching
actionpack-page_caching actionpack-page_caching
activerecord-deprecated_finders
acts-as-taggable-on acts-as-taggable-on
annotate (~> 2.6.0.beta2) annotate (~> 2.6.0.beta2)
asciidoctor asciidoctor
......
...@@ -52,6 +52,6 @@ def destroy ...@@ -52,6 +52,6 @@ def destroy
private private
def group def group
@group = Group.find_by_path(params[:id]) @group = Group.find_by(path: params[:id])
end end
end end
...@@ -5,7 +5,7 @@ class Admin::ProjectsController < Admin::ApplicationController ...@@ -5,7 +5,7 @@ class Admin::ProjectsController < Admin::ApplicationController
def index def index
owner_id = params[:owner_id] owner_id = params[:owner_id]
user = User.find_by_id(owner_id) user = User.find_by(id: owner_id)
@projects = user ? user.owned_projects : Project.all @projects = user ? user.owned_projects : Project.all
@projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present? @projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
......
...@@ -100,6 +100,6 @@ def destroy ...@@ -100,6 +100,6 @@ def destroy
protected protected
def user def user
@user ||= User.find_by_username!(params[:id]) @user ||= User.find_by!(username: params[:id])
end end
end end
...@@ -41,7 +41,7 @@ def projects ...@@ -41,7 +41,7 @@ def projects
current_user.authorized_projects current_user.authorized_projects
end end
@projects = @projects.where(namespace_id: Group.find_by_name(params[:group])) if params[:group].present? @projects = @projects.where(namespace_id: Group.find_by(name: params[:group])) if params[:group].present?
@projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present? @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
@projects = @projects.includes(:namespace) @projects = @projects.includes(:namespace)
@projects = @projects.tagged_with(params[:label]) if params[:label].present? @projects = @projects.tagged_with(params[:label]) if params[:label].present?
......
...@@ -87,7 +87,7 @@ def destroy ...@@ -87,7 +87,7 @@ def destroy
protected protected
def group def group
@group ||= Group.find_by_path(params[:id]) @group ||= Group.find_by(path: params[:id])
end end
def projects def projects
......
...@@ -19,6 +19,6 @@ def leave ...@@ -19,6 +19,6 @@ def leave
private private
def group def group
@group ||= Group.find_by_path(params[:id]) @group ||= Group.find_by(path: params[:id])
end end
end end
...@@ -97,7 +97,7 @@ def bulk_update ...@@ -97,7 +97,7 @@ def bulk_update
def issue def issue
@issue ||= begin @issue ||= begin
@project.issues.find_by_iid!(params[:id]) @project.issues.find_by!(iid: params[:id])
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
redirect_old redirect_old
end end
...@@ -128,7 +128,7 @@ def issues_filtered ...@@ -128,7 +128,7 @@ def issues_filtered
# To prevent 404 errors we provide a redirect to correct iids until 7.0 release # To prevent 404 errors we provide a redirect to correct iids until 7.0 release
# #
def redirect_old def redirect_old
issue = @project.issues.find_by_id(params[:id]) issue = @project.issues.find_by(id: params[:id])
if issue if issue
redirect_to project_issue_path(@project, issue) redirect_to project_issue_path(@project, issue)
......
...@@ -169,7 +169,7 @@ def selected_target_project ...@@ -169,7 +169,7 @@ def selected_target_project
end end
def merge_request def merge_request
@merge_request ||= @project.merge_requests.find_by_iid!(params[:id]) @merge_request ||= @project.merge_requests.find_by!(iid: params[:id])
end end
def closes_issues def closes_issues
......
...@@ -76,7 +76,7 @@ def destroy ...@@ -76,7 +76,7 @@ def destroy
protected protected
def milestone def milestone
@milestone ||= @project.milestones.find_by_iid!(params[:id]) @milestone ||= @project.milestones.find_by!(iid: params[:id])
end end
def authorize_admin_milestone! def authorize_admin_milestone!
......
...@@ -26,7 +26,7 @@ def create ...@@ -26,7 +26,7 @@ def create
end end
def update def update
@user_project_relation = project.users_projects.find_by_user_id(member) @user_project_relation = project.users_projects.find_by(user_id: member)
@user_project_relation.update_attributes(params[:team_member]) @user_project_relation.update_attributes(params[:team_member])
unless @user_project_relation.valid? unless @user_project_relation.valid?
...@@ -36,7 +36,7 @@ def update ...@@ -36,7 +36,7 @@ def update
end end
def destroy def destroy
@user_project_relation = project.users_projects.find_by_user_id(member) @user_project_relation = project.users_projects.find_by(user_id: member)
@user_project_relation.destroy @user_project_relation.destroy
respond_to do |format| respond_to do |format|
...@@ -46,7 +46,7 @@ def destroy ...@@ -46,7 +46,7 @@ def destroy
end end
def leave def leave
project.users_projects.find_by_user_id(current_user).destroy project.users_projects.find_by(user_id: current_user).destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to :back } format.html { redirect_to :back }
...@@ -65,6 +65,6 @@ def apply_import ...@@ -65,6 +65,6 @@ def apply_import
protected protected
def member def member
@member ||= User.find_by_username(params[:id]) @member ||= User.find_by(username: params[:id])
end end
end end
class SearchController < ApplicationController class SearchController < ApplicationController
def show def show
@project = Project.find_by_id(params[:project_id]) if params[:project_id].present? @project = Project.find_by(id: params[:project_id]) if params[:project_id].present?
@group = Group.find_by_id(params[:group_id]) if params[:group_id].present? @group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
if @project if @project
return access_denied! unless can?(current_user, :download_code, @project) return access_denied! unless can?(current_user, :download_code, @project)
......
...@@ -18,7 +18,7 @@ def index ...@@ -18,7 +18,7 @@ def index
end end
def user_index def user_index
@user = User.find_by_username(params[:username]) @user = User.find_by(username: params[:username])
@snippets = @user.snippets.fresh.non_expired @snippets = @user.snippets.fresh.non_expired
if @user == current_user if @user == current_user
......
...@@ -2,7 +2,7 @@ class UsersController < ApplicationController ...@@ -2,7 +2,7 @@ class UsersController < ApplicationController
layout 'navless' layout 'navless'
def show def show
@user = User.find_by_username!(params[:username]) @user = User.find_by!(username: params[:username])
@projects = @user.authorized_projects.where(id: current_user.authorized_projects.pluck(:id)).includes(:namespace) @projects = @user.authorized_projects.where(id: current_user.authorized_projects.pluck(:id)).includes(:namespace)
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
......
...@@ -30,7 +30,7 @@ def destroy ...@@ -30,7 +30,7 @@ def destroy
protected protected
def group def group
@group ||= Group.find_by_path(params[:group_id]) @group ||= Group.find_by(path: params[:group_id])
end end
def authorize_admin_group! def authorize_admin_group!
......
...@@ -50,7 +50,7 @@ def current_action?(*args) ...@@ -50,7 +50,7 @@ def current_action?(*args)
end end
def avatar_icon(user_email = '', size = nil) def avatar_icon(user_email = '', size = nil)
user = User.find_by_email(user_email) user = User.find_by(email: user_email)
if user && user.avatar.present? if user && user.avatar.present?
user.avatar.url user.avatar.url
else else
......
...@@ -8,7 +8,7 @@ def new_issue_email(recipient_id, issue_id) ...@@ -8,7 +8,7 @@ def new_issue_email(recipient_id, issue_id)
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id)
@issue = Issue.find(issue_id) @issue = Issue.find(issue_id)
@previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
@project = @issue.project @project = @issue.project
mail(to: recipient(recipient_id), subject: subject("Changed issue ##{@issue.iid}", @issue.title)) mail(to: recipient(recipient_id), subject: subject("Changed issue ##{@issue.iid}", @issue.title))
end end
......
...@@ -8,7 +8,7 @@ def new_merge_request_email(recipient_id, merge_request_id) ...@@ -8,7 +8,7 @@ def new_merge_request_email(recipient_id, merge_request_id)
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id)
@merge_request = MergeRequest.find(merge_request_id) @merge_request = MergeRequest.find(merge_request_id)
@previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
@project = @merge_request.project @project = @merge_request.project
mail(to: recipient(recipient_id), subject: subject("Changed merge request ##{@merge_request.iid}", @merge_request.title)) mail(to: recipient(recipient_id), subject: subject("Changed merge request ##{@merge_request.iid}", @merge_request.title))
end end
......
...@@ -123,8 +123,8 @@ def self.cross_reference_exists?(noteable, mentioner) ...@@ -123,8 +123,8 @@ def self.cross_reference_exists?(noteable, mentioner)
def commit_author def commit_author
@commit_author ||= @commit_author ||=
project.users.find_by_email(noteable.author_email) || project.users.find_by(email: noteable.author_email) ||
project.users.find_by_name(noteable.author_name) project.users.find_by(name: noteable.author_name)
rescue rescue
nil nil
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