| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| app/controllers/tas_controller.rb | 85 | 65 | 42.35%
|
41.54%
|
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 class TasController < ApplicationController |
2 include UsersHelper |
3 before_filter :authorize_only_for_admin |
4 |
5 def index |
6 @tas = Ta.find(:all, :order => "user_name") |
7 end |
8 |
9 def populate |
10 @tas_data = Ta.find(:all, :order => "user_name") |
11 # construct_table_rows defined in UsersHelper |
12 @tas = construct_table_rows(@tas_data) |
13 end |
14 |
15 def new |
16 @user = Ta.new |
17 end |
18 |
19 def edit |
20 @user = Ta.find_by_id(params[:id]) |
21 end |
22 |
23 def update |
24 @user = Ta.find_by_id(params[:user][:id]) |
25 attrs = params[:user] |
26 # update_attributes supplied by ActiveRecords |
27 if !@user.update_attributes(attrs) |
28 flash[:error] = I18n.t("tas.update.error") |
29 render :action => :edit |
30 else |
31 flash[:success] = I18n.t("tas.update.success", |
32 :user_name => @user.user_name) |
33 |
34 redirect_to :action => :index |
35 end |
36 end |
37 |
38 def create |
39 # Default attributes: role = TA or role = STUDENT |
40 # params[:user] is a hash of values passed to the controller |
41 # by the HTML form with the help of ActiveView::Helper:: |
42 @user = Ta.new(params[:user]) |
43 # Return unless the save is successful; save inherted from |
44 # active records--creates a new record if the model is new, otherwise |
45 # updates the existing record |
46 if @user.save |
47 flash[:success] = I18n.t("tas.create.success", |
48 :user_name => @user.user_name) |
49 redirect_to :action => 'index' # Redirect |
50 else |
51 flash[:error] = I18n.t("tas.create.error") |
52 render :action => 'new' |
53 end |
54 end |
55 |
56 #downloads users with the given role as a csv list |
57 def download_ta_list |
58 #find all the users |
59 tas = Ta.find(:all, :order => "user_name") |
60 case params[:format] |
61 when "csv" |
62 output = User.generate_csv_list(tas) |
63 format = "text/csv" |
64 when "xml" |
65 output = tas.to_xml |
66 format = "text/xml" |
67 else |
68 # Raise exception? |
69 output = tas.to_xml |
70 format = "text/xml" |
71 end |
72 send_data(output, :type => format, :disposition => "inline") |
73 end |
74 |
75 def upload_ta_list |
76 if request.post? && !params[:userlist].blank? |
77 result = User.upload_user_list(Ta, params[:userlist]) |
78 if result[:invalid_lines].length > 0 |
79 flash[:invalid_lines] = result[:invalid_lines] |
80 end |
81 flash[:upload_notice] = result[:upload_notice] |
82 end |
83 redirect_to :action => 'index' |
84 end |
85 end |
Generated on Tue Feb 07 00:07:35 -0500 2012 with rcov 0.9.10