X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/1b7586c9288d694b2bc443d62f3c40502868ff77..6b44a1976cf07ba50ba8aed8b34434e69a45e62d:/test/controllers/diary_entry_controller_test.rb?ds=inline diff --git a/test/controllers/diary_entry_controller_test.rb b/test/controllers/diary_entry_controller_test.rb index 58fffb8d3..141a86be3 100644 --- a/test/controllers/diary_entry_controller_test.rb +++ b/test/controllers/diary_entry_controller_test.rb @@ -254,7 +254,7 @@ class DiaryEntryControllerTest < ActionController::TestCase get :edit, :params => { :display_name => entry.user.display_name, :id => entry.id } assert_response :redirect - assert_redirected_to :controller => :user, :action => :login, :referer => "/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit" + assert_redirected_to :controller => :user, :action => :login, :referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit" # Verify that you get a not found error, when you pass a bogus id get :edit, @@ -284,7 +284,7 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_select "h1", :text => /Edit diary entry/, :count => 1 end assert_select "div#content", :count => 1 do - assert_select "form[action='/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit'][method=post]", :count => 1 do + assert_select "form[action='/user/#{ERB::Util.u(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 @@ -329,13 +329,13 @@ class DiaryEntryControllerTest < ActionController::TestCase 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/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1 + assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1 end # and when not logged in as the user who wrote the entry get :view, :params => { :display_name => entry.user.display_name, :id => entry.id }, - :session => { :user => entry.user } + :session => { :user => create(:user) } assert_response :success assert_template "diary_entry/view" assert_select "title", :text => /Users' diaries | /, :count => 1 @@ -349,9 +349,7 @@ class DiaryEntryControllerTest < ActionController::TestCase 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 "li[class='hidden show_if_user_#{entry.user.id}']", :count => 1 do - assert_select "a[href='/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1 - end + assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", false end end @@ -430,7 +428,7 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_response :success assert_select ".diary-comment", :count => 1 do assert_select "#comment#{comment.id}", :count => 1 do - assert_select "a[href='/user/#{URI.encode(other_user.display_name)}']", :text => other_user.display_name, :count => 1 + assert_select "a[href='/user/#{ERB::Util.u(other_user.display_name)}']", :text => other_user.display_name, :count => 1 end assert_select ".richtext", :text => /New comment/, :count => 1 end @@ -570,6 +568,21 @@ class DiaryEntryControllerTest < ActionController::TestCase check_diary_list end + def test_list_paged + # Create several pages worth of diary entries + create_list(:diary_entry, 50) + + # Try and get the list + get :list + assert_response :success + assert_select "div.diary_post", :count => 20 + + # Try and get the second page + get :list, :params => { :page => 2 } + assert_response :success + assert_select "div.diary_post", :count => 20 + end + def test_rss create(:language, :code => "de") create(:diary_entry, :language_code => "en") @@ -875,7 +888,7 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_select "div.diary_post", entries.count entries.each do |entry| - assert_select "a[href=?]", "/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}" + assert_select "a[href=?]", "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}" end end end