##// END OF EJS Templates
Replaces find(:all) calls....
Jean-Philippe Lang -
r10690:536747b74708
parent child
Show More
@@ -258,7 +258,7 class CustomField < ActiveRecord::Base
258
258
259 # to move in project_custom_field
259 # to move in project_custom_field
260 def self.for_all
260 def self.for_all
261 find(:all, :conditions => ["is_for_all=?", true], :order => 'position')
261 where(:is_for_all => true).order('position').all
262 end
262 end
263
263
264 def type_name
264 def type_name
@@ -62,8 +62,11 class Group < Principal
62
62
63 def user_removed(user)
63 def user_removed(user)
64 members.each do |member|
64 members.each do |member|
65 MemberRole.find(:all, :include => :member,
65 MemberRole.
66 :conditions => ["#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids]).each(&:destroy)
66 includes(:member).
67 where("#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids).
68 all.
69 each(&:destroy)
67 end
70 end
68 end
71 end
69
72
@@ -281,7 +281,7 class MailHandler < ActionMailer::Base
281 if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project)
281 if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project)
282 addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase}
282 addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase}
283 unless addresses.empty?
283 unless addresses.empty?
284 watchers = User.active.find(:all, :conditions => ['LOWER(mail) IN (?)', addresses])
284 watchers = User.active.where('LOWER(mail) IN (?)', addresses).all
285 watchers.each {|w| obj.add_watcher(w)}
285 watchers.each {|w| obj.add_watcher(w)}
286 end
286 end
287 end
287 end
@@ -252,7 +252,7 class Mailer < ActionMailer::Base
252 # Mailer.account_activation_request(user).deliver => sends an email to all active administrators
252 # Mailer.account_activation_request(user).deliver => sends an email to all active administrators
253 def account_activation_request(user)
253 def account_activation_request(user)
254 # Send the email to all active administrators
254 # Send the email to all active administrators
255 recipients = User.active.find(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact
255 recipients = User.active.where(:admin => true).all.collect { |u| u.mail }.compact
256 @user = user
256 @user = user
257 @url = url_for(:controller => 'users', :action => 'index',
257 @url = url_for(:controller => 'users', :action => 'index',
258 :status => User::STATUS_REGISTERED,
258 :status => User::STATUS_REGISTERED,
@@ -54,7 +54,7 class MemberRole < ActiveRecord::Base
54 end
54 end
55
55
56 def remove_role_from_group_users
56 def remove_role_from_group_users
57 MemberRole.find(:all, :conditions => { :inherited_from => id }).group_by(&:member).each do |member, member_roles|
57 MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
58 member_roles.each(&:destroy)
58 member_roles.each(&:destroy)
59 if member && member.user
59 if member && member.user
60 Watcher.prune(:user => member.user, :project => member.project)
60 Watcher.prune(:user => member.user, :project => member.project)
@@ -138,7 +138,7 class Project < ActiveRecord::Base
138 # returns latest created projects
138 # returns latest created projects
139 # non public projects will be returned only if user is a member of those
139 # non public projects will be returned only if user is a member of those
140 def self.latest(user=nil, count=5)
140 def self.latest(user=nil, count=5)
141 visible(user).find(:all, :limit => count, :order => "created_on DESC")
141 visible(user).limit(count).order("created_on DESC").all
142 end
142 end
143
143
144 # Returns true if the project is visible to +user+ or to the current user.
144 # Returns true if the project is visible to +user+ or to the current user.
@@ -338,7 +338,7 class Project < ActiveRecord::Base
338 # by the current user
338 # by the current user
339 def allowed_parents
339 def allowed_parents
340 return @allowed_parents if @allowed_parents
340 return @allowed_parents if @allowed_parents
341 @allowed_parents = Project.find(:all, :conditions => Project.allowed_to_condition(User.current, :add_subprojects))
341 @allowed_parents = Project.where(Project.allowed_to_condition(User.current, :add_subprojects)).all
342 @allowed_parents = @allowed_parents - self_and_descendants
342 @allowed_parents = @allowed_parents - self_and_descendants
343 if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
343 if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
344 @allowed_parents << nil
344 @allowed_parents << nil
@@ -415,7 +415,7 class Project < ActiveRecord::Base
415 # Closes open and locked project versions that are completed
415 # Closes open and locked project versions that are completed
416 def close_completed_versions
416 def close_completed_versions
417 Version.transaction do
417 Version.transaction do
418 versions.find(:all, :conditions => {:status => %w(open locked)}).each do |version|
418 versions.where(:status => %w(open locked)).all.each do |version|
419 if version.completed?
419 if version.completed?
420 version.update_attribute(:status, 'closed')
420 version.update_attribute(:status, 'closed')
421 end
421 end
@@ -452,7 +452,7 class Project < ActiveRecord::Base
452
452
453 # Returns a hash of project users grouped by role
453 # Returns a hash of project users grouped by role
454 def users_by_role
454 def users_by_role
455 members.find(:all, :include => [:user, :roles]).inject({}) do |h, m|
455 members.includes(:user, :roles).all.inject({}) do |h, m|
456 m.roles.each do |r|
456 m.roles.each do |r|
457 h[r] ||= []
457 h[r] ||= []
458 h[r] << m.user
458 h[r] << m.user
@@ -786,7 +786,7 class Project < ActiveRecord::Base
786
786
787 # Get issues sorted by root_id, lft so that parent issues
787 # Get issues sorted by root_id, lft so that parent issues
788 # get copied before their children
788 # get copied before their children
789 project.issues.find(:all, :order => 'root_id, lft').each do |issue|
789 project.issues.reorder('root_id, lft').all.each do |issue|
790 new_issue = Issue.new
790 new_issue = Issue.new
791 new_issue.copy_from(issue, :subtasks => false, :link => false)
791 new_issue.copy_from(issue, :subtasks => false, :link => false)
792 new_issue.project = self
792 new_issue.project = self
@@ -929,13 +929,11 class Project < ActiveRecord::Base
929 def system_activities_and_project_overrides(include_inactive=false)
929 def system_activities_and_project_overrides(include_inactive=false)
930 if include_inactive
930 if include_inactive
931 return TimeEntryActivity.shared.
931 return TimeEntryActivity.shared.
932 find(:all,
932 where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
933 :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
934 self.time_entry_activities
933 self.time_entry_activities
935 else
934 else
936 return TimeEntryActivity.shared.active.
935 return TimeEntryActivity.shared.active.
937 find(:all,
936 where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
938 :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
939 self.time_entry_activities.active
937 self.time_entry_activities.active
940 end
938 end
941 end
939 end
@@ -218,7 +218,7 class Query < ActiveRecord::Base
218 end
218 end
219
219
220 def trackers
220 def trackers
221 @trackers ||= project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
221 @trackers ||= project.nil? ? Tracker.sorted.all : project.rolled_up_trackers
222 end
222 end
223
223
224 # Returns a hash of localized labels for all filter operators
224 # Returns a hash of localized labels for all filter operators
@@ -231,7 +231,7 class Query < ActiveRecord::Base
231 @available_filters = {
231 @available_filters = {
232 "status_id" => {
232 "status_id" => {
233 :type => :list_status, :order => 0,
233 :type => :list_status, :order => 0,
234 :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] }
234 :values => IssueStatus.sorted.all.collect{|s| [s.name, s.id.to_s] }
235 },
235 },
236 "tracker_id" => {
236 "tracker_id" => {
237 :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] }
237 :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] }
@@ -344,12 +344,7 class Query < ActiveRecord::Base
344 }
344 }
345 }
345 }
346 end
346 end
347 add_custom_fields_filters(
347 add_custom_fields_filters(IssueCustomField.where(:is_filter => true, :is_for_all => true).all)
348 IssueCustomField.find(:all,
349 :conditions => {
350 :is_filter => true,
351 :is_for_all => true
352 }))
353 end
348 end
354 add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
349 add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
355 if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||
350 if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||
@@ -455,7 +450,7 class Query < ActiveRecord::Base
455 @available_columns = ::Query.available_columns.dup
450 @available_columns = ::Query.available_columns.dup
456 @available_columns += (project ?
451 @available_columns += (project ?
457 project.all_issue_custom_fields :
452 project.all_issue_custom_fields :
458 IssueCustomField.find(:all)
453 IssueCustomField.all
459 ).collect {|cf| QueryCustomFieldColumn.new(cf) }
454 ).collect {|cf| QueryCustomFieldColumn.new(cf) }
460
455
461 if User.current.allowed_to?(:view_time_entries, project, :global => true)
456 if User.current.allowed_to?(:view_time_entries, project, :global => true)
@@ -337,7 +337,7 class Repository < ActiveRecord::Base
337
337
338 # scan changeset comments to find related and fixed issues for all repositories
338 # scan changeset comments to find related and fixed issues for all repositories
339 def self.scan_changesets_for_issue_ids
339 def self.scan_changesets_for_issue_ids
340 find(:all).each(&:scan_changesets_for_issue_ids)
340 all.each(&:scan_changesets_for_issue_ids)
341 end
341 end
342
342
343 def self.scm_name
343 def self.scm_name
@@ -92,11 +92,12 class Repository::Mercurial < Repository
92 # Sqlite3 and PostgreSQL pass.
92 # Sqlite3 and PostgreSQL pass.
93 # Is this MySQL bug?
93 # Is this MySQL bug?
94 def latest_changesets(path, rev, limit=10)
94 def latest_changesets(path, rev, limit=10)
95 changesets.find(:all,
95 changesets.
96 :include => :user,
96 includes(:user).
97 :conditions => latest_changesets_cond(path, rev, limit),
97 where(latest_changesets_cond(path, rev, limit)).
98 :limit => limit,
98 limit(limit).
99 :order => "#{Changeset.table_name}.id DESC")
99 order("#{Changeset.table_name}.id DESC").
100 all
100 end
101 end
101
102
102 def latest_changesets_cond(path, rev, limit)
103 def latest_changesets_cond(path, rev, limit)
@@ -29,7 +29,7 class Watcher < ActiveRecord::Base
29 prune_single_user(options[:user], options)
29 prune_single_user(options[:user], options)
30 else
30 else
31 pruned = 0
31 pruned = 0
32 User.find(:all, :conditions => "id IN (SELECT DISTINCT user_id FROM #{table_name})").each do |user|
32 User.where("id IN (SELECT DISTINCT user_id FROM #{table_name})").all.each do |user|
33 pruned += prune_single_user(user, options)
33 pruned += prune_single_user(user, options)
34 end
34 end
35 pruned
35 pruned
@@ -47,7 +47,7 class Watcher < ActiveRecord::Base
47 def self.prune_single_user(user, options={})
47 def self.prune_single_user(user, options={})
48 return unless user.is_a?(User)
48 return unless user.is_a?(User)
49 pruned = 0
49 pruned = 0
50 find(:all, :conditions => {:user_id => user.id}).each do |watcher|
50 where(:user_id => user.id).all.each do |watcher|
51 next if watcher.watchable.nil?
51 next if watcher.watchable.nil?
52
52
53 if options.has_key?(:project)
53 if options.has_key?(:project)
@@ -1,5 +1,5
1 <% roles = Role.find_all_givable %>
1 <% roles = Role.find_all_givable %>
2 <% projects = Project.active.find(:all, :order => 'lft') %>
2 <% projects = Project.active.all %>
3
3
4 <div class="splitcontentleft">
4 <div class="splitcontentleft">
5 <% if @group.memberships.any? %>
5 <% if @group.memberships.any? %>
@@ -1,6 +1,6
1 <%= error_messages_for 'member' %>
1 <%= error_messages_for 'member' %>
2 <% roles = Role.find_all_givable
2 <% roles = Role.find_all_givable
3 members = @project.member_principals.find(:all, :include => [:roles, :principal]).sort %>
3 members = @project.member_principals.includes(:roles, :principal).all.sort %>
4
4
5 <div class="splitcontentleft">
5 <div class="splitcontentleft">
6 <% if members.any? %>
6 <% if members.any? %>
@@ -68,7 +68,7
68 <p><%= setting_text_field :commit_fix_keywords, :size => 30 %>
68 <p><%= setting_text_field :commit_fix_keywords, :size => 30 %>
69 &nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id,
69 &nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id,
70 [["", 0]] +
70 [["", 0]] +
71 IssueStatus.find(:all).collect{
71 IssueStatus.sorted.all.collect{
72 |status| [status.name, status.id.to_s]
72 |status| [status.name, status.id.to_s]
73 },
73 },
74 :label => false %>
74 :label => false %>
@@ -1,5 +1,5
1 <% roles = Role.find_all_givable %>
1 <% roles = Role.find_all_givable %>
2 <% projects = Project.active.find(:all, :order => 'lft') %>
2 <% projects = Project.active.all %>
3
3
4 <div class="splitcontentleft">
4 <div class="splitcontentleft">
5 <% if @user.memberships.any? %>
5 <% if @user.memberships.any? %>
@@ -44,8 +44,7 module Redmine
44 end
44 end
45
45
46 def available_custom_fields
46 def available_custom_fields
47 CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'",
47 CustomField.where("type = '#{self.class.name}CustomField'").sorted.all
48 :order => 'position')
49 end
48 end
50
49
51 # Sets the values of the object's custom fields
50 # Sets the values of the object's custom fields
@@ -139,15 +139,15 module Redmine
139 rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
139 rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
140
140
141 # Workflow
141 # Workflow
142 Tracker.find(:all).each { |t|
142 Tracker.all.each { |t|
143 IssueStatus.find(:all).each { |os|
143 IssueStatus.all.each { |os|
144 IssueStatus.find(:all).each { |ns|
144 IssueStatus.all.each { |ns|
145 WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
145 WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
146 }
146 }
147 }
147 }
148 }
148 }
149
149
150 Tracker.find(:all).each { |t|
150 Tracker.all.each { |t|
151 [new, in_progress, resolved, feedback].each { |os|
151 [new, in_progress, resolved, feedback].each { |os|
152 [in_progress, resolved, feedback, closed].each { |ns|
152 [in_progress, resolved, feedback, closed].each { |ns|
153 WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
153 WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
@@ -155,7 +155,7 module Redmine
155 }
155 }
156 }
156 }
157
157
158 Tracker.find(:all).each { |t|
158 Tracker.all.each { |t|
159 [new, in_progress, resolved, feedback].each { |os|
159 [new, in_progress, resolved, feedback].each { |os|
160 [closed].each { |ns|
160 [closed].each { |ns|
161 WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
161 WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
@@ -144,14 +144,14 module Redmine
144 end if @project
144 end if @project
145
145
146 # Add list and boolean time entry custom fields
146 # Add list and boolean time entry custom fields
147 TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
147 TimeEntryCustomField.all.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
148 @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id ORDER BY c.value LIMIT 1)",
148 @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id ORDER BY c.value LIMIT 1)",
149 :format => cf.field_format,
149 :format => cf.field_format,
150 :label => cf.name}
150 :label => cf.name}
151 end
151 end
152
152
153 # Add list and boolean time entry activity custom fields
153 # Add list and boolean time entry activity custom fields
154 TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
154 TimeEntryActivityCustomField.all.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
155 @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id ORDER BY c.value LIMIT 1)",
155 @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id ORDER BY c.value LIMIT 1)",
156 :format => cf.field_format,
156 :format => cf.field_format,
157 :label => cf.name}
157 :label => cf.name}
@@ -53,7 +53,7 task :migrate_from_mantis => :environment do
53 TRACKER_BUG = Tracker.find_by_position(1)
53 TRACKER_BUG = Tracker.find_by_position(1)
54 TRACKER_FEATURE = Tracker.find_by_position(2)
54 TRACKER_FEATURE = Tracker.find_by_position(2)
55
55
56 roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
56 roles = Role.where(:builtin => 0).order('position ASC').all
57 manager_role = roles[0]
57 manager_role = roles[0]
58 developer_role = roles[1]
58 developer_role = roles[1]
59 DEFAULT_ROLE = roles.last
59 DEFAULT_ROLE = roles.last
@@ -241,7 +241,7 task :migrate_from_mantis => :environment do
241 User.delete_all "login <> 'admin'"
241 User.delete_all "login <> 'admin'"
242 users_map = {}
242 users_map = {}
243 users_migrated = 0
243 users_migrated = 0
244 MantisUser.find(:all).each do |user|
244 MantisUser.all.each do |user|
245 u = User.new :firstname => encode(user.firstname),
245 u = User.new :firstname => encode(user.firstname),
246 :lastname => encode(user.lastname),
246 :lastname => encode(user.lastname),
247 :mail => user.email,
247 :mail => user.email,
@@ -263,7 +263,7 task :migrate_from_mantis => :environment do
263 projects_map = {}
263 projects_map = {}
264 versions_map = {}
264 versions_map = {}
265 categories_map = {}
265 categories_map = {}
266 MantisProject.find(:all).each do |project|
266 MantisProject.all.each do |project|
267 p = Project.new :name => encode(project.name),
267 p = Project.new :name => encode(project.name),
268 :description => encode(project.description)
268 :description => encode(project.description)
269 p.identifier = project.identifier
269 p.identifier = project.identifier
@@ -365,7 +365,7 task :migrate_from_mantis => :environment do
365
365
366 # Bug relationships
366 # Bug relationships
367 print "Migrating bug relations"
367 print "Migrating bug relations"
368 MantisBugRelationship.find(:all).each do |relation|
368 MantisBugRelationship.all.each do |relation|
369 next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
369 next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
370 r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
370 r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
371 r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
371 r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
@@ -379,7 +379,7 task :migrate_from_mantis => :environment do
379 # News
379 # News
380 print "Migrating news"
380 print "Migrating news"
381 News.destroy_all
381 News.destroy_all
382 MantisNews.find(:all, :conditions => 'project_id > 0').each do |news|
382 MantisNews.where('project_id > 0').all.each do |news|
383 next unless projects_map[news.project_id]
383 next unless projects_map[news.project_id]
384 n = News.new :project_id => projects_map[news.project_id],
384 n = News.new :project_id => projects_map[news.project_id],
385 :title => encode(news.headline[0..59]),
385 :title => encode(news.headline[0..59]),
@@ -395,7 +395,7 task :migrate_from_mantis => :environment do
395 # Custom fields
395 # Custom fields
396 print "Migrating custom fields"
396 print "Migrating custom fields"
397 IssueCustomField.destroy_all
397 IssueCustomField.destroy_all
398 MantisCustomField.find(:all).each do |field|
398 MantisCustomField.all.each do |field|
399 f = IssueCustomField.new :name => field.name[0..29],
399 f = IssueCustomField.new :name => field.name[0..29],
400 :field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
400 :field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
401 :min_length => field.length_min,
401 :min_length => field.length_min,
@@ -407,7 +407,7 task :migrate_from_mantis => :environment do
407 print '.'
407 print '.'
408 STDOUT.flush
408 STDOUT.flush
409 # Trackers association
409 # Trackers association
410 f.trackers = Tracker.find :all
410 f.trackers = Tracker.all
411
411
412 # Projects association
412 # Projects association
413 field.projects.each do |project|
413 field.projects.each do |project|
@@ -61,7 +61,7 namespace :redmine do
61 'patch' =>TRACKER_FEATURE
61 'patch' =>TRACKER_FEATURE
62 }
62 }
63
63
64 roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
64 roles = Role.where(:builtin => 0).order('position ASC').all
65 manager_role = roles[0]
65 manager_role = roles[0]
66 developer_role = roles[1]
66 developer_role = roles[1]
67 DEFAULT_ROLE = roles.last
67 DEFAULT_ROLE = roles.last
@@ -390,7 +390,7 namespace :redmine do
390 # Components
390 # Components
391 print "Migrating components"
391 print "Migrating components"
392 issues_category_map = {}
392 issues_category_map = {}
393 TracComponent.find(:all).each do |component|
393 TracComponent.all.each do |component|
394 print '.'
394 print '.'
395 STDOUT.flush
395 STDOUT.flush
396 c = IssueCategory.new :project => @target_project,
396 c = IssueCategory.new :project => @target_project,
@@ -404,7 +404,7 namespace :redmine do
404 # Milestones
404 # Milestones
405 print "Migrating milestones"
405 print "Migrating milestones"
406 version_map = {}
406 version_map = {}
407 TracMilestone.find(:all).each do |milestone|
407 TracMilestone.all.each do |milestone|
408 print '.'
408 print '.'
409 STDOUT.flush
409 STDOUT.flush
410 # First we try to find the wiki page...
410 # First we try to find the wiki page...
@@ -443,7 +443,7 namespace :redmine do
443 :field_format => 'string')
443 :field_format => 'string')
444
444
445 next if f.new_record?
445 next if f.new_record?
446 f.trackers = Tracker.find(:all)
446 f.trackers = Tracker.all
447 f.projects << @target_project
447 f.projects << @target_project
448 custom_field_map[field.name] = f
448 custom_field_map[field.name] = f
449 end
449 end
@@ -454,7 +454,7 namespace :redmine do
454 r = IssueCustomField.new(:name => 'Resolution',
454 r = IssueCustomField.new(:name => 'Resolution',
455 :field_format => 'list',
455 :field_format => 'list',
456 :is_filter => true) if r.nil?
456 :is_filter => true) if r.nil?
457 r.trackers = Tracker.find(:all)
457 r.trackers = Tracker.all
458 r.projects << @target_project
458 r.projects << @target_project
459 r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
459 r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
460 r.save!
460 r.save!
@@ -549,7 +549,7 namespace :redmine do
549 # Wiki
549 # Wiki
550 print "Migrating wiki"
550 print "Migrating wiki"
551 if wiki.save
551 if wiki.save
552 TracWikiPage.find(:all, :order => 'name, version').each do |page|
552 TracWikiPage.order('name, version').all.each do |page|
553 # Do not migrate Trac manual wiki pages
553 # Do not migrate Trac manual wiki pages
554 next if TRAC_WIKI_PAGES.include?(page.name)
554 next if TRAC_WIKI_PAGES.include?(page.name)
555 wiki_edit_count += 1
555 wiki_edit_count += 1
@@ -34,7 +34,7 class RolesControllerTest < ActionController::TestCase
34 assert_template 'index'
34 assert_template 'index'
35
35
36 assert_not_nil assigns(:roles)
36 assert_not_nil assigns(:roles)
37 assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
37 assert_equal Role.order('builtin, position').all, assigns(:roles)
38
38
39 assert_tag :tag => 'a', :attributes => { :href => '/roles/1/edit' },
39 assert_tag :tag => 'a', :attributes => { :href => '/roles/1/edit' },
40 :content => 'Manager'
40 :content => 'Manager'
@@ -163,7 +163,7 class RolesControllerTest < ActionController::TestCase
163 assert_template 'permissions'
163 assert_template 'permissions'
164
164
165 assert_not_nil assigns(:roles)
165 assert_not_nil assigns(:roles)
166 assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
166 assert_equal Role.order('builtin, position').all, assigns(:roles)
167
167
168 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
168 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
169 :name => 'permissions[3][]',
169 :name => 'permissions[3][]',
@@ -306,7 +306,10 class WorkflowsControllerTest < ActionController::TestCase
306
306
307 # Returns an array of status transitions that can be compared
307 # Returns an array of status transitions that can be compared
308 def status_transitions(conditions)
308 def status_transitions(conditions)
309 WorkflowTransition.find(:all, :conditions => conditions,
309 WorkflowTransition.
310 :order => 'tracker_id, role_id, old_status_id, new_status_id').collect {|w| [w.old_status, w.new_status_id]}
310 where(conditions).
311 order('tracker_id, role_id, old_status_id, new_status_id').
312 all.
313 collect {|w| [w.old_status, w.new_status_id]}
311 end
314 end
312 end
315 end
@@ -139,7 +139,7 RAW
139 # link image
139 # link image
140 '!logo.gif!:http://foo.bar/' => '<a href="http://foo.bar/"><img src="/attachments/download/3" title="This is a logo" alt="This is a logo" /></a>',
140 '!logo.gif!:http://foo.bar/' => '<a href="http://foo.bar/"><img src="/attachments/download/3" title="This is a logo" alt="This is a logo" /></a>',
141 }
141 }
142 attachments = Attachment.find(:all)
142 attachments = Attachment.all
143 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
143 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
144 end
144 end
145
145
@@ -367,7 +367,7 class IssueNestedSetTest < ActiveSupport::TestCase
367 c.reload
367 c.reload
368
368
369 assert_equal 5, c.issues.count
369 assert_equal 5, c.issues.count
370 ic1, ic2, ic3, ic4, ic5 = c.issues.find(:all, :order => 'subject')
370 ic1, ic2, ic3, ic4, ic5 = c.issues.order('subject').all
371 assert ic1.root?
371 assert ic1.root?
372 assert_equal ic1, ic2.parent
372 assert_equal ic1, ic2.parent
373 assert_equal ic1, ic3.parent
373 assert_equal ic1, ic3.parent
@@ -183,7 +183,7 class ProjectTest < ActiveSupport::TestCase
183 # 2 active members
183 # 2 active members
184 assert_equal 2, @ecookbook.members.size
184 assert_equal 2, @ecookbook.members.size
185 # and 1 is locked
185 # and 1 is locked
186 assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size
186 assert_equal 3, Member.where('project_id = ?', @ecookbook.id).all.size
187 # some boards
187 # some boards
188 assert @ecookbook.boards.any?
188 assert @ecookbook.boards.any?
189
189
@@ -693,7 +693,7 class ProjectTest < ActiveSupport::TestCase
693
693
694 def test_activities_should_use_the_system_activities
694 def test_activities_should_use_the_system_activities
695 project = Project.find(1)
695 project = Project.find(1)
696 assert_equal project.activities, TimeEntryActivity.find(:all, :conditions => {:active => true} )
696 assert_equal project.activities, TimeEntryActivity.where(:active => true).all
697 end
697 end
698
698
699
699
@@ -105,7 +105,7 class RepositoryBazaarTest < ActiveSupport::TestCase
105 @project.reload
105 @project.reload
106 assert_equal NUM_REV, @repository.changesets.count
106 assert_equal NUM_REV, @repository.changesets.count
107 # Remove changesets with revision > 5
107 # Remove changesets with revision > 5
108 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
108 @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 2}
109 @project.reload
109 @project.reload
110 assert_equal 2, @repository.changesets.count
110 assert_equal 2, @repository.changesets.count
111
111
@@ -116,7 +116,7 class RepositoryCvsTest < ActiveSupport::TestCase
116 assert_equal CHANGESETS_NUM, @repository.changesets.count
116 assert_equal CHANGESETS_NUM, @repository.changesets.count
117
117
118 # Remove changesets with revision > 3
118 # Remove changesets with revision > 3
119 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
119 @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3}
120 @project.reload
120 @project.reload
121 assert_equal 3, @repository.changesets.count
121 assert_equal 3, @repository.changesets.count
122 assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision)
122 assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision)
@@ -79,7 +79,7 class RepositoryDarcsTest < ActiveSupport::TestCase
79 assert_equal NUM_REV, @repository.changesets.count
79 assert_equal NUM_REV, @repository.changesets.count
80
80
81 # Remove changesets with revision > 3
81 # Remove changesets with revision > 3
82 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
82 @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3}
83 @project.reload
83 @project.reload
84 assert_equal 3, @repository.changesets.count
84 assert_equal 3, @repository.changesets.count
85
85
@@ -102,7 +102,7 class RepositoryMercurialTest < ActiveSupport::TestCase
102 @project.reload
102 @project.reload
103 assert_equal NUM_REV, @repository.changesets.count
103 assert_equal NUM_REV, @repository.changesets.count
104 # Remove changesets with revision > 2
104 # Remove changesets with revision > 2
105 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
105 @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 2}
106 @project.reload
106 @project.reload
107 assert_equal 3, @repository.changesets.count
107 assert_equal 3, @repository.changesets.count
108
108
@@ -47,7 +47,7 class RepositorySubversionTest < ActiveSupport::TestCase
47 assert_equal NUM_REV, @repository.changesets.count
47 assert_equal NUM_REV, @repository.changesets.count
48
48
49 # Remove changesets with revision > 5
49 # Remove changesets with revision > 5
50 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
50 @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 5}
51 @project.reload
51 @project.reload
52 assert_equal 5, @repository.changesets.count
52 assert_equal 5, @repository.changesets.count
53
53
General Comments 0
You need to be logged in to leave comments. Login now