Cleanup of finders with :conditions option.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11963 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
136cdc765a
commit
f9ddb562d5
|
@ -71,8 +71,7 @@ class ContextMenusController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_entries
|
def time_entries
|
||||||
@time_entries = TimeEntry.all(
|
@time_entries = TimeEntry.where(:id => params[:ids]).preload(:project).to_a
|
||||||
:conditions => {:id => params[:ids]}, :include => :project)
|
|
||||||
(render_404; return) unless @time_entries.present?
|
(render_404; return) unless @time_entries.present?
|
||||||
|
|
||||||
@projects = @time_entries.collect(&:project).compact.uniq
|
@projects = @time_entries.collect(&:project).compact.uniq
|
||||||
|
|
|
@ -301,7 +301,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
|
@hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
|
||||||
if @hours > 0
|
if @hours > 0
|
||||||
case params[:todo]
|
case params[:todo]
|
||||||
when 'destroy'
|
when 'destroy'
|
||||||
|
|
|
@ -35,7 +35,7 @@ class MessagesController < ApplicationController
|
||||||
page = params[:page]
|
page = params[:page]
|
||||||
# Find the page of the requested reply
|
# Find the page of the requested reply
|
||||||
if params[:r] && page.nil?
|
if params[:r] && page.nil?
|
||||||
offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
|
offset = @topic.children.where("#{Message.table_name}.id < ?", params[:r].to_i).count
|
||||||
page = 1 + offset / REPLIES_PER_PAGE
|
page = 1 + offset / REPLIES_PER_PAGE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ class ProjectsController < ApplicationController
|
||||||
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
|
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
|
||||||
|
|
||||||
if User.current.allowed_to?(:view_time_entries, @project)
|
if User.current.allowed_to?(:view_time_entries, @project)
|
||||||
@total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
|
@total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
@key = User.current.rss_key
|
@key = User.current.rss_key
|
||||||
|
|
|
@ -352,15 +352,18 @@ class RepositoriesController < ApplicationController
|
||||||
@date_to = Date.today
|
@date_to = Date.today
|
||||||
@date_from = @date_to << 11
|
@date_from = @date_to << 11
|
||||||
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
||||||
commits_by_day = Changeset.count(
|
commits_by_day = Changeset.
|
||||||
:all, :group => :commit_date,
|
where("repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to).
|
||||||
:conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
group(:commit_date).
|
||||||
|
count
|
||||||
commits_by_month = [0] * 12
|
commits_by_month = [0] * 12
|
||||||
commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
||||||
|
|
||||||
changes_by_day = Change.count(
|
changes_by_day = Change.
|
||||||
:all, :group => :commit_date, :include => :changeset,
|
joins(:changeset).
|
||||||
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
where("#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to).
|
||||||
|
group(:commit_date).
|
||||||
|
count
|
||||||
changes_by_month = [0] * 12
|
changes_by_month = [0] * 12
|
||||||
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
||||||
|
|
||||||
|
@ -393,10 +396,10 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def graph_commits_per_author(repository)
|
def graph_commits_per_author(repository)
|
||||||
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
|
commits_by_author = Changeset.where("repository_id = ?", repository.id).group(:committer).count
|
||||||
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
|
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
|
||||||
|
|
||||||
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
|
changes_by_author = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", repository.id).group(:committer).count
|
||||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||||
|
|
||||||
fields = commits_by_author.collect {|r| r.first}
|
fields = commits_by_author.collect {|r| r.first}
|
||||||
|
|
|
@ -19,11 +19,7 @@ class SysController < ActionController::Base
|
||||||
before_filter :check_enabled
|
before_filter :check_enabled
|
||||||
|
|
||||||
def projects
|
def projects
|
||||||
p = Project.active.has_module(:repository).find(
|
p = Project.active.has_module(:repository).order("#{Project.table_name}.identifier").preload(:repository).all
|
||||||
:all,
|
|
||||||
:include => :repository,
|
|
||||||
:order => "#{Project.table_name}.identifier"
|
|
||||||
)
|
|
||||||
# extra_info attribute from repository breaks activeresource client
|
# extra_info attribute from repository breaks activeresource client
|
||||||
render :xml => p.to_xml(
|
render :xml => p.to_xml(
|
||||||
:only => [:id, :identifier, :name, :is_public, :status],
|
:only => [:id, :identifier, :name, :is_public, :status],
|
||||||
|
|
|
@ -60,7 +60,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
# show projects based on current user visibility
|
# show projects based on current user visibility
|
||||||
@memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
@memberships = @user.memberships.where(Project.visible_condition(User.current)).all
|
||||||
|
|
||||||
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
||||||
@events_by_day = events.group_by(&:event_date)
|
@events_by_day = events.group_by(&:event_date)
|
||||||
|
|
|
@ -46,11 +46,11 @@ class VersionsController < ApplicationController
|
||||||
|
|
||||||
@issues_by_version = {}
|
@issues_by_version = {}
|
||||||
if @selected_tracker_ids.any? && @versions.any?
|
if @selected_tracker_ids.any? && @versions.any?
|
||||||
issues = Issue.visible.all(
|
issues = Issue.visible.
|
||||||
:include => [:project, :status, :tracker, :priority, :fixed_version],
|
includes(:project, :tracker).
|
||||||
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)},
|
preload(:status, :priority, :fixed_version).
|
||||||
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id"
|
where(:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)).
|
||||||
)
|
order("#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
|
||||||
@issues_by_version = issues.group_by(&:fixed_version)
|
@issues_by_version = issues.group_by(&:fixed_version)
|
||||||
end
|
end
|
||||||
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
||||||
|
|
|
@ -185,7 +185,7 @@ module QueriesHelper
|
||||||
if !params[:query_id].blank?
|
if !params[:query_id].blank?
|
||||||
cond = "project_id IS NULL"
|
cond = "project_id IS NULL"
|
||||||
cond << " OR project_id = #{@project.id}" if @project
|
cond << " OR project_id = #{@project.id}" if @project
|
||||||
@query = IssueQuery.find(params[:query_id], :conditions => cond)
|
@query = IssueQuery.where(cond).find(params[:query_id])
|
||||||
raise ::Unauthorized unless @query.visible?
|
raise ::Unauthorized unless @query.visible?
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
||||||
|
|
|
@ -35,12 +35,9 @@ module VersionsHelper
|
||||||
h = Hash.new {|k,v| k[v] = [0, 0]}
|
h = Hash.new {|k,v| k[v] = [0, 0]}
|
||||||
begin
|
begin
|
||||||
# Total issue count
|
# Total issue count
|
||||||
Issue.count(:group => criteria,
|
Issue.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][0] = s}
|
||||||
:conditions => ["#{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s}
|
|
||||||
# Open issues count
|
# Open issues count
|
||||||
Issue.count(:group => criteria,
|
Issue.open.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][1] = s}
|
||||||
:include => :status,
|
|
||||||
:conditions => ["#{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s}
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
# When grouping by an association, Rails throws this exception if there's no result (bug)
|
# When grouping by an association, Rails throws this exception if there's no result (bug)
|
||||||
end
|
end
|
||||||
|
|
|
@ -812,7 +812,7 @@ class Issue < ActiveRecord::Base
|
||||||
# Preloads relations for a collection of issues
|
# Preloads relations for a collection of issues
|
||||||
def self.load_relations(issues)
|
def self.load_relations(issues)
|
||||||
if issues.any?
|
if issues.any?
|
||||||
relations = IssueRelation.all(:conditions => ["issue_from_id IN (:ids) OR issue_to_id IN (:ids)", {:ids => issues.map(&:id)}])
|
relations = IssueRelation.where("issue_from_id IN (:ids) OR issue_to_id IN (:ids)", :ids => issues.map(&:id)).all
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
|
issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
|
||||||
end
|
end
|
||||||
|
@ -822,7 +822,7 @@ class Issue < ActiveRecord::Base
|
||||||
# Preloads visible spent time for a collection of issues
|
# Preloads visible spent time for a collection of issues
|
||||||
def self.load_visible_spent_hours(issues, user=User.current)
|
def self.load_visible_spent_hours(issues, user=User.current)
|
||||||
if issues.any?
|
if issues.any?
|
||||||
hours_by_issue_id = TimeEntry.visible(user).sum(:hours, :group => :issue_id)
|
hours_by_issue_id = TimeEntry.visible(user).group(:issue_id).sum(:hours)
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
|
issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
|
||||||
end
|
end
|
||||||
|
@ -850,7 +850,7 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
# Finds an issue relation given its id.
|
# Finds an issue relation given its id.
|
||||||
def find_relation(relation_id)
|
def find_relation(relation_id)
|
||||||
IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
|
IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns all the other issues that depend on the issue
|
# Returns all the other issues that depend on the issue
|
||||||
|
@ -1350,12 +1350,11 @@ class Issue < ActiveRecord::Base
|
||||||
def self.update_versions(conditions=nil)
|
def self.update_versions(conditions=nil)
|
||||||
# Only need to update issues with a fixed_version from
|
# Only need to update issues with a fixed_version from
|
||||||
# a different project and that is not systemwide shared
|
# a different project and that is not systemwide shared
|
||||||
Issue.scoped(:conditions => conditions).all(
|
Issue.includes(:project, :fixed_version).
|
||||||
:conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
|
where("#{Issue.table_name}.fixed_version_id IS NOT NULL" +
|
||||||
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
|
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
|
||||||
" AND #{Version.table_name}.sharing <> 'system'",
|
" AND #{Version.table_name}.sharing <> 'system'").
|
||||||
:include => [:project, :fixed_version]
|
where(conditions).each do |issue|
|
||||||
).each do |issue|
|
|
||||||
next if issue.project.nil? || issue.fixed_version.nil?
|
next if issue.project.nil? || issue.fixed_version.nil?
|
||||||
unless issue.project.shared_versions.include?(issue.fixed_version)
|
unless issue.project.shared_versions.include?(issue.fixed_version)
|
||||||
issue.init_journal(User.current)
|
issue.init_journal(User.current)
|
||||||
|
|
|
@ -226,7 +226,7 @@ class IssueQuery < Query
|
||||||
|
|
||||||
# Returns the issue count
|
# Returns the issue count
|
||||||
def issue_count
|
def issue_count
|
||||||
Issue.visible.count(:include => [:status, :project], :conditions => statement)
|
Issue.visible.joins(:status, :project).where(statement).count
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
@ -237,7 +237,12 @@ class IssueQuery < Query
|
||||||
if grouped?
|
if grouped?
|
||||||
begin
|
begin
|
||||||
# Rails3 will raise an (unexpected) RecordNotFound if there's only a nil group value
|
# Rails3 will raise an (unexpected) RecordNotFound if there's only a nil group value
|
||||||
r = Issue.visible.count(:joins => joins_for_order_statement(group_by_statement), :group => group_by_statement, :include => [:status, :project], :conditions => statement)
|
r = Issue.visible.
|
||||||
|
joins(:status, :project).
|
||||||
|
where(statement).
|
||||||
|
joins(joins_for_order_statement(group_by_statement)).
|
||||||
|
group(group_by_statement).
|
||||||
|
count
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
r = {nil => issue_count}
|
r = {nil => issue_count}
|
||||||
end
|
end
|
||||||
|
@ -256,14 +261,16 @@ class IssueQuery < Query
|
||||||
def issues(options={})
|
def issues(options={})
|
||||||
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
||||||
|
|
||||||
issues = Issue.visible.where(options[:conditions]).all(
|
issues = Issue.visible.
|
||||||
:include => ([:status, :project] + (options[:include] || [])).uniq,
|
joins(:status, :project).
|
||||||
:conditions => statement,
|
where(statement).
|
||||||
:order => order_option,
|
includes(([:status, :project] + (options[:include] || [])).uniq).
|
||||||
:joins => joins_for_order_statement(order_option.join(',')),
|
where(options[:conditions]).
|
||||||
:limit => options[:limit],
|
order(order_option).
|
||||||
:offset => options[:offset]
|
joins(joins_for_order_statement(order_option.join(','))).
|
||||||
)
|
limit(options[:limit]).
|
||||||
|
offset(options[:offset]).
|
||||||
|
all
|
||||||
|
|
||||||
if has_column?(:spent_hours)
|
if has_column?(:spent_hours)
|
||||||
Issue.load_visible_spent_hours(issues)
|
Issue.load_visible_spent_hours(issues)
|
||||||
|
@ -280,12 +287,16 @@ class IssueQuery < Query
|
||||||
def issue_ids(options={})
|
def issue_ids(options={})
|
||||||
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
||||||
|
|
||||||
Issue.visible.scoped(:conditions => options[:conditions]).scoped(:include => ([:status, :project] + (options[:include] || [])).uniq,
|
Issue.visible.
|
||||||
:conditions => statement,
|
joins(:status, :project).
|
||||||
:order => order_option,
|
where(statement).
|
||||||
:joins => joins_for_order_statement(order_option.join(',')),
|
includes(([:status, :project] + (options[:include] || [])).uniq).
|
||||||
:limit => options[:limit],
|
where(options[:conditions]).
|
||||||
:offset => options[:offset]).find_ids
|
order(order_option).
|
||||||
|
joins(joins_for_order_statement(order_option.join(','))).
|
||||||
|
limit(options[:limit]).
|
||||||
|
offset(options[:offset]).
|
||||||
|
find_ids
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
@ -293,13 +304,14 @@ class IssueQuery < Query
|
||||||
# Returns the journals
|
# Returns the journals
|
||||||
# Valid options are :order, :offset, :limit
|
# Valid options are :order, :offset, :limit
|
||||||
def journals(options={})
|
def journals(options={})
|
||||||
Journal.visible.all(
|
Journal.visible.
|
||||||
:include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}],
|
joins(:issue => [:project, :status]).
|
||||||
:conditions => statement,
|
where(statement).
|
||||||
:order => options[:order],
|
order(options[:order]).
|
||||||
:limit => options[:limit],
|
limit(options[:limit]).
|
||||||
:offset => options[:offset]
|
offset(options[:offset]).
|
||||||
)
|
preload(:details, :user, {:issue => [:project, :author, :tracker, :status]}).
|
||||||
|
all
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
@ -307,10 +319,11 @@ class IssueQuery < Query
|
||||||
# Returns the versions
|
# Returns the versions
|
||||||
# Valid options are :conditions
|
# Valid options are :conditions
|
||||||
def versions(options={})
|
def versions(options={})
|
||||||
Version.visible.where(options[:conditions]).all(
|
Version.visible.
|
||||||
:include => :project,
|
where(project_statement).
|
||||||
:conditions => project_statement
|
where(options[:conditions]).
|
||||||
)
|
includes(:project).
|
||||||
|
all
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
|
|
@ -249,19 +249,18 @@ class Repository < ActiveRecord::Base
|
||||||
# Default behaviour is to search in cached changesets
|
# Default behaviour is to search in cached changesets
|
||||||
def latest_changesets(path, rev, limit=10)
|
def latest_changesets(path, rev, limit=10)
|
||||||
if path.blank?
|
if path.blank?
|
||||||
changesets.find(
|
changesets.
|
||||||
:all,
|
reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
|
||||||
:include => :user,
|
limit(limit).
|
||||||
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
preload(:user).
|
||||||
:limit => limit)
|
all
|
||||||
else
|
else
|
||||||
filechanges.find(
|
filechanges.
|
||||||
:all,
|
where("path = ?", path.with_leading_slash).
|
||||||
:include => {:changeset => :user},
|
reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
|
||||||
:conditions => ["path = ?", path.with_leading_slash],
|
limit(limit).
|
||||||
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
preload(:changeset => :user).
|
||||||
:limit => limit
|
collect(&:changeset)
|
||||||
).collect(&:changeset)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -393,7 +392,7 @@ class Repository < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_as_default?
|
def set_as_default?
|
||||||
new_record? && project && !Repository.first(:conditions => {:project_id => project.id})
|
new_record? && project && Repository.where(:project_id => project.id).empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -68,15 +68,11 @@ class Repository::Bazaar < Repository
|
||||||
full_path = File.join(root_url, e.path)
|
full_path = File.join(root_url, e.path)
|
||||||
e.size = File.stat(full_path).size if File.file?(full_path)
|
e.size = File.stat(full_path).size if File.file?(full_path)
|
||||||
end
|
end
|
||||||
c = Change.find(
|
c = Change.
|
||||||
:first,
|
includes(:changeset).
|
||||||
:include => :changeset,
|
where("#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id).
|
||||||
:conditions => [
|
order("#{Changeset.table_name}.revision DESC").
|
||||||
"#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?",
|
first
|
||||||
e.lastrev.revision,
|
|
||||||
id
|
|
||||||
],
|
|
||||||
:order => "#{Changeset.table_name}.revision DESC")
|
|
||||||
if c
|
if c
|
||||||
e.lastrev.identifier = c.changeset.revision
|
e.lastrev.identifier = c.changeset.revision
|
||||||
e.lastrev.name = c.changeset.revision
|
e.lastrev.name = c.changeset.revision
|
||||||
|
|
|
@ -143,14 +143,11 @@ class Repository::Cvs < Repository
|
||||||
)
|
)
|
||||||
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
|
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
|
||||||
author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding)
|
author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding)
|
||||||
cs = changesets.find(
|
cs = changesets.where(
|
||||||
:first,
|
:committed_on => tmp_time - time_delta .. tmp_time + time_delta,
|
||||||
:conditions => {
|
:committer => author_utf8,
|
||||||
:committed_on => tmp_time - time_delta .. tmp_time + time_delta,
|
:comments => cmt
|
||||||
:committer => author_utf8,
|
).first
|
||||||
:comments => cmt
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# create a new changeset....
|
# create a new changeset....
|
||||||
unless cs
|
unless cs
|
||||||
# we use a temporaray revision number here (just for inserting)
|
# we use a temporaray revision number here (just for inserting)
|
||||||
|
@ -185,10 +182,10 @@ class Repository::Cvs < Repository
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renumber new changesets in chronological order
|
# Renumber new changesets in chronological order
|
||||||
Changeset.all(
|
Changeset.
|
||||||
:order => 'committed_on ASC, id ASC',
|
order('committed_on ASC, id ASC').
|
||||||
:conditions => ["repository_id = ? AND revision LIKE 'tmp%'", id]
|
where("repository_id = ? AND revision LIKE 'tmp%'", id).
|
||||||
).each do |changeset|
|
each do |changeset|
|
||||||
changeset.update_attribute :revision, next_revision_number
|
changeset.update_attribute :revision, next_revision_number
|
||||||
end
|
end
|
||||||
end # transaction
|
end # transaction
|
||||||
|
|
|
@ -191,13 +191,8 @@ class Repository::Git < Repository
|
||||||
offset = 0
|
offset = 0
|
||||||
revisions_copy = revisions.clone # revisions will change
|
revisions_copy = revisions.clone # revisions will change
|
||||||
while offset < revisions_copy.size
|
while offset < revisions_copy.size
|
||||||
recent_changesets_slice = changesets.find(
|
scmids = revisions_copy.slice(offset, limit).map{|x| x.scmid}
|
||||||
:all,
|
recent_changesets_slice = changesets.where(:scmid => scmids).all
|
||||||
:conditions => [
|
|
||||||
'scmid IN (?)',
|
|
||||||
revisions_copy.slice(offset, limit).map{|x| x.scmid}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
# Subtract revisions that redmine already knows about
|
# Subtract revisions that redmine already knows about
|
||||||
recent_revisions = recent_changesets_slice.map{|c| c.scmid}
|
recent_revisions = recent_changesets_slice.map{|c| c.scmid}
|
||||||
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
|
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
|
||||||
|
@ -246,13 +241,7 @@ class Repository::Git < Repository
|
||||||
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
||||||
return [] if revisions.nil? || revisions.empty?
|
return [] if revisions.nil? || revisions.empty?
|
||||||
|
|
||||||
changesets.find(
|
changesets.where(:scmid => revisions.map {|c| c.scmid}).all
|
||||||
:all,
|
|
||||||
:conditions => [
|
|
||||||
"scmid IN (?)",
|
|
||||||
revisions.map!{|c| c.scmid}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_extra_info_of_changesets
|
def clear_extra_info_of_changesets
|
||||||
|
|
|
@ -50,10 +50,10 @@ class Wiki < ActiveRecord::Base
|
||||||
@page_found_with_redirect = false
|
@page_found_with_redirect = false
|
||||||
title = start_page if title.blank?
|
title = start_page if title.blank?
|
||||||
title = Wiki.titleize(title)
|
title = Wiki.titleize(title)
|
||||||
page = pages.first(:conditions => ["LOWER(title) = LOWER(?)", title])
|
page = pages.where("LOWER(title) = LOWER(?)", title).first
|
||||||
if !page && !(options[:with_redirect] == false)
|
if !page && !(options[:with_redirect] == false)
|
||||||
# search for a redirect
|
# search for a redirect
|
||||||
redirect = redirects.first(:conditions => ["LOWER(title) = LOWER(?)", title])
|
redirect = redirects.where("LOWER(title) = LOWER(?)", title).first
|
||||||
if redirect
|
if redirect
|
||||||
page = find_page(redirect.redirects_to, :with_redirect => false)
|
page = find_page(redirect.redirects_to, :with_redirect => false)
|
||||||
@page_found_with_redirect = true
|
@page_found_with_redirect = true
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
:from => @events_by_day.keys.first %></h3>
|
:from => @events_by_day.keys.first %></h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%=l(:label_reported_issues)%>: <%= Issue.count(:conditions => ["author_id=?", @user.id]) %>
|
<%=l(:label_reported_issues)%>: <%= Issue.where(:author_id => @user.id).count %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="activity">
|
<div id="activity">
|
||||||
|
|
|
@ -162,11 +162,12 @@ module Redmine
|
||||||
ids = issues.collect(&:project).uniq.collect(&:id)
|
ids = issues.collect(&:project).uniq.collect(&:id)
|
||||||
if ids.any?
|
if ids.any?
|
||||||
# All issues projects and their visible ancestors
|
# All issues projects and their visible ancestors
|
||||||
@projects = Project.visible.all(
|
@projects = Project.visible.
|
||||||
:joins => "LEFT JOIN #{Project.table_name} child ON #{Project.table_name}.lft <= child.lft AND #{Project.table_name}.rgt >= child.rgt",
|
joins("LEFT JOIN #{Project.table_name} child ON #{Project.table_name}.lft <= child.lft AND #{Project.table_name}.rgt >= child.rgt").
|
||||||
:conditions => ["child.id IN (?)", ids],
|
where("child.id IN (?)", ids).
|
||||||
:order => "#{Project.table_name}.lft ASC"
|
order("#{Project.table_name}.lft ASC").
|
||||||
).uniq
|
uniq.
|
||||||
|
all
|
||||||
else
|
else
|
||||||
@projects = []
|
@projects = []
|
||||||
end
|
end
|
||||||
|
|
|
@ -153,7 +153,7 @@ class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1})
|
custom_values_count = CustomValue.where(:custom_field_id => 1).count
|
||||||
assert custom_values_count > 0
|
assert custom_values_count > 0
|
||||||
|
|
||||||
assert_difference 'CustomField.count', -1 do
|
assert_difference 'CustomField.count', -1 do
|
||||||
|
|
|
@ -3701,7 +3701,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_bulk_copy_should_allow_changing_the_issue_attributes
|
def test_bulk_copy_should_allow_changing_the_issue_attributes
|
||||||
# Fixes random test failure with Mysql
|
# Fixes random test failure with Mysql
|
||||||
# where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
|
# where Issue.where(:project_id => 2).limit(2).order('id desc')
|
||||||
# doesn't return the expected results
|
# doesn't return the expected results
|
||||||
Issue.delete_all("project_id=2")
|
Issue.delete_all("project_id=2")
|
||||||
|
|
||||||
|
@ -3716,7 +3716,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
|
copied_issues = Issue.where(:project_id => 2).limit(2).order('id desc').to_a
|
||||||
assert_equal 2, copied_issues.size
|
assert_equal 2, copied_issues.size
|
||||||
copied_issues.each do |issue|
|
copied_issues.each do |issue|
|
||||||
assert_equal 2, issue.project_id, "Project is incorrect"
|
assert_equal 2, issue.project_id, "Project is incorrect"
|
||||||
|
|
|
@ -51,7 +51,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'common/feed'
|
assert_template 'common/feed'
|
||||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||||
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_condition(User.current))
|
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||||
end
|
end
|
||||||
|
|
||||||
test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||||||
|
|
|
@ -280,7 +280,7 @@ class RepositoriesControllerTest < ActionController::TestCase
|
||||||
:revision => 100,
|
:revision => 100,
|
||||||
:comments => 'Committed by foo.'
|
:comments => 'Committed by foo.'
|
||||||
)
|
)
|
||||||
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
|
assert_no_difference "Changeset.where(:user_id => 3).count" do
|
||||||
post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_equal User.find(2), c.reload.user
|
assert_equal User.find(2), c.reload.user
|
||||||
|
|
|
@ -30,7 +30,7 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'index'
|
assert_template 'index'
|
||||||
|
|
||||||
count = WorkflowTransition.count(:all, :conditions => 'role_id = 1 AND tracker_id = 2')
|
count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count
|
||||||
assert_tag :tag => 'a', :content => count.to_s,
|
assert_tag :tag => 'a', :content => count.to_s,
|
||||||
:attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' }
|
:attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' }
|
||||||
end
|
end
|
||||||
|
@ -125,10 +125,10 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_clear_workflow
|
def test_clear_workflow
|
||||||
assert WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2}) > 0
|
assert WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count > 0
|
||||||
|
|
||||||
post :edit, :role_id => 2, :tracker_id => 1
|
post :edit, :role_id => 1, :tracker_id => 2
|
||||||
assert_equal 0, WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
assert_equal 0, WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_permissions
|
def test_get_permissions
|
||||||
|
|
|
@ -95,11 +95,11 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
test "DELETE /issue_categories/:id.xml should reassign issues with :reassign_to_id param" do
|
test "DELETE /issue_categories/:id.xml should reassign issues with :reassign_to_id param" do
|
||||||
issue_count = Issue.count(:conditions => {:category_id => 1})
|
issue_count = Issue.where(:category_id => 1).count
|
||||||
assert issue_count > 0
|
assert issue_count > 0
|
||||||
|
|
||||||
assert_difference 'IssueCategory.count', -1 do
|
assert_difference 'IssueCategory.count', -1 do
|
||||||
assert_difference 'Issue.count(:conditions => {:category_id => 2})', 3 do
|
assert_difference 'Issue.where(:category_id => 2).count', 3 do
|
||||||
delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith')
|
delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -138,9 +138,9 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
||||||
get '/issues.xml',
|
get '/issues.xml',
|
||||||
{:set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='},
|
{:set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='},
|
||||||
:v => {:cf_1 => ['MySQL']}}
|
:v => {:cf_1 => ['MySQL']}}
|
||||||
expected_ids = Issue.visible.all(
|
expected_ids = Issue.visible.
|
||||||
:include => :custom_values,
|
joins(:custom_values).
|
||||||
:conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id)
|
where(:custom_values => {:custom_field_id => 1, :value => 'MySQL'}).map(&:id)
|
||||||
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
||||||
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
||||||
end
|
end
|
||||||
|
@ -151,9 +151,9 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
||||||
should "show only issues with the custom field value" do
|
should "show only issues with the custom field value" do
|
||||||
get '/issues.xml', { :cf_1 => 'MySQL' }
|
get '/issues.xml', { :cf_1 => 'MySQL' }
|
||||||
|
|
||||||
expected_ids = Issue.visible.all(
|
expected_ids = Issue.visible.
|
||||||
:include => :custom_values,
|
joins(:custom_values).
|
||||||
:conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id)
|
where(:custom_values => {:custom_field_id => 1, :value => 'MySQL'}).map(&:id)
|
||||||
|
|
||||||
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
||||||
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
||||||
|
@ -170,7 +170,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
||||||
should "show only issues with the status_id" do
|
should "show only issues with the status_id" do
|
||||||
get '/issues.xml?status_id=5'
|
get '/issues.xml?status_id=5'
|
||||||
|
|
||||||
expected_ids = Issue.visible.all(:conditions => {:status_id => 5}).map(&:id)
|
expected_ids = Issue.visible.where(:status_id => 5).map(&:id)
|
||||||
|
|
||||||
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
||||||
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
||||||
|
|
|
@ -112,7 +112,7 @@ class ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_user_password(login, new_password)
|
def change_user_password(login, new_password)
|
||||||
user = User.first(:conditions => {:login => login})
|
user = User.where(:login => login).first
|
||||||
user.password, user.password_confirmation = new_password, new_password
|
user.password, user.password_confirmation = new_password, new_password
|
||||||
user.save!
|
user.save!
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,7 +100,7 @@ class BoardTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_equal 0, Message.count(:conditions => {:board_id => 1})
|
assert_equal 0, Message.where(:board_id => 1).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_should_nullify_children
|
def test_destroy_should_nullify_children
|
||||||
|
|
|
@ -30,8 +30,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_ref_keywords_any
|
def test_ref_keywords_any
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
Setting.commit_fix_status_id = IssueStatus.find(
|
Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id
|
||||||
:first, :conditions => ["is_closed = ?", true]).id
|
|
||||||
Setting.commit_fix_done_ratio = '90'
|
Setting.commit_fix_done_ratio = '90'
|
||||||
Setting.commit_ref_keywords = '*'
|
Setting.commit_ref_keywords = '*'
|
||||||
Setting.commit_fix_keywords = 'fixes , closes'
|
Setting.commit_fix_keywords = 'fixes , closes'
|
||||||
|
@ -113,8 +112,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ref_keywords_closing_with_timelog
|
def test_ref_keywords_closing_with_timelog
|
||||||
Setting.commit_fix_status_id = IssueStatus.find(
|
Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id
|
||||||
:first, :conditions => ["is_closed = ?", true]).id
|
|
||||||
Setting.commit_ref_keywords = '*'
|
Setting.commit_ref_keywords = '*'
|
||||||
Setting.commit_fix_keywords = 'fixes , closes'
|
Setting.commit_fix_keywords = 'fixes , closes'
|
||||||
Setting.commit_logtime_enabled = '1'
|
Setting.commit_logtime_enabled = '1'
|
||||||
|
|
|
@ -36,8 +36,8 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||||
assert_difference 'IssueStatus.count', -1 do
|
assert_difference 'IssueStatus.count', -1 do
|
||||||
assert status.destroy
|
assert status.destroy
|
||||||
end
|
end
|
||||||
assert_nil WorkflowTransition.first(:conditions => {:old_status_id => status.id})
|
assert_nil WorkflowTransition.where(:old_status_id => status.id).first
|
||||||
assert_nil WorkflowTransition.first(:conditions => {:new_status_id => status.id})
|
assert_nil WorkflowTransition.where(:new_status_id => status.id).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_status_in_use
|
def test_destroy_status_in_use
|
||||||
|
@ -98,7 +98,7 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
with_settings :issue_done_ratio => 'issue_field' do
|
with_settings :issue_done_ratio => 'issue_field' do
|
||||||
IssueStatus.update_issue_done_ratios
|
IssueStatus.update_issue_done_ratios
|
||||||
assert_equal 0, Issue.count(:conditions => {:done_ratio => 50})
|
assert_equal 0, Issue.where(:done_ratio => 50).count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
with_settings :issue_done_ratio => 'issue_status' do
|
with_settings :issue_done_ratio => 'issue_status' do
|
||||||
IssueStatus.update_issue_done_ratios
|
IssueStatus.update_issue_done_ratios
|
||||||
issues = Issue.all(:conditions => {:status_id => 1})
|
issues = Issue.where(:status_id => 1).all
|
||||||
assert_equal [50], issues.map {|issue| issue.read_attribute(:done_ratio)}.uniq
|
assert_equal [50], issues.map {|issue| issue.read_attribute(:done_ratio)}.uniq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,7 +63,7 @@ class ProjectCopyTest < ActiveSupport::TestCase
|
||||||
assert_equal @project, issue.project
|
assert_equal @project, issue.project
|
||||||
end
|
end
|
||||||
|
|
||||||
copied_issue = @project.issues.first(:conditions => {:subject => "copy issue status"})
|
copied_issue = @project.issues.where(:subject => "copy issue status").first
|
||||||
assert copied_issue
|
assert copied_issue
|
||||||
assert copied_issue.status
|
assert copied_issue.status
|
||||||
assert_equal "Closed", copied_issue.status.name
|
assert_equal "Closed", copied_issue.status.name
|
||||||
|
@ -93,7 +93,7 @@ class ProjectCopyTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert @project.copy(@source_project)
|
assert @project.copy(@source_project)
|
||||||
@project.reload
|
@project.reload
|
||||||
copied_issue = @project.issues.first(:conditions => {:subject => "copy issues assigned to a locked version"})
|
copied_issue = @project.issues.where(:subject => "copy issues assigned to a locked version").first
|
||||||
|
|
||||||
assert copied_issue
|
assert copied_issue
|
||||||
assert copied_issue.fixed_version
|
assert copied_issue.fixed_version
|
||||||
|
@ -112,7 +112,7 @@ class ProjectCopyTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert @project.copy(@source_project)
|
assert @project.copy(@source_project)
|
||||||
@project.reload
|
@project.reload
|
||||||
copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"})
|
copied_issue = @project.issues.where(:subject => "change the new issues to use the copied version").first
|
||||||
|
|
||||||
assert copied_issue
|
assert copied_issue
|
||||||
assert copied_issue.fixed_version
|
assert copied_issue.fixed_version
|
||||||
|
@ -128,7 +128,7 @@ class ProjectCopyTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert @project.copy(@source_project)
|
assert @project.copy(@source_project)
|
||||||
@project.reload
|
@project.reload
|
||||||
copied_issue = @project.issues.first(:conditions => {:subject => "keep target shared versions"})
|
copied_issue = @project.issues.where(:subject => "keep target shared versions").first
|
||||||
|
|
||||||
assert copied_issue
|
assert copied_issue
|
||||||
assert_equal assigned_version, copied_issue.fixed_version
|
assert_equal assigned_version, copied_issue.fixed_version
|
||||||
|
@ -175,7 +175,7 @@ class ProjectCopyTest < ActiveSupport::TestCase
|
||||||
@source_project.issues << issue
|
@source_project.issues << issue
|
||||||
assert @project.copy(@source_project)
|
assert @project.copy(@source_project)
|
||||||
|
|
||||||
copied_issue = @project.issues.first(:conditions => {:subject => "copy with attachment"})
|
copied_issue = @project.issues.where(:subject => "copy with attachment").first
|
||||||
assert_not_nil copied_issue
|
assert_not_nil copied_issue
|
||||||
assert_equal 1, copied_issue.attachments.count, "Attachment not copied"
|
assert_equal 1, copied_issue.attachments.count, "Attachment not copied"
|
||||||
assert_equal "testfile.txt", copied_issue.attachments.first.filename
|
assert_equal "testfile.txt", copied_issue.attachments.first.filename
|
||||||
|
|
|
@ -175,7 +175,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
# Assign an issue of a project to a version of a child project
|
# Assign an issue of a project to a version of a child project
|
||||||
Issue.find(4).update_attribute :fixed_version_id, 4
|
Issue.find(4).update_attribute :fixed_version_id, 4
|
||||||
|
|
||||||
assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do
|
assert_no_difference "Project.where(:status => Project::STATUS_ARCHIVED).count" do
|
||||||
assert_equal false, @ecookbook.archive
|
assert_equal false, @ecookbook.archive
|
||||||
end
|
end
|
||||||
@ecookbook.reload
|
@ecookbook.reload
|
||||||
|
@ -211,9 +211,9 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
# make sure that the project non longer exists
|
# make sure that the project non longer exists
|
||||||
assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) }
|
assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) }
|
||||||
# make sure related data was removed
|
# make sure related data was removed
|
||||||
assert_nil Member.first(:conditions => {:project_id => @ecookbook.id})
|
assert_nil Member.where(:project_id => @ecookbook.id).first
|
||||||
assert_nil Board.first(:conditions => {:project_id => @ecookbook.id})
|
assert_nil Board.where(:project_id => @ecookbook.id).first
|
||||||
assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id})
|
assert_nil Issue.where(:project_id => @ecookbook.id).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_should_destroy_subtasks
|
def test_destroy_should_destroy_subtasks
|
||||||
|
@ -246,7 +246,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
assert_equal 0, Board.count
|
assert_equal 0, Board.count
|
||||||
assert_equal 0, Message.count
|
assert_equal 0, Message.count
|
||||||
assert_equal 0, News.count
|
assert_equal 0, News.count
|
||||||
assert_equal 0, Query.count(:conditions => "project_id IS NOT NULL")
|
assert_equal 0, Query.where("project_id IS NOT NULL").count
|
||||||
assert_equal 0, Repository.count
|
assert_equal 0, Repository.count
|
||||||
assert_equal 0, Changeset.count
|
assert_equal 0, Changeset.count
|
||||||
assert_equal 0, Change.count
|
assert_equal 0, Change.count
|
||||||
|
@ -260,7 +260,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
assert_equal 0, WikiContent::Version.count
|
assert_equal 0, WikiContent::Version.count
|
||||||
assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size
|
assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size
|
||||||
assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size
|
assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size
|
||||||
assert_equal 0, CustomValue.count(:conditions => {:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']})
|
assert_equal 0, CustomValue.where(:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_an_orphan_project_to_a_root_project
|
def test_move_an_orphan_project_to_a_root_project
|
||||||
|
|
|
@ -586,7 +586,7 @@ class QueryTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
|
query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
|
||||||
result = query.issues
|
result = query.issues
|
||||||
assert_equal Issue.visible.all(:conditions => {:assigned_to_id => ([2] + user.reload.group_ids)}).sort_by(&:id), result.sort_by(&:id)
|
assert_equal Issue.visible.where(:assigned_to_id => ([2] + user.reload.group_ids)).sort_by(&:id), result.sort_by(&:id)
|
||||||
|
|
||||||
assert result.include?(i1)
|
assert result.include?(i1)
|
||||||
assert result.include?(i2)
|
assert result.include?(i2)
|
||||||
|
|
|
@ -183,9 +183,7 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||||
Setting.default_language = 'en'
|
Setting.default_language = 'en'
|
||||||
|
|
||||||
# choosing a status to apply to fix issues
|
# choosing a status to apply to fix issues
|
||||||
Setting.commit_fix_status_id = IssueStatus.find(
|
Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id
|
||||||
:first,
|
|
||||||
:conditions => ["is_closed = ?", true]).id
|
|
||||||
Setting.commit_fix_done_ratio = "90"
|
Setting.commit_fix_done_ratio = "90"
|
||||||
Setting.commit_ref_keywords = 'refs , references, IssueID'
|
Setting.commit_ref_keywords = 'refs , references, IssueID'
|
||||||
Setting.commit_fix_keywords = 'fixes , closes'
|
Setting.commit_fix_keywords = 'fixes , closes'
|
||||||
|
@ -278,7 +276,7 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_manual_user_mapping
|
def test_manual_user_mapping
|
||||||
assert_no_difference "Changeset.count(:conditions => 'user_id <> 2')" do
|
assert_no_difference "Changeset.where('user_id <> 2').count" do
|
||||||
c = Changeset.create!(
|
c = Changeset.create!(
|
||||||
:repository => @repository,
|
:repository => @repository,
|
||||||
:committer => 'foo',
|
:committer => 'foo',
|
||||||
|
|
|
@ -128,7 +128,7 @@ class SearchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_search_issue_with_multiple_hits_in_journals
|
def test_search_issue_with_multiple_hits_in_journals
|
||||||
i = Issue.find(1)
|
i = Issue.find(1)
|
||||||
assert_equal 2, i.journals.count(:all, :conditions => "notes LIKE '%notes%'")
|
assert_equal 2, i.journals.where("notes LIKE '%notes%'").count
|
||||||
|
|
||||||
r = Issue.search('%notes%').first
|
r = Issue.search('%notes%').first
|
||||||
assert_equal 1, r.size
|
assert_equal 1, r.size
|
||||||
|
|
|
@ -40,7 +40,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
def test_generate
|
def test_generate
|
||||||
User.generate!(:firstname => 'Testing connection')
|
User.generate!(:firstname => 'Testing connection')
|
||||||
User.generate!(:firstname => 'Testing connection')
|
User.generate!(:firstname => 'Testing connection')
|
||||||
assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'})
|
assert_equal 2, User.where(:firstname => 'Testing connection').count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_truth
|
def test_truth
|
||||||
|
|
|
@ -30,9 +30,9 @@ class WorkflowTest < ActiveSupport::TestCase
|
||||||
WorkflowTransition.copy(Tracker.find(2), Role.find(1), Tracker.find(3), Role.find(2))
|
WorkflowTransition.copy(Tracker.find(2), Role.find(1), Tracker.find(3), Role.find(2))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false})
|
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false).first
|
||||||
assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 3, :author => false, :assignee => true})
|
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 3, :author => false, :assignee => true).first
|
||||||
assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 4, :author => true, :assignee => false})
|
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 4, :author => true, :assignee => false).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_workflow_permission_should_validate_rule
|
def test_workflow_permission_should_validate_rule
|
||||||
|
|
Loading…
Reference in New Issue