C0 code coverage information
Generated on Sun Jun 11 23:15:15 CEST 2006 with rcov 0.6.0
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.
1 require 'digest/sha1'
Calls
1 Object#require at vendor/rails/activesupport/lib/active_support/dependencies.rb:213
2
3 # this model expects a certain database layout and its based on the name/login pattern.
4 class User < ActiveRecord::Base
Calls
1 #<Class:ActiveRecord::Base>#inherited at vendor/rails/activerecord/lib/active_record/base.rb:246
5
6 # echo "typo" | sha1sum -
7 @@salt = '20ac4d290c2293702c64b3b287ae5ea79b26a5c1'
8 cattr_accessor :salt
Calls
1 Class#cattr_accessor at vendor/rails/activesupport/lib/active_support/class_attribute_accessors.rb:53
9
10 # Authenticate a user.
11 #
12 # Example:
13 # @user = User.authenticate('bob', 'bobpass')
14 #
15 def self.authenticate(login, pass)
Called by
23 app/apis/typo_web_service.rb:11 in 'TypoWebService#authenticate'
3 app/controllers/accounts_controller.rb:6 in 'AccountsController#login'
1 app/controllers/accounts_controller.rb:25 in 'AccountsController#signup'
16 find_first(["login = ? AND password = ?", login, sha1(pass)])
Calls
27 #<Class:User>#sha1 at app/models/user.rb:32
27 #<Class:ActiveRecord::Base>#find_first at vendor/rails/activerecord/lib/active_record/deprecated_finders.rb:21
17 end
18
19 def self.authenticate?(login, pass)
20 user = self.authenticate(login, pass)
21 return false if user.nil?
22 return true if user.login == login
23
24 false
25 end
26
27 protected
28
29 # Apply SHA1 encryption to the supplied password.
30 # We will additionally surround the password with a salt
31 # for additional security.
32 def self.sha1(pass)
Called by
27 app/models/user.rb:16 in '#<Class:User>#authenticate'
1 app/models/user.rb:42 in 'User#crypt_password'
33 Digest::SHA1.hexdigest("#{salt}--#{pass}--")
Calls
28 #<Class:User>#salt at (eval):5
34 end
35
36 before_create :crypt_password
Calls
1 #<Class:ActiveRecord::Base>#before_create at (eval):1
37
38 # Before saving the record to database we will crypt the password
39 # using SHA1.
40 # We never store the actual password in the DB.
41 def crypt_password
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
Called by
1 vendor/rails/activerecord/lib/active_record/callbacks.rb:333 in 'ActiveRecord::Callbacks#callback'
42 write_attribute "password", self.class.sha1(password)
Calls
1 User#password at (eval):1
1 ActiveRecord::Base#write_attribute at vendor/rails/activerecord/lib/active_record/base.rb:1580
1 #<Class:User>#sha1 at app/models/user.rb:32
43 end
44
45 before_update :crypt_unless_empty
Calls
1 #<Class:ActiveRecord::Base>#before_update at (eval):1
46
47 # If the record is updated we will check if the password is empty.
48 # If its empty we assume that the user didn't want to change his
49 # password and just reset it to the old value.
50 def crypt_unless_empty
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
51 if password.empty?
52 user = self.class.find(self.id)
53 self.password = user.password
54 else
55 write_attribute "password", self.class.sha1(password)
56 end
57 end
58
59 validates_uniqueness_of :login, :on => :create
Calls
1 ActiveRecord::Validations::ClassMethods#validates_uniqueness_of at vendor/rails/activerecord/lib/active_record/validations.rb:486
60 validates_length_of :password, :within => 5..40, :on => :create
Calls
1 ActiveRecord::Validations::ClassMethods#validates_length_of at vendor/rails/activerecord/lib/active_record/validations.rb:414
61 validates_presence_of :login
Calls
1 ActiveRecord::Validations::ClassMethods#validates_presence_of at vendor/rails/activerecord/lib/active_record/validations.rb:372
62
63 validates_confirmation_of :password, :if=> Proc.new { |u| u.password.size > 0}
Calls
4 User#password at (eval):1
1 ActiveRecord::Validations::ClassMethods#validates_confirmation_of at vendor/rails/activerecord/lib/active_record/validations.rb:324
64 validates_length_of :login, :within => 3..40
Calls
1 ActiveRecord::Validations::ClassMethods#validates_length_of at vendor/rails/activerecord/lib/active_record/validations.rb:414
65 end
Generated using the rcov code coverage analysis tool for Ruby version 0.6.0.