diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-10 05:10:43 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-10 05:10:43 +0000 |
commit | 22c1e2b8cf8527c1e97de976f3dd46e7bee7cba3 (patch) | |
tree | c868aacb521e2918f8ef1d67adf0b4c47b5b4ac2 /app/models | |
parent | cfa1f0c231309c596900a0e82e89f15a4ab071a1 (diff) | |
download | redmine-22c1e2b8cf8527c1e97de976f3dd46e7bee7cba3.tar.gz redmine-22c1e2b8cf8527c1e97de976f3dd46e7bee7cba3.zip |
Adds named scopes to replace custom finders.
* Adds watched_by class method in ActsAsWatchable
* Adds Issue#recently_updated, Issue#with_limit and Issue#on_active_project
#2482
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3557 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 9aaebce73..ffce8ea18 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -49,8 +49,9 @@ class Issue < ActiveRecord::Base DONE_RATIO_OPTIONS = %w(issue_field issue_status) attr_reader :current_journal - + validates_presence_of :subject, :priority, :project, :tracker, :author, :status + validates_length_of :subject, :maximum => 255 validates_inclusion_of :done_ratio, :in => 0..100 validates_numericality_of :estimated_hours, :allow_nil => true @@ -60,6 +61,11 @@ class Issue < ActiveRecord::Base named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status + named_scope :recently_updated, :order => "#{self.table_name}.updated_on DESC" + named_scope :with_limit, lambda { |limit| { :limit => limit} } + named_scope :on_active_project, :include => [:status, :project, :tracker], + :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] + before_create :default_assign before_save :reschedule_following_issues, :close_duplicates, :update_done_ratio_from_issue_status after_save :create_journal |