From 8d526d81e903c780f991a39f0051424ae613c23f Mon Sep 17 00:00:00 2001 From: Tim Chambers Date: Thu, 8 Nov 2018 15:39:42 -0800 Subject: [PATCH] Recast test data in Rails 4 format --- test/helper.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index fb110d0..a00ebff 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -121,9 +121,9 @@ def setup_database(options) end class Department < ActiveRecord::Base - scope :it, where(:name => 'IT') - scope :hr, where(:name => 'Human Resources') - scope :finance, where(:name => 'Finance') + scope :it, -> { where(:name => 'IT') } + scope :hr, -> { where(:name => 'Human Resources') } + scope :finance, -> { where(:name => 'Finance') } has_many :department_memberships has_many :employees, :through => :department_memberships end @@ -134,11 +134,16 @@ class DepartmentMembership < ActiveRecord::Base end class Report < ActiveRecord::Base - scope :with_urgent_title, where(:title => 'URGENT') - scope :with_urgent_body, where("body LIKE '%URGENT%'") + scope :with_urgent_title, -> { where(:title => 'URGENT') } + scope :urgent, -> { where(:title => 'URGENT') } + scope :with_urgent_body, -> { where("body LIKE '%URGENT%'") } belongs_to :employee - def urgent_title? ; self[:title] == 'URGENT' ; end - def urgent_body? ; self[:body] =~ /URGENT/ ; end + def urgent_title? + self[:title] == 'URGENT' + end + def urgent_body? + self[:body] =~ /URGENT/ + end end class LegacyReport < ActiveRecord::Base @@ -147,7 +152,11 @@ class LegacyReport < ActiveRecord::Base class Employee < ActiveRecord::Base scope :email_for_actionmoniker, where("email LIKE '%@actionmoniker.com'") - has_many :reports do ; def urgent ; find(:all,:conditions => {:title => 'URGENT'}) ; end ; end + has_many :reports do + def urgent + where(:title => 'URGENT') + end + end has_many :taxonomies, :as => :classable has_many :department_memberships has_many :departments, :through => :department_memberships