C0 code coverage information

Generated on Sun May 10 11:15:57 +0100 2009 with rcov 0.8.2.1


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
app/models/event.rb 105 79
96.2%  
94.9%  
  1 class Event < ActiveRecord::Base 
  2   include Permissions::Events
  3   include RecordUserWhoCreated
  4   include Taggable
  5   include Permalink
  6   include PoundsToPence
  7   
  8   # default_scope :order => 'start_date, nmk_event ASC'
  9   named_scope :featured, :conditions => {:featured => true, :is_course => false}
 10   named_scope :course, :conditions => {:is_course => true }
 11   named_scope :future, lambda {{ :conditions => ['start_date >= ?',Time.now.at_beginning_of_day], :order => 'start_date DESC'}}
 12   # Nasty hack because default and named scopes and ordering doesn't work
 13   named_scope :future_forward, lambda {{ :conditions => ['start_date >= ?',Time.now.at_beginning_of_day], :order => 'start_date ASC'}}
 14   
 15   named_scope :homepage_events, :conditions => 'nmk_event=TRUE AND featured=FALSE AND start_date >= now()', :limit => 4, :order => 'start_date, nmk_event ASC'
 16   named_scope :homepage_featured,  :conditions => 'nmk_event=TRUE AND is_course=TRUE AND featured=TRUE OR featured IS NULL AND start_date >= now()', :limit => 5, :order => 'start_date, nmk_event ASC'
 17   named_scope :past, lambda {{ :conditions => ['start_date <= ?',Time.now.at_beginning_of_day], :order => 'start_date DESC'}}
 18   
 19   def self.random_featured_event
 20     featured.find(:first, :order=>'rand()')
 21   end
 22 
 23   has_many :comments, :as => :subject, :dependent => :destroy
 24   has_many :back_links, :as => :target, :dependent => :destroy, :conditions => 'visible IS TRUE'
 25   has_many :bookings, :dependent => :destroy
 26   has_many :event_delegates, :through => :bookings, :dependent => :destroy
 27   
 28   validates_presence_of :title
 29   validates_format_of :cost_pounds_full, :with => /\s*£?\s*(\d+(\.\d+)?)\s*/, :if => :can_book_through_site?
 30   validates_format_of :cost_pounds_discount, :with => /\s*£?\s*(\d+(\.\d+)?)\s*/, :if => :can_book_through_site?  
 31   validates_numericality_of :capacity, :only_integer => true, :if => :can_book_through_site?
 32   
 33   before_save :geocode
 34 
 35   def spaces
 36     capacity - event_delegates.count # (true) # True in order to make sure always accurate
 37   end
 38   
 39   def places_booked
 40     event_delegates.count
 41   end
 42   
 43   def has_space?
 44     spaces >= 1
 45   end
 46   
 47   def can_book?
 48     return false unless start_date >= Time.now.at_beginning_of_day
 49     if can_book_through_site? 
 50       return has_space?
 51     else
 52       return !alternative_booking_url.blank?
 53     end
 54   end
 55   
 56   def timing_as_string
 57     return "#{start_date.to_s(:long_ordinal)} to #{end_date.to_s(:time)}" if (start_date.year == end_date.year) && (start_date.yday == end_date.yday)
 58     "#{start_date.to_s(:long_ordinal)} to #{end_date.to_s(:long_ordinal)}"
 59   end
 60   
 61   POSTCODE_REGEXP = /\b[A-PR-UWYZ][A-HK-Y0-9][A-HJKSTUW0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UVW-Z]{2}\b/o
 62   
 63   def postcode
 64     (venue_title && venue_title[POSTCODE_REGEXP]) || (venue_description && venue_description[POSTCODE_REGEXP])
 65   end
 66   
 67   def cost_pounds_full
 68     pounds_for cost_pence_full
 69   end
 70   
 71   def cost_pounds_discount
 72     pounds_for cost_pence_discount
 73   end
 74   
 75   def discount_available?
 76     cost_pence_full != cost_pence_discount
 77   end
 78   
 79   def cost_pounds_full=(pounds)
 80     self.cost_pence_full = pence_for(pounds)
 81   end
 82   
 83   def cost_pounds_discount=(pounds)
 84     self.cost_pence_discount = pence_for(pounds)
 85   end
 86 
 87   def date
 88     updated_at.to_date.to_s(:long_ordinal)
 89   end
 90 
 91   def nice_start_date
 92     start_date.to_date.to_s(:long_ordinal)
 93   end
 94   
 95   def content_without_abstract
 96     self.content.try(:gsub,self.abstract, "")
 97   end
 98   
 99   private
100   
101   def geocode
102     self.latitude, self.longitude = *Google.new.geocode(postcode)
103   end
104 
105 end

Generated using the rcov code coverage analysis tool for Ruby version 0.8.2.1.

Valid XHTML 1.0! Valid CSS!