We are unable to run "Project Status" or "Requirement Coverage" Reports (with module failing)

时间:2016-08-23 15:33:32

标签: ruby-on-rails centos tarantula

Recently, we found that when running certain reports (Either Project Status or Requirement Coverage) the report fails with a popup showing:

undefined method `[]' for nil:NilClass

Examining the httpd access logs I see the following:

"GET /report/requirement_coverage/?sort_by=id&test_object_ids=12 HTTP/1.1" 403 38 "http://tarantula.xxxxx.xxxx/"

in the production.log file, we also see this:

undefined method []' for nil:NilClass /opt/tarantula/rails/lib/priority_extensions.rb:9:inpriority_name' /opt/tarantula/rails/app/models/report/requirement_coverage.rb:115:in case_info' /opt/tarantula/rails/app/models/report/requirement_coverage.rb:77:inblock (2 levels) in do_query' /opt/tarantula/rails/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/associations/collection_proxy.rb:91:in each' /opt/tarantula/rails/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/associations/collection_proxy.rb:91:inmethod_missing' /opt/tarantula/rails/app/models/report/requirement_coverage.rb:77:in block in do_query' /opt/tarantula/rails/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation/delegation.rb:6:ineach' /opt/tarantula/rails/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation/delegation.rb:6:in each' /opt/tarantula/rails/app/models/report/requirement_coverage.rb:66:indo_query'

lots more under this followd by:

/opt/tarantula/rails/vendor/bundle/ruby/1.9.1/gems/passenger-3.0.19/helper-scripts/passenger-spawn-server:99:in `' Completed 403 Forbidden in 113381.4ms (Views: 0.2ms | ActiveRecord: 7849.2ms)

NOTE: this is not my code, but code from a module of Testia Tarantula

=begin rdoc

Include this in a model which is to be prioritized.

 =end
 module PriorityExtensions

   def priority_name
     Project::Priorities.detect{|p| p[:value] == self.priority}[:name]
   end

   def priority=(p)
     if p.is_a? String
       p_val = Project::Priorities.detect{|pp| pp[:name] == p.downcase}
       if p_val
         self[:priority] = p_val[:value]
       else
         raise "Invalid priority '#{p}' for #{self.class} (id #{self.id})"
       end
     else
       self[:priority] = p
     end
   end

   def self.included(model)
     model.validates_inclusion_of :priority, :in =>           Project::Priorities.map{|p| p[:value]}
   end

 end

1 个答案:

答案 0 :(得分:0)

发现问题,表“案例”中的列“优先级”已经以某种方式被更改为无效的NULL。将值更改为“0”(正常)可解决问题。