]> git.openstreetmap.org Git - rails.git/commitdiff
Update tests for layout changes
authorTom Hughes <tom@compton.nu>
Tue, 8 Jan 2013 22:11:54 +0000 (22:11 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 14 Jan 2013 22:30:54 +0000 (22:30 +0000)
test/functional/changeset_controller_test.rb
test/functional/diary_entry_controller_test.rb
test/integration/client_application_test.rb
test/integration/user_diaries_test.rb

index 21cae1f000a9359aae37ccdf381f0727e6d7eef1..9ed9f295954ba3dc90382c4011933559c315f697 100644 (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_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
     changesets.each do |changeset|
       # FIXME this test needs rewriting - test for table contents
     end
index d799ddf5a31cb48667f4aada35b0cde87ac58fab..52356d91301caaf9ea55f0d52e5a728fca6ae16d 100644 (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 "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
           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_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
         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 "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
           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 "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
         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 "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
           end
         end
       end
index 9ab32ca7810f6ae3aa8687d74b3b15371d803983..f34a9c430fbf14463727caa42f8b24b4ccf2e9e1 100644 (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_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
     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
     # 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"
       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}]"
       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
 
     # 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
   ##
   # utility method to make the HTML screening easier to read.
   def assert_in_body
index fab05894fe924a6b55f48629c6bec2d0fa291339..23687fa8e948646e2195a8af34a0019bc98ad1eb 100644 (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
     # 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
           end
         end
       end