Branston C0 Coverage Information - RCov

app/models/user.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
app/models/user.rb 75 35
100.00%
100.00%

Key

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.

Coverage Details

1 #    This file is part of Branston.
2 #
3 #    Branston is free software: you can redistribute it and/or modify
4 #    it under the terms of the GNU Affero General Public License as published by
5 #    the Free Software Foundation.
6 #
7 #    Branston is distributed in the hope that it will be useful,
8 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 #    GNU Affero General Public License for more details.
11 #
12 #    You should have received a copy of the GNU Affero General Public License
13 #    along with Branston.  If not, see <http://www.gnu.org/licenses/>.
14 
15 require 'digest/sha1'
16 
17 class User < ActiveRecord::Base
18   include Authentication
19   include Authentication::ByPassword
20   include Authentication::ByCookieToken
21 
22   validates_presence_of     :login
23   validates_length_of       :login,    :within => 3..40
24   validates_uniqueness_of   :login
25   validates_format_of       :login,    :with => Authentication.login_regex, :message => Authentication.bad_login_message
26 
27   validates_format_of       :name,     :with => Authentication.name_regex,  :message => Authentication.bad_name_message, :allow_nil => true
28   validates_length_of       :name,     :maximum => 100
29 
30   validates_presence_of     :email
31   validates_length_of       :email,    :within => 6..100 #r@a.wk
32   validates_uniqueness_of   :email
33   validates_format_of       :email,    :with => Authentication.email_regex, :message => Authentication.bad_email_message
34 
35   has_many :participations
36   has_many :iterations, :through => :participations
37   has_many :stories, :foreign_key => 'author_id'
38 
39   # HACK HACK HACK -- how to do attr_accessible from here?
40   # prevents a user from submitting a crafted form that bypasses activation
41   # anything else you want your user to change should be added here.
42   attr_accessible :login, :email, :name, :password, :password_confirmation
43 
44 
45 
46   # Authenticates a user by their login name and unencrypted password.  Returns the user or nil.
47   #
48   # uff.  this is really an authorization, not authentication routine.
49   # We really need a Dispatch Chain here or something.
50   # This will also let us return a human error message.
51   #
52   def self.authenticate(login, password)
53     return nil if login.blank? || password.blank?
54     u = find_by_login(login.downcase) # need to get the salt
55     u && u.authenticated?(password) ? u : nil
56   end
57 
58   def login=(value)
59     write_attribute :login, (value ? value.downcase : nil)
60   end
61 
62   def email=(value)
63     write_attribute :email, (value ? value.downcase : nil)
64   end
65 
66   def to_s
67     login
68   end
69 
70   protected
71 
72 
73 
74 end
75 

Generated on Thu Jan 07 15:27:03 +0000 2010 with rcov 0.9.6