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/login.rb 70 55
85.7%  
81.8%  
 1 # This is not a database class. Just used for the login logic
 2 class Login
 3   attr_accessor :login, :email, :password, :remember_me, :return_url
 4   attr_reader :errors, :user
 5   
 6   # from ActiveRecord:Base in order to play correctly with formbuilders
 7   def self.human_attribute_name(attribute_key_name)
 8     attribute_key_name.humanize
 9   end
10   
11   def initialize(params={})
12     params.each { |key,value| send("#{key}=",value) }
13     @errors = ActiveRecord::Errors.new(self)
14     check_validity
15   end
16     
17   def valid?
18     @valid == true
19   end
20     
21   def auth_token
22     return nil unless remember_me == "1"
23     return nil unless errors.empty?
24     user.remember_me
25     return {:value => user.remember_token, :expires => user.remember_token_expires_at}
26   end
27   
28   def user_id
29     user && user.id
30   end  
31   
32   private
33 
34   def check_validity
35     errors.clear
36     check_for_blanks
37     (login.blank? ? validate_according_to_email : validate_according_to_login) if errors.empty?
38     check_password if errors.empty?
39     check_activated if errors.empty?
40     @valid = errors.empty?
41   end
42 
43   def check_for_blanks
44     errors.add(:password,"must be given") if self.password.empty?
45     if email.blank? && login.blank?
46         errors.add(:email,"must be given")
47     end
48   end
49     
50   def validate_according_to_login
51     @user = User.find_by_login(login)
52     errors.add(:login, "has not been found") unless @user
53   end
54   
55   def validate_according_to_email
56     @user = User.find_by_email(email)
57     errors.add(:email, "has not been found") unless @user
58   end
59    
60   def check_password
61     return :ok if @user.authenticated?(password)
62     @user = nil
63     errors.add :password, "is incorrect"
64   end
65   
66   def check_activated
67     errors.add(:activation, "not complete. Please check your email account for a url that we'd like you to visit in order to activate this account. If the email hasn't arrived, please contact us. Our details are in the 'contact us' link above.") unless @user.activated?
68   end
69   
70 end

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

Valid XHTML 1.0! Valid CSS!