summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-09 10:50:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-09 10:50:42 +0000
commit2072669769d24248789366e6552231c1cac5695d (patch)
tree260536878a7abf3983fba7f7905e93b6113f99a2 /app
parent93c2b92a4b5b7003be3113b5d9baf2a0448402a8 (diff)
downloadredmine-2072669769d24248789366e6552231c1cac5695d.tar.gz
redmine-2072669769d24248789366e6552231c1cac5695d.zip
Fixed: Setting issue attributes from mail should be case-insensitive (#8759).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6199 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/enumeration.rb1
-rw-r--r--app/models/issue_category.rb6
-rw-r--r--app/models/issue_status.rb2
-rw-r--r--app/models/mail_handler.rb10
-rw-r--r--app/models/tracker.rb2
-rw-r--r--app/models/version.rb1
6 files changed, 15 insertions, 7 deletions
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb
index 3b7a434a7..71afe8fee 100644
--- a/app/models/enumeration.rb
+++ b/app/models/enumeration.rb
@@ -32,6 +32,7 @@ class Enumeration < ActiveRecord::Base
named_scope :shared, :conditions => { :project_id => nil }
named_scope :active, :conditions => { :active => true }
+ named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
def self.default
# Creates a fake default scope so Enumeration.default will check
diff --git a/app/models/issue_category.rb b/app/models/issue_category.rb
index 51baeb419..96b8eeee1 100644
--- a/app/models/issue_category.rb
+++ b/app/models/issue_category.rb
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006 Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -24,6 +24,8 @@ class IssueCategory < ActiveRecord::Base
validates_uniqueness_of :name, :scope => [:project_id]
validates_length_of :name, :maximum => 30
+ named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
+
alias :destroy_without_reassign :destroy
# Destroy the category
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index 5527e2c9a..f2db4b570 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -26,6 +26,8 @@ class IssueStatus < ActiveRecord::Base
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
+
+ named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
def after_save
IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default?
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index a312301d2..dbbd4f5f3 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -265,12 +265,12 @@ class MailHandler < ActionMailer::Base
assigned_to = nil if assigned_to && !issue.assignable_users.include?(assigned_to)
attrs = {
- 'tracker_id' => (k = get_keyword(:tracker)) && issue.project.trackers.find_by_name(k).try(:id),
- 'status_id' => (k = get_keyword(:status)) && IssueStatus.find_by_name(k).try(:id),
- 'priority_id' => (k = get_keyword(:priority)) && IssuePriority.find_by_name(k).try(:id),
- 'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.find_by_name(k).try(:id),
+ 'tracker_id' => (k = get_keyword(:tracker)) && issue.project.trackers.named(k).first.try(:id),
+ 'status_id' => (k = get_keyword(:status)) && IssueStatus.named(k).first.try(:id),
+ 'priority_id' => (k = get_keyword(:priority)) && IssuePriority.named(k).first.try(:id),
+ 'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.named(k).first.try(:id),
'assigned_to_id' => assigned_to.try(:id),
- 'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.find_by_name(k).try(:id),
+ 'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.named(k).first.try(:id),
'start_date' => get_keyword(:start_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
'estimated_hours' => get_keyword(:estimated_hours, :override => true),
diff --git a/app/models/tracker.rb b/app/models/tracker.rb
index 93fdd4035..7bf5732ba 100644
--- a/app/models/tracker.rb
+++ b/app/models/tracker.rb
@@ -32,6 +32,8 @@ class Tracker < ActiveRecord::Base
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
+ named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
+
def to_s; name end
def <=>(tracker)
diff --git a/app/models/version.rb b/app/models/version.rb
index 8b01816a7..710074a86 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -33,6 +33,7 @@ class Version < ActiveRecord::Base
validates_inclusion_of :status, :in => VERSION_STATUSES
validates_inclusion_of :sharing, :in => VERSION_SHARINGS
+ named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
named_scope :open, :conditions => {:status => 'open'}
named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }