Replaces find(:all) calls.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10917 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-12-02 20:23:48 +00:00
parent 96fca0b08f
commit 536747b747
29 changed files with 70 additions and 71 deletions

View File

@ -258,7 +258,7 @@ class CustomField < ActiveRecord::Base
# to move in project_custom_field # to move in project_custom_field
def self.for_all def self.for_all
find(:all, :conditions => ["is_for_all=?", true], :order => 'position') where(:is_for_all => true).order('position').all
end end
def type_name def type_name

View File

@ -62,8 +62,11 @@ class Group < Principal
def user_removed(user) def user_removed(user)
members.each do |member| members.each do |member|
MemberRole.find(:all, :include => :member, MemberRole.
:conditions => ["#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids]).each(&:destroy) includes(:member).
where("#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids).
all.
each(&:destroy)
end end
end end

View File

@ -281,7 +281,7 @@ class MailHandler < ActionMailer::Base
if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project) if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project)
addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase} addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase}
unless addresses.empty? unless addresses.empty?
watchers = User.active.find(:all, :conditions => ['LOWER(mail) IN (?)', addresses]) watchers = User.active.where('LOWER(mail) IN (?)', addresses).all
watchers.each {|w| obj.add_watcher(w)} watchers.each {|w| obj.add_watcher(w)}
end end
end end

View File

@ -252,7 +252,7 @@ class Mailer < ActionMailer::Base
# Mailer.account_activation_request(user).deliver => sends an email to all active administrators # Mailer.account_activation_request(user).deliver => sends an email to all active administrators
def account_activation_request(user) def account_activation_request(user)
# Send the email to all active administrators # Send the email to all active administrators
recipients = User.active.find(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact recipients = User.active.where(:admin => true).all.collect { |u| u.mail }.compact
@user = user @user = user
@url = url_for(:controller => 'users', :action => 'index', @url = url_for(:controller => 'users', :action => 'index',
:status => User::STATUS_REGISTERED, :status => User::STATUS_REGISTERED,

View File

@ -54,7 +54,7 @@ class MemberRole < ActiveRecord::Base
end end
def remove_role_from_group_users def remove_role_from_group_users
MemberRole.find(:all, :conditions => { :inherited_from => id }).group_by(&:member).each do |member, member_roles| MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
member_roles.each(&:destroy) member_roles.each(&:destroy)
if member && member.user if member && member.user
Watcher.prune(:user => member.user, :project => member.project) Watcher.prune(:user => member.user, :project => member.project)

View File

@ -138,7 +138,7 @@ class Project < ActiveRecord::Base
# returns latest created projects # returns latest created projects
# non public projects will be returned only if user is a member of those # non public projects will be returned only if user is a member of those
def self.latest(user=nil, count=5) def self.latest(user=nil, count=5)
visible(user).find(:all, :limit => count, :order => "created_on DESC") visible(user).limit(count).order("created_on DESC").all
end end
# Returns true if the project is visible to +user+ or to the current user. # Returns true if the project is visible to +user+ or to the current user.
@ -338,7 +338,7 @@ class Project < ActiveRecord::Base
# by the current user # by the current user
def allowed_parents def allowed_parents
return @allowed_parents if @allowed_parents return @allowed_parents if @allowed_parents
@allowed_parents = Project.find(:all, :conditions => Project.allowed_to_condition(User.current, :add_subprojects)) @allowed_parents = Project.where(Project.allowed_to_condition(User.current, :add_subprojects)).all
@allowed_parents = @allowed_parents - self_and_descendants @allowed_parents = @allowed_parents - self_and_descendants
if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?) if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
@allowed_parents << nil @allowed_parents << nil
@ -415,7 +415,7 @@ class Project < ActiveRecord::Base
# Closes open and locked project versions that are completed # Closes open and locked project versions that are completed
def close_completed_versions def close_completed_versions
Version.transaction do Version.transaction do
versions.find(:all, :conditions => {:status => %w(open locked)}).each do |version| versions.where(:status => %w(open locked)).all.each do |version|
if version.completed? if version.completed?
version.update_attribute(:status, 'closed') version.update_attribute(:status, 'closed')
end end
@ -452,7 +452,7 @@ class Project < ActiveRecord::Base
# Returns a hash of project users grouped by role # Returns a hash of project users grouped by role
def users_by_role def users_by_role
members.find(:all, :include => [:user, :roles]).inject({}) do |h, m| members.includes(:user, :roles).all.inject({}) do |h, m|
m.roles.each do |r| m.roles.each do |r|
h[r] ||= [] h[r] ||= []
h[r] << m.user h[r] << m.user
@ -786,7 +786,7 @@ class Project < ActiveRecord::Base
# Get issues sorted by root_id, lft so that parent issues # Get issues sorted by root_id, lft so that parent issues
# get copied before their children # get copied before their children
project.issues.find(:all, :order => 'root_id, lft').each do |issue| project.issues.reorder('root_id, lft').all.each do |issue|
new_issue = Issue.new new_issue = Issue.new
new_issue.copy_from(issue, :subtasks => false, :link => false) new_issue.copy_from(issue, :subtasks => false, :link => false)
new_issue.project = self new_issue.project = self
@ -929,13 +929,11 @@ class Project < ActiveRecord::Base
def system_activities_and_project_overrides(include_inactive=false) def system_activities_and_project_overrides(include_inactive=false)
if include_inactive if include_inactive
return TimeEntryActivity.shared. return TimeEntryActivity.shared.
find(:all, where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
:conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
self.time_entry_activities self.time_entry_activities
else else
return TimeEntryActivity.shared.active. return TimeEntryActivity.shared.active.
find(:all, where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
:conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
self.time_entry_activities.active self.time_entry_activities.active
end end
end end

View File

@ -218,7 +218,7 @@ class Query < ActiveRecord::Base
end end
def trackers def trackers
@trackers ||= project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers @trackers ||= project.nil? ? Tracker.sorted.all : project.rolled_up_trackers
end end
# Returns a hash of localized labels for all filter operators # Returns a hash of localized labels for all filter operators
@ -231,7 +231,7 @@ class Query < ActiveRecord::Base
@available_filters = { @available_filters = {
"status_id" => { "status_id" => {
:type => :list_status, :order => 0, :type => :list_status, :order => 0,
:values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } :values => IssueStatus.sorted.all.collect{|s| [s.name, s.id.to_s] }
}, },
"tracker_id" => { "tracker_id" => {
:type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] }
@ -344,12 +344,7 @@ class Query < ActiveRecord::Base
} }
} }
end end
add_custom_fields_filters( add_custom_fields_filters(IssueCustomField.where(:is_filter => true, :is_for_all => true).all)
IssueCustomField.find(:all,
:conditions => {
:is_filter => true,
:is_for_all => true
}))
end end
add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
if User.current.allowed_to?(:set_issues_private, nil, :global => true) || if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||
@ -455,7 +450,7 @@ class Query < ActiveRecord::Base
@available_columns = ::Query.available_columns.dup @available_columns = ::Query.available_columns.dup
@available_columns += (project ? @available_columns += (project ?
project.all_issue_custom_fields : project.all_issue_custom_fields :
IssueCustomField.find(:all) IssueCustomField.all
).collect {|cf| QueryCustomFieldColumn.new(cf) } ).collect {|cf| QueryCustomFieldColumn.new(cf) }
if User.current.allowed_to?(:view_time_entries, project, :global => true) if User.current.allowed_to?(:view_time_entries, project, :global => true)

View File

@ -337,7 +337,7 @@ class Repository < ActiveRecord::Base
# scan changeset comments to find related and fixed issues for all repositories # scan changeset comments to find related and fixed issues for all repositories
def self.scan_changesets_for_issue_ids def self.scan_changesets_for_issue_ids
find(:all).each(&:scan_changesets_for_issue_ids) all.each(&:scan_changesets_for_issue_ids)
end end
def self.scm_name def self.scm_name

View File

@ -92,11 +92,12 @@ class Repository::Mercurial < Repository
# Sqlite3 and PostgreSQL pass. # Sqlite3 and PostgreSQL pass.
# Is this MySQL bug? # Is this MySQL bug?
def latest_changesets(path, rev, limit=10) def latest_changesets(path, rev, limit=10)
changesets.find(:all, changesets.
:include => :user, includes(:user).
:conditions => latest_changesets_cond(path, rev, limit), where(latest_changesets_cond(path, rev, limit)).
:limit => limit, limit(limit).
:order => "#{Changeset.table_name}.id DESC") order("#{Changeset.table_name}.id DESC").
all
end end
def latest_changesets_cond(path, rev, limit) def latest_changesets_cond(path, rev, limit)

View File

@ -29,7 +29,7 @@ class Watcher < ActiveRecord::Base
prune_single_user(options[:user], options) prune_single_user(options[:user], options)
else else
pruned = 0 pruned = 0
User.find(:all, :conditions => "id IN (SELECT DISTINCT user_id FROM #{table_name})").each do |user| User.where("id IN (SELECT DISTINCT user_id FROM #{table_name})").all.each do |user|
pruned += prune_single_user(user, options) pruned += prune_single_user(user, options)
end end
pruned pruned
@ -47,7 +47,7 @@ class Watcher < ActiveRecord::Base
def self.prune_single_user(user, options={}) def self.prune_single_user(user, options={})
return unless user.is_a?(User) return unless user.is_a?(User)
pruned = 0 pruned = 0
find(:all, :conditions => {:user_id => user.id}).each do |watcher| where(:user_id => user.id).all.each do |watcher|
next if watcher.watchable.nil? next if watcher.watchable.nil?
if options.has_key?(:project) if options.has_key?(:project)

View File

@ -1,5 +1,5 @@
<% roles = Role.find_all_givable %> <% roles = Role.find_all_givable %>
<% projects = Project.active.find(:all, :order => 'lft') %> <% projects = Project.active.all %>
<div class="splitcontentleft"> <div class="splitcontentleft">
<% if @group.memberships.any? %> <% if @group.memberships.any? %>

View File

@ -1,6 +1,6 @@
<%= error_messages_for 'member' %> <%= error_messages_for 'member' %>
<% roles = Role.find_all_givable <% roles = Role.find_all_givable
members = @project.member_principals.find(:all, :include => [:roles, :principal]).sort %> members = @project.member_principals.includes(:roles, :principal).all.sort %>
<div class="splitcontentleft"> <div class="splitcontentleft">
<% if members.any? %> <% if members.any? %>

View File

@ -68,7 +68,7 @@
<p><%= setting_text_field :commit_fix_keywords, :size => 30 %> <p><%= setting_text_field :commit_fix_keywords, :size => 30 %>
&nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id, &nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id,
[["", 0]] + [["", 0]] +
IssueStatus.find(:all).collect{ IssueStatus.sorted.all.collect{
|status| [status.name, status.id.to_s] |status| [status.name, status.id.to_s]
}, },
:label => false %> :label => false %>

View File

@ -1,5 +1,5 @@
<% roles = Role.find_all_givable %> <% roles = Role.find_all_givable %>
<% projects = Project.active.find(:all, :order => 'lft') %> <% projects = Project.active.all %>
<div class="splitcontentleft"> <div class="splitcontentleft">
<% if @user.memberships.any? %> <% if @user.memberships.any? %>

View File

@ -44,8 +44,7 @@ module Redmine
end end
def available_custom_fields def available_custom_fields
CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'", CustomField.where("type = '#{self.class.name}CustomField'").sorted.all
:order => 'position')
end end
# Sets the values of the object's custom fields # Sets the values of the object's custom fields

View File

@ -139,15 +139,15 @@ module Redmine
rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6) rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
# Workflow # Workflow
Tracker.find(:all).each { |t| Tracker.all.each { |t|
IssueStatus.find(:all).each { |os| IssueStatus.all.each { |os|
IssueStatus.find(:all).each { |ns| IssueStatus.all.each { |ns|
WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
} }
} }
} }
Tracker.find(:all).each { |t| Tracker.all.each { |t|
[new, in_progress, resolved, feedback].each { |os| [new, in_progress, resolved, feedback].each { |os|
[in_progress, resolved, feedback, closed].each { |ns| [in_progress, resolved, feedback, closed].each { |ns|
WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns 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
} }
} }
Tracker.find(:all).each { |t| Tracker.all.each { |t|
[new, in_progress, resolved, feedback].each { |os| [new, in_progress, resolved, feedback].each { |os|
[closed].each { |ns| [closed].each { |ns|
WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns

View File

@ -144,14 +144,14 @@ module Redmine
end if @project end if @project
# Add list and boolean time entry custom fields # Add list and boolean time entry custom fields
TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| TimeEntryCustomField.all.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
@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)", @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)",
:format => cf.field_format, :format => cf.field_format,
:label => cf.name} :label => cf.name}
end end
# Add list and boolean time entry activity custom fields # Add list and boolean time entry activity custom fields
TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| TimeEntryActivityCustomField.all.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
@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)", @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)",
:format => cf.field_format, :format => cf.field_format,
:label => cf.name} :label => cf.name}

View File

@ -53,7 +53,7 @@ task :migrate_from_mantis => :environment do
TRACKER_BUG = Tracker.find_by_position(1) TRACKER_BUG = Tracker.find_by_position(1)
TRACKER_FEATURE = Tracker.find_by_position(2) TRACKER_FEATURE = Tracker.find_by_position(2)
roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC') roles = Role.where(:builtin => 0).order('position ASC').all
manager_role = roles[0] manager_role = roles[0]
developer_role = roles[1] developer_role = roles[1]
DEFAULT_ROLE = roles.last DEFAULT_ROLE = roles.last
@ -241,7 +241,7 @@ task :migrate_from_mantis => :environment do
User.delete_all "login <> 'admin'" User.delete_all "login <> 'admin'"
users_map = {} users_map = {}
users_migrated = 0 users_migrated = 0
MantisUser.find(:all).each do |user| MantisUser.all.each do |user|
u = User.new :firstname => encode(user.firstname), u = User.new :firstname => encode(user.firstname),
:lastname => encode(user.lastname), :lastname => encode(user.lastname),
:mail => user.email, :mail => user.email,
@ -263,7 +263,7 @@ task :migrate_from_mantis => :environment do
projects_map = {} projects_map = {}
versions_map = {} versions_map = {}
categories_map = {} categories_map = {}
MantisProject.find(:all).each do |project| MantisProject.all.each do |project|
p = Project.new :name => encode(project.name), p = Project.new :name => encode(project.name),
:description => encode(project.description) :description => encode(project.description)
p.identifier = project.identifier p.identifier = project.identifier
@ -365,7 +365,7 @@ task :migrate_from_mantis => :environment do
# Bug relationships # Bug relationships
print "Migrating bug relations" print "Migrating bug relations"
MantisBugRelationship.find(:all).each do |relation| MantisBugRelationship.all.each do |relation|
next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id] next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type] r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id]) r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
@ -379,7 +379,7 @@ task :migrate_from_mantis => :environment do
# News # News
print "Migrating news" print "Migrating news"
News.destroy_all News.destroy_all
MantisNews.find(:all, :conditions => 'project_id > 0').each do |news| MantisNews.where('project_id > 0').all.each do |news|
next unless projects_map[news.project_id] next unless projects_map[news.project_id]
n = News.new :project_id => projects_map[news.project_id], n = News.new :project_id => projects_map[news.project_id],
:title => encode(news.headline[0..59]), :title => encode(news.headline[0..59]),
@ -395,7 +395,7 @@ task :migrate_from_mantis => :environment do
# Custom fields # Custom fields
print "Migrating custom fields" print "Migrating custom fields"
IssueCustomField.destroy_all IssueCustomField.destroy_all
MantisCustomField.find(:all).each do |field| MantisCustomField.all.each do |field|
f = IssueCustomField.new :name => field.name[0..29], f = IssueCustomField.new :name => field.name[0..29],
:field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format], :field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
:min_length => field.length_min, :min_length => field.length_min,
@ -407,7 +407,7 @@ task :migrate_from_mantis => :environment do
print '.' print '.'
STDOUT.flush STDOUT.flush
# Trackers association # Trackers association
f.trackers = Tracker.find :all f.trackers = Tracker.all
# Projects association # Projects association
field.projects.each do |project| field.projects.each do |project|

View File

@ -61,7 +61,7 @@ namespace :redmine do
'patch' =>TRACKER_FEATURE 'patch' =>TRACKER_FEATURE
} }
roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC') roles = Role.where(:builtin => 0).order('position ASC').all
manager_role = roles[0] manager_role = roles[0]
developer_role = roles[1] developer_role = roles[1]
DEFAULT_ROLE = roles.last DEFAULT_ROLE = roles.last
@ -390,7 +390,7 @@ namespace :redmine do
# Components # Components
print "Migrating components" print "Migrating components"
issues_category_map = {} issues_category_map = {}
TracComponent.find(:all).each do |component| TracComponent.all.each do |component|
print '.' print '.'
STDOUT.flush STDOUT.flush
c = IssueCategory.new :project => @target_project, c = IssueCategory.new :project => @target_project,
@ -404,7 +404,7 @@ namespace :redmine do
# Milestones # Milestones
print "Migrating milestones" print "Migrating milestones"
version_map = {} version_map = {}
TracMilestone.find(:all).each do |milestone| TracMilestone.all.each do |milestone|
print '.' print '.'
STDOUT.flush STDOUT.flush
# First we try to find the wiki page... # First we try to find the wiki page...
@ -443,7 +443,7 @@ namespace :redmine do
:field_format => 'string') :field_format => 'string')
next if f.new_record? next if f.new_record?
f.trackers = Tracker.find(:all) f.trackers = Tracker.all
f.projects << @target_project f.projects << @target_project
custom_field_map[field.name] = f custom_field_map[field.name] = f
end end
@ -454,7 +454,7 @@ namespace :redmine do
r = IssueCustomField.new(:name => 'Resolution', r = IssueCustomField.new(:name => 'Resolution',
:field_format => 'list', :field_format => 'list',
:is_filter => true) if r.nil? :is_filter => true) if r.nil?
r.trackers = Tracker.find(:all) r.trackers = Tracker.all
r.projects << @target_project r.projects << @target_project
r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
r.save! r.save!
@ -549,7 +549,7 @@ namespace :redmine do
# Wiki # Wiki
print "Migrating wiki" print "Migrating wiki"
if wiki.save if wiki.save
TracWikiPage.find(:all, :order => 'name, version').each do |page| TracWikiPage.order('name, version').all.each do |page|
# Do not migrate Trac manual wiki pages # Do not migrate Trac manual wiki pages
next if TRAC_WIKI_PAGES.include?(page.name) next if TRAC_WIKI_PAGES.include?(page.name)
wiki_edit_count += 1 wiki_edit_count += 1

View File

@ -34,7 +34,7 @@ class RolesControllerTest < ActionController::TestCase
assert_template 'index' assert_template 'index'
assert_not_nil assigns(:roles) assert_not_nil assigns(:roles)
assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles) assert_equal Role.order('builtin, position').all, assigns(:roles)
assert_tag :tag => 'a', :attributes => { :href => '/roles/1/edit' }, assert_tag :tag => 'a', :attributes => { :href => '/roles/1/edit' },
:content => 'Manager' :content => 'Manager'
@ -163,7 +163,7 @@ class RolesControllerTest < ActionController::TestCase
assert_template 'permissions' assert_template 'permissions'
assert_not_nil assigns(:roles) assert_not_nil assigns(:roles)
assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles) assert_equal Role.order('builtin, position').all, assigns(:roles)
assert_tag :tag => 'input', :attributes => { :type => 'checkbox', assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'permissions[3][]', :name => 'permissions[3][]',

View File

@ -306,7 +306,10 @@ class WorkflowsControllerTest < ActionController::TestCase
# Returns an array of status transitions that can be compared # Returns an array of status transitions that can be compared
def status_transitions(conditions) def status_transitions(conditions)
WorkflowTransition.find(:all, :conditions => conditions, WorkflowTransition.
:order => 'tracker_id, role_id, old_status_id, new_status_id').collect {|w| [w.old_status, w.new_status_id]} where(conditions).
order('tracker_id, role_id, old_status_id, new_status_id').
all.
collect {|w| [w.old_status, w.new_status_id]}
end end
end end

View File

@ -139,7 +139,7 @@ RAW
# link image # link image
'!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>', '!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>',
} }
attachments = Attachment.find(:all) attachments = Attachment.all
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
end end

View File

@ -367,7 +367,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase
c.reload c.reload
assert_equal 5, c.issues.count assert_equal 5, c.issues.count
ic1, ic2, ic3, ic4, ic5 = c.issues.find(:all, :order => 'subject') ic1, ic2, ic3, ic4, ic5 = c.issues.order('subject').all
assert ic1.root? assert ic1.root?
assert_equal ic1, ic2.parent assert_equal ic1, ic2.parent
assert_equal ic1, ic3.parent assert_equal ic1, ic3.parent

View File

@ -183,7 +183,7 @@ class ProjectTest < ActiveSupport::TestCase
# 2 active members # 2 active members
assert_equal 2, @ecookbook.members.size assert_equal 2, @ecookbook.members.size
# and 1 is locked # and 1 is locked
assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size assert_equal 3, Member.where('project_id = ?', @ecookbook.id).all.size
# some boards # some boards
assert @ecookbook.boards.any? assert @ecookbook.boards.any?
@ -693,7 +693,7 @@ class ProjectTest < ActiveSupport::TestCase
def test_activities_should_use_the_system_activities def test_activities_should_use_the_system_activities
project = Project.find(1) project = Project.find(1)
assert_equal project.activities, TimeEntryActivity.find(:all, :conditions => {:active => true} ) assert_equal project.activities, TimeEntryActivity.where(:active => true).all
end end

View File

@ -105,7 +105,7 @@ class RepositoryBazaarTest < ActiveSupport::TestCase
@project.reload @project.reload
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
# Remove changesets with revision > 5 # Remove changesets with revision > 5
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 2}
@project.reload @project.reload
assert_equal 2, @repository.changesets.count assert_equal 2, @repository.changesets.count

View File

@ -116,7 +116,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
assert_equal CHANGESETS_NUM, @repository.changesets.count assert_equal CHANGESETS_NUM, @repository.changesets.count
# Remove changesets with revision > 3 # Remove changesets with revision > 3
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3}
@project.reload @project.reload
assert_equal 3, @repository.changesets.count assert_equal 3, @repository.changesets.count
assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision) assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision)

View File

@ -79,7 +79,7 @@ class RepositoryDarcsTest < ActiveSupport::TestCase
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
# Remove changesets with revision > 3 # Remove changesets with revision > 3
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3}
@project.reload @project.reload
assert_equal 3, @repository.changesets.count assert_equal 3, @repository.changesets.count

View File

@ -102,7 +102,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
@project.reload @project.reload
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
# Remove changesets with revision > 2 # Remove changesets with revision > 2
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 2}
@project.reload @project.reload
assert_equal 3, @repository.changesets.count assert_equal 3, @repository.changesets.count

View File

@ -47,7 +47,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
# Remove changesets with revision > 5 # Remove changesets with revision > 5
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5} @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 5}
@project.reload @project.reload
assert_equal 5, @repository.changesets.count assert_equal 5, @repository.changesets.count