GitLab wurde erfolgreich aktualisiert. Durch regelmäßige Updates bleibt das THM GitLab sicher. Danke für Ihre Geduld.

Commit 7cefe444 authored by jplang's avatar jplang

Use open scope in version issues count methods.

git-svn-id: https://svn.redmine.org/redmine/trunk@8285 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 31d50eee
......@@ -63,7 +63,10 @@ class Issue < ActiveRecord::Base
named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Issue.visible_condition(args.shift || User.current, *args) } }
named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
named_scope :open, lambda {|*args|
is_closed = args.size > 0 ? !args.first : false
{:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status}
}
named_scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
named_scope :with_limit, lambda { |limit| { :limit => limit} }
......
......@@ -124,12 +124,12 @@ class Version < ActiveRecord::Base
# Returns the total amount of open issues for this version.
def open_issues_count
@open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status)
@open_issues_count ||= Issue.open.count(:all, :conditions => ["fixed_version_id = ?", self.id])
end
# Returns the total amount of closed issues for this version.
def closed_issues_count
@closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status)
@closed_issues_count ||= Issue.open(false).count(:all, :conditions => ["fixed_version_id = ?", self.id])
end
def wiki_page
......
......@@ -219,6 +219,16 @@ class IssueTest < ActiveSupport::TestCase
assert_equal 0, Issue.find(1).descendants.visible.all.size
end
def test_open_scope
issues = Issue.open.all
assert_nil issues.detect(&:closed?)
end
def test_open_scope_with_arg
issues = Issue.open(false).all
assert_equal issues, issues.select(&:closed?)
end
def test_errors_full_messages_should_include_custom_fields_errors
field = IssueCustomField.find_by_name('Database')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment