Update tests for layout changes

This commit is contained in:
Tom Hughes 2013-01-08 22:11:54 +00:00
parent 4c9a3d4803
commit ed699548e6
4 changed files with 90 additions and 52 deletions

View file

@ -1735,7 +1735,7 @@ EOF
assert_template "list"
# Now check that all 20 (or however many were returned) changesets are in the html
assert_select "h1", :text => "Changesets", :count => 1
assert_select "table[id='changeset_list'] tr", :count => changesets.size
assert_select "div[id='changeset_list'] ul", :count => changesets.size
changesets.each do |changeset|
# FIXME this test needs rewriting - test for table contents
end

View file

@ -103,16 +103,20 @@ class DiaryEntryControllerTest < ActionController::TestCase
assert_select "title", :text => /New Diary Entry/, :count => 1
end
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "h1", :text => "New Diary Entry", :count => 1
# We don't care about the layout, we just care about the form fields
# that are available
assert_select "form[action='/diary/new']", :count => 1 do
assert_select "input[id=diary_entry_title][name='diary_entry[title]']", :count => 1
assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :count => 1
assert_select "input#latitude[name='diary_entry[latitude]'][type=text]", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]'][type=text]", :count => 1
assert_select "input[name=commit][type=submit][value=Save]", :count => 1
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
assert_select "h1", :text => "New Diary Entry", :count => 1
end
assert_select "div#content", :count => 1 do
# We don't care about the layout, we just care about the form fields
# that are available
assert_select "form[action='/diary/new']", :count => 1 do
assert_select "input[id=diary_entry_title][name='diary_entry[title]']", :count => 1
assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :count => 1
assert_select "input#latitude[name='diary_entry[latitude]'][type=text]", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]'][type=text]", :count => 1
assert_select "input[name=commit][type=submit][value=Save]", :count => 1
end
end
end
end
@ -135,8 +139,10 @@ class DiaryEntryControllerTest < ActionController::TestCase
assert_response :not_found
assert_select "html", :count => 1 do
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "h2", :text => "No entry with the id: 9999", :count => 1
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => "No entry with the id: 9999", :count => 1
end
end
end
end
@ -150,18 +156,22 @@ class DiaryEntryControllerTest < ActionController::TestCase
assert_select "title", :text => /Edit diary entry/, :count => 1
end
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "h1", :text => /Edit diary entry/, :count => 1
assert_select "form[action='/user/#{entry.user.display_name}/diary/#{entry.id}/edit'][method=post]", :count => 1 do
assert_select "input#diary_entry_title[name='diary_entry[title]'][value='#{entry.title}']", :count => 1
assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => entry.body, :count => 1
assert_select "select#diary_entry_language_code", :count => 1
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
assert_select "input[name=commit][type=submit][value=Save]", :count => 1
assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
assert_select "input", :count => 7
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
assert_select "h1", :text => /Edit diary entry/, :count => 1
end
assert_select "div#content", :count => 1 do
assert_select "form[action='/user/#{entry.user.display_name}/diary/#{entry.id}/edit'][method=post]", :count => 1 do
assert_select "input#diary_entry_title[name='diary_entry[title]'][value='#{entry.title}']", :count => 1
assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => entry.body, :count => 1
assert_select "select#diary_entry_language_code", :count => 1
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
assert_select "input[name=commit][type=submit][value=Save]", :count => 1
assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
assert_select "input", :count => 7
end
end
end
end
@ -189,16 +199,20 @@ class DiaryEntryControllerTest < ActionController::TestCase
assert_select "title", :text => /Users' diaries | /, :count => 1
end
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "h2", :text => /#{entry.user.display_name}&#x27;s diary/, :count => 1
assert_select "b", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "p", :text => /#{new_body}/, :count => 1
assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
# As we're not logged in, check that you cannot edit
#print @response.body
assert_select "a[href='/user/#{entry.user.display_name}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => /#{entry.user.display_name}&#x27;s diary/, :count => 1
end
assert_select "div#content", :count => 1 do
assert_select "div.post_heading", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "p", :text => /#{new_body}/, :count => 1
assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
# As we're not logged in, check that you cannot edit
#print @response.body
assert_select "a[href='/user/#{entry.user.display_name}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
end
end
end
end
@ -214,16 +228,20 @@ class DiaryEntryControllerTest < ActionController::TestCase
assert_select "title", :text => /Users' diaries | /, :count => 1
end
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "h2", :text => /#{users(:normal_user).display_name}&#x27;s diary/, :count => 1
assert_select "b", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "p", :text => /#{new_body}/, :count => 1
assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
# As we're not logged in, check that you cannot edit
assert_select "span[class=hidden show_if_user_#{entry.user.id}]", :count => 1 do
assert_select "a[href='/user/#{entry.user.display_name}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => /#{users(:normal_user).display_name}&#x27;s diary/, :count => 1
end
assert_select "div#content", :count => 1 do
assert_select "div.post_heading", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "p", :text => /#{new_body}/, :count => 1
assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
# As we're not logged in, check that you cannot edit
assert_select "span[class=hidden show_if_user_#{entry.user.id}]", :count => 1 do
assert_select "a[href='/user/#{entry.user.display_name}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
end
end
end
end

View file

@ -22,8 +22,8 @@ class ClientApplicationTest < ActionController::IntegrationTest
assert_template 'user/account'
# check that the form to allow new client application creations exists
assert_in_body do
assert_select "a[href='/user/test2/oauth_clients']"
assert_in_heading do
assert_select "ul.secondary-actions li a[href='/user/test2/oauth_clients']"
end
# now we follow the link to the oauth client list
@ -36,8 +36,10 @@ class ClientApplicationTest < ActionController::IntegrationTest
# now we follow the link to the new oauth client page
get '/user/test2/oauth_clients/new'
assert_response :success
assert_in_body do
assert_in_heading do
assert_select "h1", "Register a new application"
end
assert_in_body do
assert_select "form[action='/user/test2/oauth_clients']" do
[ :name, :url, :callback_url, :support_url ].each do |inp|
assert_select "input[name=?]", "client_application[#{inp}]"
@ -74,6 +76,20 @@ class ClientApplicationTest < ActionController::IntegrationTest
# tests, as its too tied into the HTTP headers and stuff that it signs.
end
##
# utility method to make the HTML screening easier to read.
def assert_in_heading
assert_select "html:root" do
assert_select "body" do
assert_select "div.wrapper" do
assert_select "div.content-heading" do
yield
end
end
end
end
end
##
# utility method to make the HTML screening easier to read.
def assert_in_body

View file

@ -38,10 +38,14 @@ class UserDiariesTest < ActionController::IntegrationTest
# that need to be tested, which can't be tested in the functional tests
assert_select "html:root" do
assert_select "body" do
assert_select "div#content" do
assert_select "h1", "New Diary Entry"
assert_select "form[action='/diary/new']" do
assert_select "input[id=diary_entry_title]"
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
assert_select "h1", "New Diary Entry"
end
assert_select "div#content" do
assert_select "form[action='/diary/new']" do
assert_select "input[id=diary_entry_title]"
end
end
end
end