@@ -64,7 +64,6 class Issue < ActiveRecord::Base | |||||
64 | lambda {|*args| { :include => :project, |
|
64 | lambda {|*args| { :include => :project, | |
65 | :conditions => Issue.visible_condition(args.shift || User.current, *args) } } |
|
65 | :conditions => Issue.visible_condition(args.shift || User.current, *args) } } | |
66 |
|
66 | |||
67 | class << self; undef :open; end |
|
|||
68 | scope :open, lambda {|*args| |
|
67 | scope :open, lambda {|*args| | |
69 | is_closed = args.size > 0 ? !args.first : false |
|
68 | is_closed = args.size > 0 ? !args.first : false | |
70 | {:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status} |
|
69 | {:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status} |
@@ -35,7 +35,6 class Version < ActiveRecord::Base | |||||
35 | validates_inclusion_of :sharing, :in => VERSION_SHARINGS |
|
35 | validates_inclusion_of :sharing, :in => VERSION_SHARINGS | |
36 |
|
36 | |||
37 | scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}} |
|
37 | scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}} | |
38 | class << self; undef :open; end |
|
|||
39 | scope :open, :conditions => {:status => 'open'} |
|
38 | scope :open, :conditions => {:status => 'open'} | |
40 | scope :visible, lambda {|*args| { :include => :project, |
|
39 | scope :visible, lambda {|*args| { :include => :project, | |
41 | :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } |
|
40 | :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } |
@@ -10,6 +10,11 module ActiveRecord | |||||
10 | l("field_#{name.underscore.gsub('/', '_')}_#{attr}", :default => ["field_#{attr}".to_sym, attr]) |
|
10 | l("field_#{name.underscore.gsub('/', '_')}_#{attr}", :default => ["field_#{attr}".to_sym, attr]) | |
11 | end |
|
11 | end | |
12 | end |
|
12 | end | |
|
13 | ||||
|
14 | # Undefines private Kernel#open method to allow using `open` scopes in models. | |||
|
15 | # See Defect #11545 (http://www.redmine.org/issues/11545) for details. | |||
|
16 | class Base ; undef open ; end | |||
|
17 | class Relation ; undef open ; end | |||
13 | end |
|
18 | end | |
14 |
|
19 | |||
15 | module ActionView |
|
20 | module ActionView |
@@ -132,6 +132,10 class ProjectTest < ActiveSupport::TestCase | |||||
132 | end |
|
132 | end | |
133 | end |
|
133 | end | |
134 |
|
134 | |||
|
135 | def test_open_scope_on_issues_association | |||
|
136 | assert_kind_of Issue, Project.find(1).issues.open.first | |||
|
137 | end | |||
|
138 | ||||
135 | def test_archive |
|
139 | def test_archive | |
136 | user = @ecookbook.members.first.user |
|
140 | user = @ecookbook.members.first.user | |
137 | @ecookbook.archive |
|
141 | @ecookbook.archive |
General Comments 0
You need to be logged in to leave comments.
Login now