Permalink
Browse files

Added exit_code_ok? helper method to avoid nil errors in views.

  • Loading branch information...
1 parent 039f621 commit 73076fa2081753062e1eb35d54f7faee2cb23e3e @benissimo committed Feb 14, 2012
Showing with 7 additions and 3 deletions.
  1. +4 −0 app/helpers/application_helper.rb
  2. +3 −3 app/views/builds/_build.html.haml
View
4 app/helpers/application_helper.rb
@@ -73,4 +73,8 @@ def status_css_class(status)
end
end
+ def exit_code_ok?(build_or_part)
+ build_or_part.output[0] && build_or_part.output[0].exit_code == 0
+ end
+
end
View
6 app/views/builds/_build.html.haml
@@ -1,12 +1,12 @@
.build-details
- - if build && build.output[0]
- %h3{ :class => build.output[0].exit_code == 0 ? "status_build_ok" : "status_build_failed"}
+ - if build
+ %h3{ :class => exit_code_ok?(build) ? "status_build_ok" : "status_build_failed"}
VCS
%ul.unstyled
%li
= render :partial => "builds/step", :locals => {:step => build.output[0], :step_no => 0}
- @build.parts.each_with_index do |part, index|
- %h3{ :class => part.output[0].exit_code == 0 ? "status_build_ok" : "status_build_failed"}
+ %h3{ :class => exit_code_ok?(part) ? "status_build_ok" : "status_build_failed"}
= part.name
%ul{:id => "part_#{index}", :class => 'unstyled' }
- part.output.each_with_index do |output, index|

0 comments on commit 73076fa

Please sign in to comment.