0
@@ -3,6 +3,9 @@ require "net/http"
0
+`mysql -f --user=root -D chyrp -e 'TRUNCATE TABLE chyrp_posts; TRUNCATE TABLE chyrp_pages; TRUNCATE TABLE chyrp_comments; TRUNCATE TABLE chyrp_tags;' > /dev/null`
0
:textarea => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam urna. Vivamus nisl. Mauris iaculis rutrum elit. Cras ornare congue mi. Nullam mi quam, luctus dapibus, euismod ut, dapibus sed, dui. Praesent est lectus, rutrum ac, blandit vitae, hendrerit at, massa. Morbi mauris purus, lobortis vel, commodo vitae, aliquet vehicula, ante. Nunc commodo. Pellentesque vel lacus. Quisque eros. Maecenas et quam. Curabitur eget justo a ante dignissim dapibus. Sed et lacus. Suspendisse potenti. Vivamus ipsum mi, blandit vitae, scelerisque a, pellentesque vitae, nisl. Donec vitae est et est egestas laoreet. Vestibulum commodo elit ut nisl. Nullam volutpat nisi non elit. Morbi sapien eros, ornare et, dapibus id, mattis id, nibh. Suspendisse ut nisl id est scelerisque faucibus.\n\nPraesent viverra felis nec justo. Duis gravida tempor massa. Aliquam lobortis tortor eu purus. Phasellus volutpat, justo eget molestie rhoncus, nibh tortor suscipit justo, non vehicula tortor tortor id sapien. Vivamus quis nisl et neque ullamcorper viverra. Vestibulum accumsan, elit luctus auctor fermentum, lorem tellus dignissim odio, a lobortis magna nulla eget arcu. Phasellus vel erat at dolor sagittis luctus. Nulla facilisi. In eros eros, molestie sit amet, ornare a, fermentum et, dui. Vivamus vel turpis quis diam iaculis dapibus. Nunc lacinia. Integer commodo, urna interdum imperdiet pretium, libero nulla pellentesque turpis, in ultrices neque tortor at arcu. Sed mollis odio eget mauris ultricies bibendum. Vivamus malesuada metus vel arcu. Nam sit amet metus. Pellentesque quis felis non nibh adipiscing adipiscing.",
0
@@ -17,29 +20,64 @@ HEADERS = {
0
"User-Agent" => "tester.rb"
0
+ "title" => "Test Text Post",
0
+ "body" => FUZZER[:textarea]
0
+ "quote" => FUZZER[:textarea].split(". ")[0] + ".",
0
+ "source" => "Chyrp Tester"
0
+ "title" => "Test Chat Post",
0
+ "dialogue" => "Person: Hi!\nMe (me): Hello!\nPerson: How are you?\nMe: Great, thanks! And you?\nPerson: FUCKING AWESOME."
0
+ "name" => "Google Search",
0
+ "source" => "http://google.com/",
0
+ "description" => "I can't believe how long I've gone without finding this site."
0
class Chyrp < Test::Unit::TestCase
0
- resp, write = get "/admin/?action=write_post"
0
+ POSTS.each do |feather, attrs|
0
+ resp, write = get "/admin/?action=write_post&feather="+ feather.to_s
0
- post (page/"form").attr("action"), form_fuzz(page/"form")
0
+ form_fuzz(page/"form").each do |key, val|
0
+ attrs[key] = val unless attrs.has_key? key
0
+ attrs['feather'] = feather.to_s
0
+ post (page/"form").attr("action"), attrs
0
- resp, write = get "/admin/?action=write_post"
0
+ POSTS.each do |feather, attrs|
0
+ resp, write = get "/admin/?action=write_post&feather="+ feather.to_s
0
- data = form_fuzz(page/"form")
0
- data['draft'] = "true"
0
+ form_fuzz(page/"form").each do |key, val|
0
+ attrs[key] = val unless attrs.has_key? key
0
+ attrs['feather'] = feather.to_s
0
+ attrs['draft'] = "true"
0
- post (page/"form").attr("action"), data
0
+ post (page/"form").attr("action"), attrs
0
resp, page = test_index
0
+ return unless page =~ /class="post /
0
post_url = (page/".post:first/h2/a").attr("href")
0
@@ -58,7 +96,10 @@ class Chyrp < Test::Unit::TestCase
0
resp, page = test_index
0
- page_url = (page/"#sidebar/ul:nth(0)/li:nth(0)/a").attr("href")
0
+ first_page = (page/"#sidebar/ul:nth(0)/li:nth(0)/a")
0
+ return unless first_page
0
+ page_url = first_page.attr("href")
0
@@ -125,6 +166,7 @@ class Chyrp < Test::Unit::TestCase
0
resp, page = get("/page/2/")
0
+ return unless page =~ /class="post /
0
assert_match /Page 2 of /, page, "No pagination links displayed."
0
@@ -174,33 +216,16 @@ class Chyrp < Test::Unit::TestCase
0
(form/"*[@name]").each do |field|
0
- if field['type'] == "hidden" or (field.name != "textarea" and field['value'] != "") or (field.name == "textarea" and !field.empty?)
0
- if field.name == "select"
0
- selected = (field/"option[@selected]")
0
- option = selected.length > 0 ? selected : (field/"option:nth(0)")
0
- data[field['name']] = option.attr("value")
0
- elsif field.name != "button"
0
- if field['type'] == "checkbox"
0
- data[field['name']] = (field['checked'] || "no") == "checked" ? "1" : "0"
0
- data[field['name']] = field['value'] || field.html
0
+ next unless data[field['name']].nil? or data[field['name']].empty?
0
if field.name == "textarea"
0
data[field['name']] = FUZZER[:textarea]
0
elsif field.name == "input"
0
- next if field['name'] == "trackbacks"
0
- if field['name'] == "slug"
0
- data[field['name']] = "test-slug"
0
- data[field['name']] = FUZZER[:text]
0
+ next if field['type'] != "text" or field['name'] == "trackbacks" or field['name'] == "slug"
0
+ data[field['name']] = FUZZER[:text]