C0 code coverage information

Generated on Fri Aug 25 10:11:33 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/assignments_controller.rb 213 180
45.1% 
40.0% 
  1 class AssignmentsController < ApplicationController
  2     model   :user
  3     layout 'staff'
  4     include ArticlesHelper
  5 
  6     AVAILABLE_SORTS = %w{ article_type artist title planned_publish_date needs_materials release_date username updated_at }
  7 	 
  8     before_filter :check_editor_role, :only => [:create, :assign_to_user, :prioritize_user, :edit, :fulfill_materials, :quick_assign, :list_needs_materials]
  9     before_filter :check_contrib_role, :only => [:edit, :my_assignments, :show, :request_materials]
 10     def index
 11         list
 12         render :action => 'list'
 13     end
 14 
 15     def list        
 16         if is_in_role? USER_ROLE[:editor]
 17             @assignment_pages, @assignments = paginate(
 18               :assignment,
 19               :select => "assignments.id, article_type, artist, title, planned_publish_date, needs_materials, release_date, user_id, username,  assignments.updated_at",
 20               :joins => "LEFT OUTER JOIN users on users.id = assignments.user_id", 
 21               :per_page => 50, 
 22               :order => sort_columns(params[:sort])
 23             )
 24         else
 25             @assignment_pages, @assignments = paginate(
 26               :assignment,
 27               :select => "assignments.id, article_type, artist, title, planned_publish_date, needs_materials, release_date, user_id, username, assignments.updated_at",
 28               :conditions => ["user_id = ?", @session['user'].id], 
 29               :joins => "LEFT OUTER JOIN users on users.id = assignments.user_id", 
 30               :per_page => 50, 
 31               :order => sort_columns(params[:sort])
 32             )
 33         end
 34     end
 35 
 36     def list_unassigned
 37         @assignment_pages, @assignments = paginate( :assignment, :per_page =>
 38         50, :conditions => "user_id IS NULL")
 39         render :action => 'list'
 40     end
 41 
 42     def list_needs_materials
 43         @assignment_pages, @assignments = paginate( :assignment, :per_page =>
 44         50, :conditions => "needs_materials > 0 and needs_materials < 3")
 45         render :action => 'list'
 46     end
 47     
 48     def show
 49         return false unless find_assignment
 50         if @assignment.article
 51             @article = @assignment.article
 52             @version_number = 0 
 53             if(params[:version])
 54                 @version_number = params[:version].to_i
 55                 @article = @article.find_version(@version_number) 
 56             else
 57                 @version_number = @article.version
 58             end
 59         end
 60     end
 61 
 62     def new
 63         @assignment = Assignment.new
 64     end
 65 
 66     def create
 67         @assignment = Assignment.new(params[:assignment])
 68         @assignment.editor = @session['user']
 69         @assignment.planned_publish_date = nil if params[:pub_tbd] == "on"
 70         @assignment.due_date = nil if params[:due_tbd] == "on"
 71         if @assignment.save
 72             flash[:notice] = 'Assignment was successfully created.'
 73             redirect_to :action => 'list'
 74         else
 75             render :action => 'new'
 76         end
 77     end
 78 
 79     def assign_to_user
 80         return false unless find_assignment
 81         unless request.get?
 82             user = User.find(params[:user][:id])
 83             @assignment.editor = @session['user']
 84             if @assignment.update_attribute(:user, user)
 85                 url = url_for(:controller => 'assignments', :action => 'show', :id => @assignment)
 86                 
 87                 #check if a notification should be sent
 88                 if @assignment.user and ((@assignment.user.notification_flags & UserNotify::NOTIFICATION_TYPES[:assignment]) != 0)
 89                     UserNotify.deliver_assignment @assignment, url
 90                 end
 91                 
 92                 flash[:notice] = "User sucessfully assigned to assignment."
 93                 redirect_to :action => 'list'
 94             else
 95                 flash[:error] = "Could not set this assigment to the selected user."
 96             end
 97         end
 98     end
 99     
100     def quick_assign
101     end
102     
103     def request_materials
104         return false unless find_assignment
105         @assignment.editor = @session['user']
106         needs_materials_param = params[:article][:needs_materials].to_i
107         if @assignment.update_attribute(:needs_materials, needs_materials_param)
108             if needs_materials_param > 0 and needs_materials_param < 3
109                 url = url_for(:controller => 'assignments', :action => 'show', :id => @assignment)
110                 UserNotify.deliver_needs_materials url, @assignment
111                 flash[:notice] = "Successfully requested materials, notice sent to editors."
112             else
113                 flash[:notice] = "Status of requested materials changed successfully."
114             end
115             redirect_to :action => 'show', :id => @assignment
116         else
117             flash[:error] = "A problem occured while attempting to request for materials. Contact an administrator."
118         end
119     end
120     
121     def fulfill_materials
122         return false unless find_assignment
123         @assignment.editor = @session['user']
124         if @assignment.update_attribute(:needs_materials, 3)
125             url = url_for(:controller => 'assignments', :action => 'show', :id => @assignment)
126             #UserNotify.deliver_materials_fulfilled url, @assignment
127             flash[:notice] = "Successfully fulfilled materials."
128             redirect_to :action => 'list'
129         else
130             flash[:error] = "A problem occured while attempting to fulfill materials. Contact an administrator."
131         end 
132     end
133 
134     def my_assignments
135         @assignments = @current_user.assignments
136         render :action => 'list'
137     end
138 
139     def prioritize_user
140         @user = User.find(params[:id])
141         @assignments = @user.assignments
142         unless request.get?
143         end
144     end
145 
146     def edit
147         return if generate_filled_in
148         @assignment.attributes = params[:assignment]
149         @assignment.release_date = nil if params[:release_tbd] == "on"
150         @assignment.planned_publish_date = nil if params[:pub_tbd] == "on"
151         @assignment.due_date = nil if params[:due_tbd] == "on"
152         if @assignment.save
153             if @assignment.user
154                url = url_for(:controller => 'assignments', :action => 'show', :id => @assignment)
155                #UserNotify.deliver_assignment @assignment, url
156             end
157             flash[:notice] = 'Assignment was successfully updated.'
158             redirect_to :action => 'list', :id => @assignment
159         else
160             render :action => 'edit'
161         end
162     end
163     
164     def cut
165         destroy
166     end
167 
168     def destroy
169         Assignment.find(params[:id]).destroy
170         redirect_to :action => 'list'
171     end
172 
173     private
174 
175     def find_assignment
176         begin
177             @assignment = Assignment.find(params[:id])
178         rescue ActiveRecord::RecordNotFound
179             # we will redirect it to the oops page.
180             render :template => '/staff/oops', :status     => "404 Not Found"
181             return false
182         end
183     end
184 
185     # Generate a template user for certain actions on get
186     def generate_filled_in
187         return false unless find_assignment
188         
189         case @request.method
190         when :get
191             render
192             return true
193         end
194         return false
195     end
196 
197     # Generate SQL for clicking html table header to sort
198     def sort_columns(sort_param)
199         return if sort_param.nil?
200         sort = nil
201         
202         AVAILABLE_SORTS.each do |s|
203           # there are other ways of doing this which suck less - but hey
204           if sort_param[s]
205             sort = s # use s as it is known safe
206             sort << " DESC" if sort_param =~ /_reverse/
207             break
208           end
209         end
210         return sort
211     end
212     
213 end

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

Valid XHTML 1.0! Valid CSS!