Skip to content

Commit

Permalink
Merged r6199 from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@6200 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Jul 9, 2011
1 parent a5bcdf6 commit 3e9ad22
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/models/enumeration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/models/issue_category.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/models/issue_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 5 additions & 5 deletions app/models/mail_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ def issue_attributes_from_keywords(issue)
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),
Expand Down
2 changes: 2 additions & 0 deletions app/models/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def copy(source_tracker)
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)
Expand Down
1 change: 1 addition & 0 deletions app/models/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) } }
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/mail_handler/ticket_with_attributes.eml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.

Project: onlinestore
Tracker: Feature request
category: Stock management
priority: Urgent
Tracker: Feature Request
category: stock management
priority: URGENT
2 changes: 1 addition & 1 deletion test/unit/mail_handler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_add_issue
assert_equal '2010-01-01', issue.start_date.to_s
assert_equal '2010-12-31', issue.due_date.to_s
assert_equal User.find_by_login('jsmith'), issue.assigned_to
assert_equal Version.find_by_name('alpha'), issue.fixed_version
assert_equal Version.find_by_name('Alpha'), issue.fixed_version
assert_equal 2.5, issue.estimated_hours
assert_equal 30, issue.done_ratio
assert_equal [issue.id, 1, 2], [issue.root_id, issue.lft, issue.rgt]
Expand Down

0 comments on commit 3e9ad22

Please sign in to comment.