Skip to content

Commit

Permalink
Recast test data in Rails 4 format
Browse files Browse the repository at this point in the history
  • Loading branch information
tjchambers committed Nov 8, 2018
1 parent 6b58fcf commit 8d526d8
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8d526d8

Please sign in to comment.