C0 code coverage information

Generated on Fri Aug 25 11:26:23 PDT 2006 with rcov 0.7.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.
Name Total lines Lines of code Total coverage Code coverage
app/controllers/application.rb 173 135
43.9% 
32.6% 
  1 require 'localization'
  2 require 'user_system'
  3 require 'utility'
  4 
  5 # Filters added to this controller will be run for all controllers in the application.
  6 # Likewise, all the methods added will be available for all controllers.
  7 class ApplicationController < ActionController::Base
  8     include Localization
  9     include Utility
 10     include UserSystem
 11 
 12     helper Localization
 13     helper 'users'
 14 
 15     model :user
 16     model :result
 17     model :link
 18     model :article_page
 19 
 20     before_filter :fix_page_parameter
 21     before_filter :login_required
 22     before_filter :configure_charsets
 23     before_filter :setup_stylesheets
 24 
 25     #before_filter :find_user, :except => :login
 26     
 27     # Exception handling...
 28     include ExceptionNotifiable
 29     
 30     private
 31     
 32     def fix_page_parameter
 33         params[:page] = params[:page].gsub('page_', '') if params[:page]
 34     end
 35 
 36     def redirect_to_index(msg = nil)
 37         flash[:notice] = msg if msg
 38         redirect_to(:action => 'index')
 39     end
 40 
 41     def authorize
 42         unless (@current_user)
 43             flash[:notice] = "Please log in"
 44             session[:jumpto] = request.parameters
 45             redirect_to(:controller => "users", :action => "login")
 46         else
 47             # revive the user cookie
 48             session[:expiration] = 15.minutes.from_now
 49         end
 50     end
 51 
 52     def find_user
 53         if session[:user_id]
 54             if session[:expiration] && session[:expiration] > Time.now
 55                 @current_user = User.find(session[:user_id], :conditions => "role_id >= 255 OR (enabled > 0 AND NOT (expires > 0 AND expires_at < now()))")
 56             else
 57                 session[:user_id] = nil
 58                 @current_user = nil
 59             end
 60         else
 61             @current_user = nil
 62         end
 63     rescue
 64         @current_user = nil
 65     end
 66 
 67     def redirect_unauth(message = "You do not have access to the administration panel.")
 68         unless message
 69             flash[:error] = "You do not have access to the administration panel."
 70         else
 71             flash[:error] = message
 72         end
 73         redirect_to( :controller => '', :action => 'index')
 74     end
 75 
 76     def check_admin_role
 77         check_role(UserSystem::USER_ROLE[:god])
 78     end
 79 
 80     def check_editor_role
 81         check_role(UserSystem::USER_ROLE[:editor])
 82     end
 83 
 84     def check_contrib_role
 85         check_role(UserSystem::USER_ROLE[:contributor])
 86     end
 87 
 88     def check_copyedit_role
 89         check_role(UserSystem::USER_ROLE[:copy_editor])
 90     end
 91 
 92     def check_role(role_id)
 93         unless is_in_role? role_id
 94             redirect_unauth "You are not authorized to perform this action."
 95             return false
 96         end
 97         true
 98     end
 99 
100     def is_in_role?(role_id)
101         @session['user'] and @session['user'].role_id >= role_id
102     end
103 
104     def check_current_user_or_admin
105         check_current_user UserSystem::USER_ROLE[:god]
106     end
107 
108     def check_current_user_or_copy_editor
109         check_current_user UserSystem::USER_ROLE[:editor]
110     end
111 
112     def check_current_user_or_copy_editor
113         check_current_user UserSystem::USER_ROLE[:copy_editor]
114     end
115 
116     def check_current_user(role)
117         unless @session and @session['user']
118             return false
119         end
120         unless @session['user'][:id] == @params[:id].to_i or @session['user'].role_id >= role
121             redirect_unauth "You are not authorized to perform this action."
122             return false
123         end
124     end
125 
126     def configure_charsets
127       # is this even required???
128         @headers["Content-Type"] = "text/html; charset=iso-8859-1" 
129         suppress(ActiveRecord::StatementInvalid) do
130             ActiveRecord::Base.connection.execute 'SET NAMES latin1'
131         end
132     end
133     
134     def get_most_read(article_type)
135       @most_read = Article.find(:all,
136       :limit => 40,
137       :joins => "INNER JOIN read_counts ON read_counts.article_id = articles.id",
138       :order => 'read_counts.count DESC',
139       :select => 'articles.id as id, artist, title, sub_category_id, type',
140       :conditions => ['(published_at <= NOW() OR published_at IS NULL) AND approved = 1 AND type = ?', article_type])
141 	  logger.info "Most read loaded"
142     end
143     
144     protected
145     
146     def setup_stylesheets
147         @stylesheets = []
148     end
149     
150     def month_spread(year, month)
151         #just in case they are strings.
152         year = year.to_i
153         month = month.to_i
154         
155         first_day = Time.local(year, month, 1, 0, 0, 0)
156         # last day is one second ahead of last second of last day of month.
157         if month == 12
158             last_day = Time.local(year + 1, 1, 1, 0, 0, 0)
159         else
160             last_day = Time.local(year, month + 1, 1, 0, 0, 0)
161         end
162         last_day = last_day - 1
163         [first_day, last_day]
164     end
165     
166     def rss_name(action_name)
167       @feeds = { 
168             :rss => url_for( :controller => 'rss', :action => action_name ),
169             :atom => url_for( :controller => 'atom', :action => action_name ),
170         }
171     end
172     
173 end

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

Valid XHTML 1.0! Valid CSS!