Added a check for XML well-formedness to assert_success

(optional, enabled by uncommenting a variable at the top of test_helper.rb);
corrected some malformed templates (not all yet)
instiki-madeleine
Alexey Verkhovsky 2005-01-23 16:34:27 +00:00
parent 203405c4dc
commit c8e459cbb0
4 changed files with 37 additions and 24 deletions

View File

@ -8,12 +8,12 @@
<p>
File to upload:
<br/>
<input type="file" name="file" size="40">
<input type="file" name="file" size="40" />
</p>
<p>
<input type="submit" value="Update"> as
<input type="submit" value="Update" /> as
<input type="text" name="author" id="authorName" value="<%= @author %>"
onClick="this.value == 'AnonymousCoward' ? this.value = '' : true">
onClick="this.value == 'AnonymousCoward' ? this.value = '' : true" />
<% if @page %>
| <a href="../file/">Cancel</a> <small>(unlocks page)</small>
<% end %>

View File

@ -17,7 +17,7 @@ end
<%= list_item "Authors", "../authors/", "Who wrote what" %> |
<%= list_item "Feeds", "../feeds/", "Subscribe to changes by RSS" %> |
<%= list_item "Export", "../export/", "Download a zip with all the pages in this wiki", "X" %> |
<input type="text" id="searchField" name="query" style="font-size: 10px" value="Search" onClick="this.value == 'Search' ? this.value = '' : true">
<input type="text" id="searchField" name="query" style="font-size: 10px" value="Search" onClick="this.value == 'Search' ? this.value = '' : true" />
<% else %>
<%= list_item "Home Page", "../published/HomePage", "Home, Sweet Home", "H" %> |
<% end%>

View File

@ -8,8 +8,8 @@
</div>
<div class="inputBox">
Name: <input type="text" id="name" name="name" value="<%= @web.name %>" onChange="proposeAddress();"> &nbsp;&nbsp;
Address: <input type="text" id="address" name="address" value="<%= @web.address %>" onChange="cleanAddress();">
Name: <input type="text" id="name" name="name" value="<%= @web.name %>" onChange="proposeAddress();" /> &nbsp;&nbsp;
Address: <input type="text" id="address" name="address" value="<%= @web.address %>" onChange="cleanAddress();" />
<i>(Letters & digits only)</i>
</div>
@ -30,24 +30,17 @@
Color:
<select name="color">
<%= html_options({ "Green" => "008B26", "Purple" => "504685", "Red" => "DA0006", "Orange" => "FA6F00", "Grey" => "8BA2B0" },
@web.color) %>
<%= html_options({ "Green" => "008B26", "Purple" => "504685", "Red" => "DA0006", "Orange" => "FA6F00", "Grey" => "8BA2B0" }, @web.color) %>
</select>
&nbsp;&nbsp;
<small>
<input type="checkbox" name="safe_mode"<%= " CHECKED" if @web.safe_mode %>> Safe mode
&nbsp;&nbsp;
<input type="checkbox" name="brackets_only"<%= " CHECKED" if @web.brackets_only %>> Brackets only
&nbsp;&nbsp;
<input type="checkbox" name="count_pages"<%= " CHECKED" if @web.count_pages %>> Count pages
<input type="checkbox" name="safe_mode"<%= " CHECKED" if @web.safe_mode %>> Safe mode
&nbsp;&nbsp;
<input type="checkbox" name="brackets_only"<%= " CHECKED" if @web.brackets_only %>> Brackets only
&nbsp;&nbsp;
<input type="checkbox" name="count_pages"<%= " CHECKED" if @web.count_pages %>> Count pages
</small>
<textarea id="additionalStyle" style="display: none; margin-top: 10px; margin-bottom: 5px; width: 560px; height: 200px" name="additional_style"><%= @web.additional_style %></textarea>
@ -114,23 +107,23 @@ function validateSetup() {
alert("You must enter the system password");
return false;
}
if (document.getElementById('name').value == "") {
alert("You must pick a name for the web");
return false;
}
if (document.getElementById('address').value == "") {
alert("You must pick an address for the web");
return false;
}
if (document.getElementById('password').value != "" &&
document.getElementById('password').value != document.getElementById('password_check').value) {
alert("The password and its verification doesn't match");
return false;
}
return true;
}
</script>

View File

@ -1,10 +1,12 @@
ENV['RAILS_ENV'] ||= 'test'
require File.dirname(__FILE__) + '/../config/environment'
require 'application'
require 'test/unit'
require 'action_controller/test_process'
# Uncomment this variable to have assert_success check that response bodies are valid XML
# $validate_xml_in_assert_success = true
# Convenient setup method for Test::Unit::TestCase
class Test::Unit::TestCase
@ -93,3 +95,21 @@ module ChunkMatch
end
end
if defined? $validate_xml_in_assert_success and $validate_xml_in_assert_success == true
module Test
module Unit
module Assertions
alias :__assert_success_before_ovverride_by_instiki :assert_success
def assert_success
__assert_success_before_ovverride_by_instiki
if @response.body.kind_of?(Proc)
body = @response.body.call
else
body = @response.body
end
assert_nothing_raised(body) { REXML::Document.new(body) }
end
end
end
end
end