Permalink
Browse files

Remove deprecated finders

  • Loading branch information...
1 parent 3fe578a commit a3f645ef51ec12ce93934b4ddb11313613d8c451 @skv-headless skv-headless committed Jan 19, 2014
Showing with 145 additions and 147 deletions.
  1. +0 −1 Gemfile
  2. +0 −1 Gemfile.lock
  3. +1 −1 app/controllers/admin/groups_controller.rb
  4. +1 −1 app/controllers/admin/projects_controller.rb
  5. +1 −1 app/controllers/admin/users_controller.rb
  6. +1 −1 app/controllers/dashboard_controller.rb
  7. +1 −1 app/controllers/groups_controller.rb
  8. +1 −1 app/controllers/profiles/groups_controller.rb
  9. +2 −2 app/controllers/projects/issues_controller.rb
  10. +1 −1 app/controllers/projects/merge_requests_controller.rb
  11. +1 −1 app/controllers/projects/milestones_controller.rb
  12. +4 −4 app/controllers/projects/team_members_controller.rb
  13. +2 −2 app/controllers/search_controller.rb
  14. +1 −1 app/controllers/snippets_controller.rb
  15. +1 −1 app/controllers/users_controller.rb
  16. +1 −1 app/controllers/users_groups_controller.rb
  17. +1 −1 app/helpers/application_helper.rb
  18. +1 −1 app/mailers/emails/issues.rb
  19. +1 −1 app/mailers/emails/merge_requests.rb
  20. +2 −2 app/models/note.rb
  21. +3 −3 app/models/project.rb
  22. +4 −4 app/models/project_team.rb
  23. +2 −2 app/models/user.rb
  24. +2 −2 app/services/notification_service.rb
  25. +1 −1 app/services/projects/create_service.rb
  26. +1 −1 app/services/search/global_service.rb
  27. +1 −1 db/fixtures/development/04_project.rb
  28. +1 −1 db/migrate/20130506095501_remove_project_id_from_key.rb
  29. +1 −1 features/steps/admin/admin_groups.rb
  30. +2 −2 features/steps/dashboard/dashboard.rb
  31. +1 −1 features/steps/dashboard/dashboard_with_archived_projects.rb
  32. +1 −1 features/steps/group/group.rb
  33. +1 −1 features/steps/profile/profile_ssh_keys.rb
  34. +3 −3 features/steps/project/project_archived.rb
  35. +1 −1 features/steps/project/project_browse_branches.rb
  36. +2 −2 features/steps/project/project_fork.rb
  37. +4 −4 features/steps/project/project_forked_merge_requests.rb
  38. +1 −1 features/steps/project/project_graph.rb
  39. +1 −1 features/steps/project/project_issue_tracker.rb
  40. +8 −8 features/steps/project/project_issues.rb
  41. +1 −1 features/steps/project/project_labels.rb
  42. +1 −1 features/steps/project/project_markdown_render.rb
  43. +3 −3 features/steps/project/project_merge_requests.rb
  44. +5 −5 features/steps/project/project_milestones.rb
  45. +1 −1 features/steps/project/project_network_graph.rb
  46. +2 −2 features/steps/project/project_snippets.rb
  47. +10 −10 features/steps/project/project_team_management.rb
  48. +3 −3 features/steps/project/redirects.rb
  49. +8 −8 features/steps/public/projects_feature.rb
  50. +5 −5 features/steps/shared/paths.rb
  51. +4 −4 features/steps/shared/project.rb
  52. +1 −1 features/steps/snippets/discover_snippets.rb
  53. +1 −1 features/steps/snippets/snippets.rb
  54. +1 −1 features/steps/snippets/user_snippets.rb
  55. +2 −2 lib/api/deploy_keys.rb
  56. +4 −4 lib/api/entities.rb
  57. +3 −3 lib/api/groups.rb
  58. +2 −2 lib/api/helpers.rb
  59. +1 −1 lib/api/merge_requests.rb
  60. +2 −2 lib/api/projects.rb
  61. +2 −2 lib/api/repositories.rb
  62. +1 −1 lib/api/users.rb
  63. +1 −1 lib/gitlab/auth.rb
  64. +3 −3 lib/gitlab/identifier.rb
  65. +2 −2 lib/gitlab/ldap/user.rb
  66. +1 −1 lib/tasks/gitlab/bulk_add_permission.rake
  67. +2 −2 lib/tasks/gitlab/enable_namespaces.rake
  68. +1 −1 lib/tasks/gitlab/import.rake
  69. +5 −5 spec/lib/gitlab/ldap/ldap_user_auth_spec.rb
  70. +1 −1 spec/requests/api/users_spec.rb
  71. +1 −1 spec/workers/post_receive_spec.rb
View
@@ -14,7 +14,6 @@ gem "protected_attributes"
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
-gem 'activerecord-deprecated_finders'
# Supported DBs
gem "mysql2", group: :mysql
View
@@ -549,7 +549,6 @@ PLATFORMS
DEPENDENCIES
actionpack-action_caching
actionpack-page_caching
- activerecord-deprecated_finders
acts-as-taggable-on
annotate (~> 2.6.0.beta2)
asciidoctor
@@ -52,6 +52,6 @@ def destroy
private
def group
- @group = Group.find_by_path(params[:id])
+ @group = Group.find_by(path: params[:id])
end
end
@@ -5,7 +5,7 @@ class Admin::ProjectsController < Admin::ApplicationController
def index
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 = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
@@ -100,6 +100,6 @@ def destroy
protected
def user
- @user ||= User.find_by_username!(params[:id])
+ @user ||= User.find_by!(username: params[:id])
end
end
@@ -41,7 +41,7 @@ def projects
current_user.authorized_projects
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.includes(:namespace)
@projects = @projects.tagged_with(params[:label]) if params[:label].present?
@@ -87,7 +87,7 @@ def destroy
protected
def group
- @group ||= Group.find_by_path(params[:id])
+ @group ||= Group.find_by(path: params[:id])
end
def projects
@@ -19,6 +19,6 @@ def leave
private
def group
- @group ||= Group.find_by_path(params[:id])
+ @group ||= Group.find_by(path: params[:id])
end
end
@@ -97,7 +97,7 @@ def bulk_update
def issue
@issue ||= begin
- @project.issues.find_by_iid!(params[:id])
+ @project.issues.find_by!(iid: params[:id])
rescue ActiveRecord::RecordNotFound
redirect_old
end
@@ -128,7 +128,7 @@ def issues_filtered
# To prevent 404 errors we provide a redirect to correct iids until 7.0 release
#
def redirect_old
- issue = @project.issues.find_by_id(params[:id])
+ issue = @project.issues.find_by(id: params[:id])
if issue
redirect_to project_issue_path(@project, issue)
@@ -169,7 +169,7 @@ def selected_target_project
end
def merge_request
- @merge_request ||= @project.merge_requests.find_by_iid!(params[:id])
+ @merge_request ||= @project.merge_requests.find_by!(iid: params[:id])
end
def closes_issues
@@ -76,7 +76,7 @@ def destroy
protected
def milestone
- @milestone ||= @project.milestones.find_by_iid!(params[:id])
+ @milestone ||= @project.milestones.find_by!(iid: params[:id])
end
def authorize_admin_milestone!
@@ -26,7 +26,7 @@ def create
end
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])
unless @user_project_relation.valid?
@@ -36,7 +36,7 @@ def update
end
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
respond_to do |format|
@@ -46,7 +46,7 @@ def destroy
end
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|
format.html { redirect_to :back }
@@ -65,6 +65,6 @@ def apply_import
protected
def member
- @member ||= User.find_by_username(params[:id])
+ @member ||= User.find_by(username: params[:id])
end
end
@@ -1,7 +1,7 @@
class SearchController < ApplicationController
def show
- @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?
+ @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?
if @project
return access_denied! unless can?(current_user, :download_code, @project)
@@ -18,7 +18,7 @@ def index
end
def user_index
- @user = User.find_by_username(params[:username])
+ @user = User.find_by(username: params[:username])
@snippets = @user.snippets.fresh.non_expired
if @user == current_user
@@ -2,7 +2,7 @@ class UsersController < ApplicationController
layout 'navless'
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)
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
@@ -30,7 +30,7 @@ def destroy
protected
def group
- @group ||= Group.find_by_path(params[:group_id])
+ @group ||= Group.find_by(path: params[:group_id])
end
def authorize_admin_group!
@@ -50,7 +50,7 @@ def current_action?(*args)
end
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?
user.avatar.url
else
@@ -8,7 +8,7 @@ def new_issue_email(recipient_id, issue_id)
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_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
mail(to: recipient(recipient_id), subject: subject("Changed issue ##{@issue.iid}", @issue.title))
end
@@ -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)
@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
mail(to: recipient(recipient_id), subject: subject("Changed merge request ##{@merge_request.iid}", @merge_request.title))
end
View
@@ -123,8 +123,8 @@ def self.cross_reference_exists?(noteable, mentioner)
def commit_author
@commit_author ||=
- project.users.find_by_email(noteable.author_email) ||
- project.users.find_by_name(noteable.author_name)
+ project.users.find_by(email: noteable.author_email) ||
+ project.users.find_by(name: noteable.author_name)
rescue
nil
end
View
@@ -141,10 +141,10 @@ def search query
def find_with_namespace(id)
if id.include?("/")
id = id.split("/")
- namespace = Namespace.find_by_path(id.first)
+ namespace = Namespace.find_by(path: id.first)
return nil unless namespace
- where(namespace_id: namespace.id).find_by_path(id.second)
+ where(namespace_id: namespace.id).find_by(path: id.second)
else
where(path: id, namespace_id: nil).last
end
@@ -288,7 +288,7 @@ def team_member_by_name_or_email(name = nil, email = nil)
# Get Team Member record by user id
def team_member_by_id(user_id)
- users_projects.find_by_user_id(user_id)
+ users_projects.find_by(user_id: user_id)
end
def name_with_namespace
@@ -22,22 +22,22 @@ def << args
end
def find(user_id)
- user = project.users.find_by_id(user_id)
+ user = project.users.find_by(id: user_id)
if group
- user ||= group.users.find_by_id(user_id)
+ user ||= group.users.find_by(id: user_id)
end
user
end
def find_tm(user_id)
- tm = project.users_projects.find_by_user_id(user_id)
+ tm = project.users_projects.find_by(user_id: user_id)
# If user is not in project members
# we should check for group membership
if group && !tm
- tm = group.users_groups.find_by_user_id(user_id)
+ tm = group.users_groups.find_by(user_id: user_id)
end
tm
View
@@ -238,7 +238,7 @@ def generate_password
def namespace_uniq
namespace_name = self.username
- if Namespace.find_by_path(namespace_name)
+ if Namespace.find_by(path: namespace_name)
self.errors.add :username, "already exist"
end
end
@@ -382,7 +382,7 @@ def accessible_deploy_keys
end
def created_by
- User.find_by_id(created_by_id) if created_by_id
+ User.find_by(id: created_by_id) if created_by_id
end
def sanitize_attrs
@@ -195,10 +195,10 @@ def reject_muted_users(users, project = nil)
users.reject do |user|
next user.notification.disabled? unless project
- tm = project.users_projects.find_by_user_id(user.id)
+ tm = project.users_projects.find_by(user_id: user.id)
if !tm && project.group
- tm = project.group.users_groups.find_by_user_id(user.id)
+ tm = project.group.users_groups.find_by(user_id: user.id)
end
# reject users who globally disabled notification and has no membership
@@ -73,7 +73,7 @@ def deny_namespace
end
def allowed_namespace?(user, namespace_id)
- namespace = Namespace.find_by_id(namespace_id)
+ namespace = Namespace.find_by(id: namespace_id)
current_user.can?(:manage_namespace, namespace)
end
end
@@ -15,7 +15,7 @@ def execute
authorized_projects_ids += current_user.authorized_projects.pluck(:id) if current_user
authorized_projects_ids += Project.public_or_internal_only(current_user).pluck(:id)
- 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?
projects = Project.where(id: authorized_projects_ids)
projects = projects.where(namespace_id: group.id) if group
projects = projects.search(query)
@@ -19,7 +19,7 @@
project_urls.each_with_index do |url, i|
group_path, project_path = url.split('/')[-2..-1]
- group = Group.find_by_path(group_path)
+ group = Group.find_by(path: group_path)
unless group
group = Group.new(
@@ -4,7 +4,7 @@ def up
Key.where('project_id IS NOT NULL').update_all(type: 'DeployKey')
DeployKey.all.each do |key|
- project = Project.find_by_id(key.project_id)
+ project = Project.find_by(id: key.project_id)
if project
project.deploy_keys << key
print '.'
@@ -40,7 +40,7 @@ class AdminGroups < Spinach::FeatureSteps
end
When 'I select user "John" from user list as "Reporter"' do
- user = User.find_by_name("John")
+ user = User.find_by(name: "John")
select2(user.id, from: "#user_ids", multiple: true)
within "#new_team_member" do
select "Reporter", from: "group_access"
@@ -43,7 +43,7 @@ class Dashboard < Spinach::FeatureSteps
end
And 'user with name "John Doe" left project "Shop"' do
- user = User.find_by_name "John Doe"
+ user = User.find_by(name: "John Doe")
Event.create(
project: project,
author_id: user.id,
@@ -85,6 +85,6 @@ class Dashboard < Spinach::FeatureSteps
end
def project
- @project ||= Project.find_by_name "Shop"
+ @project ||= Project.find_by(name: "Shop")
end
end
@@ -4,7 +4,7 @@ class DashboardWithArchivedProjects < Spinach::FeatureSteps
include SharedProject
When 'project "Forum" is archived' do
- project = Project.find_by_name "Forum"
+ project = Project.find_by(name: "Forum")
project.update_attribute(:archived, true)
end
@@ -39,7 +39,7 @@ class Groups < Spinach::FeatureSteps
end
And 'I select user "John" from list with role "Reporter"' do
- user = User.find_by_name("John")
+ user = User.find_by(name: "John")
within ".users-group-form" do
select2(user.id, from: "#user_ids", multiple: true)
select "Reporter", from: "group_access"
@@ -18,7 +18,7 @@ class ProfileSshKeys < Spinach::FeatureSteps
end
Then 'I should see new ssh key "Laptop"' do
- key = Key.find_by_title("Laptop")
+ key = Key.find_by(title: "Laptop")
page.should have_content(key.title)
page.should have_content(key.key)
current_path.should == profile_key_path(key)
Oops, something went wrong.

0 comments on commit a3f645e

Please sign in to comment.