##// END OF EJS Templates
Merged r6199 from trunk....
Jean-Philippe Lang -
r6080:3e9ad22fade0
parent child
Show More
@@ -32,6 +32,7 class Enumeration < ActiveRecord::Base
32 32
33 33 named_scope :shared, :conditions => { :project_id => nil }
34 34 named_scope :active, :conditions => { :active => true }
35 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
35 36
36 37 def self.default
37 38 # Creates a fake default scope so Enumeration.default will check
@@ -1,5 +1,5
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
@@ -24,6 +24,8 class IssueCategory < ActiveRecord::Base
24 24 validates_uniqueness_of :name, :scope => [:project_id]
25 25 validates_length_of :name, :maximum => 30
26 26
27 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
28
27 29 alias :destroy_without_reassign :destroy
28 30
29 31 # Destroy the category
@@ -26,6 +26,8 class IssueStatus < ActiveRecord::Base
26 26 validates_uniqueness_of :name
27 27 validates_length_of :name, :maximum => 30
28 28 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
29
30 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
29 31
30 32 def after_save
31 33 IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default?
@@ -265,12 +265,12 class MailHandler < ActionMailer::Base
265 265 assigned_to = nil if assigned_to && !issue.assignable_users.include?(assigned_to)
266 266
267 267 attrs = {
268 'tracker_id' => (k = get_keyword(:tracker)) && issue.project.trackers.find_by_name(k).try(:id),
269 'status_id' => (k = get_keyword(:status)) && IssueStatus.find_by_name(k).try(:id),
270 'priority_id' => (k = get_keyword(:priority)) && IssuePriority.find_by_name(k).try(:id),
271 'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.find_by_name(k).try(:id),
268 'tracker_id' => (k = get_keyword(:tracker)) && issue.project.trackers.named(k).first.try(:id),
269 'status_id' => (k = get_keyword(:status)) && IssueStatus.named(k).first.try(:id),
270 'priority_id' => (k = get_keyword(:priority)) && IssuePriority.named(k).first.try(:id),
271 'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.named(k).first.try(:id),
272 272 'assigned_to_id' => assigned_to.try(:id),
273 'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.find_by_name(k).try(:id),
273 'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.named(k).first.try(:id),
274 274 'start_date' => get_keyword(:start_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
275 275 'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
276 276 'estimated_hours' => get_keyword(:estimated_hours, :override => true),
@@ -32,6 +32,8 class Tracker < ActiveRecord::Base
32 32 validates_uniqueness_of :name
33 33 validates_length_of :name, :maximum => 30
34 34
35 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
36
35 37 def to_s; name end
36 38
37 39 def <=>(tracker)
@@ -33,6 +33,7 class Version < ActiveRecord::Base
33 33 validates_inclusion_of :status, :in => VERSION_STATUSES
34 34 validates_inclusion_of :sharing, :in => VERSION_SHARINGS
35 35
36 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
36 37 named_scope :open, :conditions => {:status => 'open'}
37 38 named_scope :visible, lambda {|*args| { :include => :project,
38 39 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
@@ -38,6 +38,6 massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
38 38 pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
39 39
40 40 Project: onlinestore
41 Tracker: Feature request
42 category: Stock management
43 priority: Urgent
41 Tracker: Feature Request
42 category: stock management
43 priority: URGENT
@@ -63,7 +63,7 class MailHandlerTest < ActiveSupport::TestCase
63 63 assert_equal '2010-01-01', issue.start_date.to_s
64 64 assert_equal '2010-12-31', issue.due_date.to_s
65 65 assert_equal User.find_by_login('jsmith'), issue.assigned_to
66 assert_equal Version.find_by_name('alpha'), issue.fixed_version
66 assert_equal Version.find_by_name('Alpha'), issue.fixed_version
67 67 assert_equal 2.5, issue.estimated_hours
68 68 assert_equal 30, issue.done_ratio
69 69 assert_equal [issue.id, 1, 2], [issue.root_id, issue.lft, issue.rgt]
General Comments 0
You need to be logged in to leave comments. Login now