From abd921736b6db3a405c6505b3bf4022bb9097d41 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 2 Dec 2012 20:28:37 +0000 Subject: [PATCH] Replaces find(:all) calls. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10918 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- db/migrate/007_create_journals.rb | 2 +- db/migrate/019_add_issue_status_position.rb | 2 +- db/migrate/021_add_tracker_position.rb | 2 +- db/migrate/022_serialize_possibles_values.rb | 2 +- db/migrate/065_add_settings_updated_on.rb | 2 +- db/migrate/068_create_enabled_modules.rb | 2 +- db/migrate/072_add_enumerations_position.rb | 2 +- db/migrate/078_add_custom_fields_position.rb | 2 +- db/migrate/081_create_projects_trackers.rb | 4 ++-- db/migrate/096_add_commit_access_permission.rb | 4 ++-- db/migrate/097_add_view_wiki_edits_permission.rb | 4 ++-- .../099_add_delete_wiki_pages_attachments_permission.rb | 4 ++-- .../20090312194159_add_projects_trackers_unique_index.rb | 2 +- db/migrate/20090503121505_populate_member_roles.rb | 2 +- db/migrate/20091114105931_add_view_issues_permission.rb | 4 ++-- ...912_enable_calendar_and_gantt_modules_where_appropriate.rb | 2 +- 16 files changed, 21 insertions(+), 21 deletions(-) diff --git a/db/migrate/007_create_journals.rb b/db/migrate/007_create_journals.rb index 2731d44f0..e219ef67a 100644 --- a/db/migrate/007_create_journals.rb +++ b/db/migrate/007_create_journals.rb @@ -28,7 +28,7 @@ class CreateJournals < ActiveRecord::Migration Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0 # data migration - IssueHistory.find(:all, :include => :issue).each {|h| + IssueHistory.all.each {|h| j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on) j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id) j.save diff --git a/db/migrate/019_add_issue_status_position.rb b/db/migrate/019_add_issue_status_position.rb index ed24d27c1..012f97c22 100644 --- a/db/migrate/019_add_issue_status_position.rb +++ b/db/migrate/019_add_issue_status_position.rb @@ -1,7 +1,7 @@ class AddIssueStatusPosition < ActiveRecord::Migration def self.up add_column :issue_statuses, :position, :integer, :default => 1 - IssueStatus.find(:all).each_with_index {|status, i| status.update_attribute(:position, i+1)} + IssueStatus.all.each_with_index {|status, i| status.update_attribute(:position, i+1)} end def self.down diff --git a/db/migrate/021_add_tracker_position.rb b/db/migrate/021_add_tracker_position.rb index ef9775620..5fa8a3185 100644 --- a/db/migrate/021_add_tracker_position.rb +++ b/db/migrate/021_add_tracker_position.rb @@ -1,7 +1,7 @@ class AddTrackerPosition < ActiveRecord::Migration def self.up add_column :trackers, :position, :integer, :default => 1 - Tracker.find(:all).each_with_index {|tracker, i| tracker.update_attribute(:position, i+1)} + Tracker.all.each_with_index {|tracker, i| tracker.update_attribute(:position, i+1)} end def self.down diff --git a/db/migrate/022_serialize_possibles_values.rb b/db/migrate/022_serialize_possibles_values.rb index 5158f37fd..3e9fed0a1 100644 --- a/db/migrate/022_serialize_possibles_values.rb +++ b/db/migrate/022_serialize_possibles_values.rb @@ -1,6 +1,6 @@ class SerializePossiblesValues < ActiveRecord::Migration def self.up - CustomField.find(:all).each do |field| + CustomField.all.each do |field| if field.possible_values and field.possible_values.is_a? String field.possible_values = field.possible_values.split('|') field.save diff --git a/db/migrate/065_add_settings_updated_on.rb b/db/migrate/065_add_settings_updated_on.rb index 8c5fde33b..1fa002776 100644 --- a/db/migrate/065_add_settings_updated_on.rb +++ b/db/migrate/065_add_settings_updated_on.rb @@ -2,7 +2,7 @@ class AddSettingsUpdatedOn < ActiveRecord::Migration def self.up add_column :settings, :updated_on, :timestamp # set updated_on - Setting.find(:all).each(&:save) + Setting.all.each(&:save) end def self.down diff --git a/db/migrate/068_create_enabled_modules.rb b/db/migrate/068_create_enabled_modules.rb index 566ba1222..88005cdb6 100644 --- a/db/migrate/068_create_enabled_modules.rb +++ b/db/migrate/068_create_enabled_modules.rb @@ -7,7 +7,7 @@ class CreateEnabledModules < ActiveRecord::Migration add_index :enabled_modules, [:project_id], :name => :enabled_modules_project_id # Enable all modules for existing projects - Project.find(:all).each do |project| + Project.all.each do |project| project.enabled_module_names = Redmine::AccessControl.available_project_modules end end diff --git a/db/migrate/072_add_enumerations_position.rb b/db/migrate/072_add_enumerations_position.rb index 22558a6e9..98092e5cf 100644 --- a/db/migrate/072_add_enumerations_position.rb +++ b/db/migrate/072_add_enumerations_position.rb @@ -1,7 +1,7 @@ class AddEnumerationsPosition < ActiveRecord::Migration def self.up add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position') - Enumeration.find(:all).group_by(&:opt).each do |opt, enums| + Enumeration.all.group_by(&:opt).each do |opt, enums| enums.each_with_index do |enum, i| # do not call model callbacks Enumeration.update_all "position = #{i+1}", {:id => enum.id} diff --git a/db/migrate/078_add_custom_fields_position.rb b/db/migrate/078_add_custom_fields_position.rb index 1c42ae732..cb29098fd 100644 --- a/db/migrate/078_add_custom_fields_position.rb +++ b/db/migrate/078_add_custom_fields_position.rb @@ -1,7 +1,7 @@ class AddCustomFieldsPosition < ActiveRecord::Migration def self.up add_column(:custom_fields, :position, :integer, :default => 1) - CustomField.find(:all).group_by(&:type).each do |t, fields| + CustomField.all.group_by(&:type).each do |t, fields| fields.each_with_index do |field, i| # do not call model callbacks CustomField.update_all "position = #{i+1}", {:id => field.id} diff --git a/db/migrate/081_create_projects_trackers.rb b/db/migrate/081_create_projects_trackers.rb index 193da07f6..ddb801d31 100644 --- a/db/migrate/081_create_projects_trackers.rb +++ b/db/migrate/081_create_projects_trackers.rb @@ -7,8 +7,8 @@ class CreateProjectsTrackers < ActiveRecord::Migration add_index :projects_trackers, :project_id, :name => :projects_trackers_project_id # Associates all trackers to all projects (as it was before) - tracker_ids = Tracker.find(:all).collect(&:id) - Project.find(:all).each do |project| + tracker_ids = Tracker.all.collect(&:id) + Project.all.each do |project| project.tracker_ids = tracker_ids end end diff --git a/db/migrate/096_add_commit_access_permission.rb b/db/migrate/096_add_commit_access_permission.rb index f88e0c992..39642cdfe 100644 --- a/db/migrate/096_add_commit_access_permission.rb +++ b/db/migrate/096_add_commit_access_permission.rb @@ -1,12 +1,12 @@ class AddCommitAccessPermission < ActiveRecord::Migration def self.up - Role.find(:all).select { |r| not r.builtin? }.each do |r| + Role.all.select { |r| not r.builtin? }.each do |r| r.add_permission!(:commit_access) end end def self.down - Role.find(:all).select { |r| not r.builtin? }.each do |r| + Role.all.select { |r| not r.builtin? }.each do |r| r.remove_permission!(:commit_access) end end diff --git a/db/migrate/097_add_view_wiki_edits_permission.rb b/db/migrate/097_add_view_wiki_edits_permission.rb index ea4c4a1db..cd25f3cb1 100644 --- a/db/migrate/097_add_view_wiki_edits_permission.rb +++ b/db/migrate/097_add_view_wiki_edits_permission.rb @@ -1,12 +1,12 @@ class AddViewWikiEditsPermission < ActiveRecord::Migration def self.up - Role.find(:all).each do |r| + Role.all.each do |r| r.add_permission!(:view_wiki_edits) if r.has_permission?(:view_wiki_pages) end end def self.down - Role.find(:all).each do |r| + Role.all.each do |r| r.remove_permission!(:view_wiki_edits) end end diff --git a/db/migrate/099_add_delete_wiki_pages_attachments_permission.rb b/db/migrate/099_add_delete_wiki_pages_attachments_permission.rb index 9fd986a3c..475e4d0aa 100644 --- a/db/migrate/099_add_delete_wiki_pages_attachments_permission.rb +++ b/db/migrate/099_add_delete_wiki_pages_attachments_permission.rb @@ -1,12 +1,12 @@ class AddDeleteWikiPagesAttachmentsPermission < ActiveRecord::Migration def self.up - Role.find(:all).each do |r| + Role.all.each do |r| r.add_permission!(:delete_wiki_pages_attachments) if r.has_permission?(:edit_wiki_pages) end end def self.down - Role.find(:all).each do |r| + Role.all.each do |r| r.remove_permission!(:delete_wiki_pages_attachments) end end diff --git a/db/migrate/20090312194159_add_projects_trackers_unique_index.rb b/db/migrate/20090312194159_add_projects_trackers_unique_index.rb index 02a8fa68e..f4e3a26d2 100644 --- a/db/migrate/20090312194159_add_projects_trackers_unique_index.rb +++ b/db/migrate/20090312194159_add_projects_trackers_unique_index.rb @@ -10,7 +10,7 @@ class AddProjectsTrackersUniqueIndex < ActiveRecord::Migration # Removes duplicates in projects_trackers table def self.remove_duplicates - Project.find(:all).each do |project| + Project.all.each do |project| ids = project.trackers.collect(&:id) unless ids == ids.uniq project.trackers.clear diff --git a/db/migrate/20090503121505_populate_member_roles.rb b/db/migrate/20090503121505_populate_member_roles.rb index aae9fc611..285d7e51a 100644 --- a/db/migrate/20090503121505_populate_member_roles.rb +++ b/db/migrate/20090503121505_populate_member_roles.rb @@ -1,7 +1,7 @@ class PopulateMemberRoles < ActiveRecord::Migration def self.up MemberRole.delete_all - Member.find(:all).each do |member| + Member.all.each do |member| MemberRole.create!(:member_id => member.id, :role_id => member.role_id) end end diff --git a/db/migrate/20091114105931_add_view_issues_permission.rb b/db/migrate/20091114105931_add_view_issues_permission.rb index 5092a8c9d..d12b2deed 100644 --- a/db/migrate/20091114105931_add_view_issues_permission.rb +++ b/db/migrate/20091114105931_add_view_issues_permission.rb @@ -1,12 +1,12 @@ class AddViewIssuesPermission < ActiveRecord::Migration def self.up - Role.find(:all).each do |r| + Role.all.each do |r| r.add_permission!(:view_issues) end end def self.down - Role.find(:all).each do |r| + Role.all.each do |r| r.remove_permission!(:view_issues) end end diff --git a/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb b/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb index 416607b43..59cd40049 100644 --- a/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb +++ b/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb @@ -1,6 +1,6 @@ class EnableCalendarAndGanttModulesWhereAppropriate < ActiveRecord::Migration def self.up - EnabledModule.find(:all, :conditions => ["name = ?", 'issue_tracking']).each do |e| + EnabledModule.where(:name => 'issue_tracking').all.each do |e| EnabledModule.create(:name => 'calendar', :project_id => e.project_id) EnabledModule.create(:name => 'gantt', :project_id => e.project_id) end