Project

General

Profile

« Previous | Next » 

Revision 21466223

Added by Shlomi Zadok about 8 years ago

Fixes #14504 - Moves Report scoped search into inherited method

View differences:

app/models/report.rb
validates :host_id, :status, :presence => true
validates :reported_at, :presence => true, :uniqueness => {:scope => [:host_id, :type]}
scoped_search :in => :host, :on => :name, :complete_value => true, :rename => :host
scoped_search :in => :environment, :on => :name, :complete_value => true, :rename => :environment
scoped_search :in => :messages, :on => :value, :rename => :log
scoped_search :in => :sources, :on => :value, :rename => :resource
scoped_search :in => :hostgroup, :on => :name, :complete_value => true, :rename => :hostgroup
scoped_search :in => :hostgroup, :on => :title, :complete_value => true, :rename => :hostgroup_fullname
scoped_search :in => :hostgroup, :on => :title, :complete_value => true, :rename => :hostgroup_title
scoped_search :on => :reported_at, :complete_value => true, :default_order => :desc, :rename => :reported, :only_explicit => true
def self.inherited(child)
child.instance_eval do
scoped_search :in => :host, :on => :name, :complete_value => true, :rename => :host
scoped_search :in => :environment, :on => :name, :complete_value => true, :rename => :environment
scoped_search :in => :messages, :on => :value, :rename => :log
scoped_search :in => :sources, :on => :value, :rename => :resource
scoped_search :in => :hostgroup, :on => :name, :complete_value => true, :rename => :hostgroup
scoped_search :in => :hostgroup, :on => :title, :complete_value => true, :rename => :hostgroup_fullname
scoped_search :in => :hostgroup, :on => :title, :complete_value => true, :rename => :hostgroup_title
scoped_search :on => :reported_at, :complete_value => true, :default_order => :desc, :rename => :reported, :only_explicit => true
end
super
end
# returns reports for hosts in the User's filter set
scope :my_reports, lambda {
test/unit/report_test.rb
assert_includes ConfigReport.authorized('view_config_reports').my_reports, report
end
test 'Inherited children can search' do
assert_nothing_raised NoMethodError do
TestReport.search_for('blah')
end
end
end
end

Also available in: Unified diff