Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
Adding a test when log is nil, also rendering an empty string instead…
Browse files Browse the repository at this point in the history
… of nil
  • Loading branch information
tecnobrat committed Mar 27, 2012
1 parent b14ceea commit ff142d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -76,7 +76,8 @@ def display_builder_state(state)
end

def format_changeset_log(log)
h(log.strip) if log.present?
log = "" if log.blank?
h(log.strip)
end

def elapsed_time(build, format = :general)
Expand Down
5 changes: 5 additions & 0 deletions test/unit/application_helper_test.rb
Expand Up @@ -35,6 +35,11 @@ class ApplicationHelperTest < ActionView::TestCase
end

context "#format_changeset_log" do
test "should render nothing if log is nil" do
@helper.extend(ERB::Util)
assert_equal "", @helper.format_changeset_log(nil)
end

test "should strip html tags" do
@helper.extend(ERB::Util)
assert_equal "&lt;hr /&gt;some changeset&lt;script&gt;alert('bad')&lt;/script&gt;",
Expand Down

1 comment on commit ff142d1

@seanmarcia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix! Foomip fixed this another way, he used

CGI.escapeHTML(log.strip)

Which removed the exception. Sorry it took so long for someone to reply. I was just recently given access to the project so you can expect more timely replies to anything.

Please sign in to comment.