X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eedf8a55e4e14d8721b209201b2bdd96d5b6738e..574513ae1a047910d282effc58611d86b0401ac3:/test/controllers/diary_entries_controller_test.rb diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index c9464ffed..b47446878 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -135,7 +135,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_select "input[name=commit][type=submit][value=Publish]", :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 "input", :count => 6 end end end @@ -164,7 +164,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :new - assert_nil UserPreference.where(:user_id => user.id, :k => "diary.default_language").first + assert_nil UserPreference.find_by(:user => user, :k => "diary.default_language") end def test_create @@ -189,7 +189,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest # checks if user was subscribed assert_equal 1, entry.subscribers.length - assert_equal "en", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v + assert_equal "en", UserPreference.find_by(:user => user, :k => "diary.default_language").v end def test_create_german @@ -216,7 +216,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest # checks if user was subscribed assert_equal 1, entry.subscribers.length - assert_equal "de", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v + assert_equal "de", UserPreference.find_by(:user => user, :k => "diary.default_language").v end def test_new_spammy @@ -294,7 +294,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_select "input[name=commit][type=submit][value=Update]", :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 => 8 + assert_select "input", :count => 7 end end @@ -563,35 +563,35 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest # Try and get the index get diary_entries_path assert_response :success - assert_select "div.diary_post", :count => 20 + assert_select "article.diary_post", :count => 20 assert_select "li.page-item a.page-link", :text => "Older Entries", :count => 1 assert_select "li.page-item.disabled span.page-link", :text => "Newer Entries", :count => 1 # Try and get the second page - get css_select("li.page-item a.page-link").first["href"] + get css_select("li.page-item .page-link").last["href"] assert_response :success - assert_select "div.diary_post", :count => 20 + assert_select "article.diary_post", :count => 20 assert_select "li.page-item a.page-link", :text => "Older Entries", :count => 1 assert_select "li.page-item a.page-link", :text => "Newer Entries", :count => 1 # Try and get the third page - get css_select("li.page-item a.page-link").first["href"] + get css_select("li.page-item .page-link").last["href"] assert_response :success - assert_select "div.diary_post", :count => 10 + assert_select "article.diary_post", :count => 10 assert_select "li.page-item.disabled span.page-link", :text => "Older Entries", :count => 1 assert_select "li.page-item a.page-link", :text => "Newer Entries", :count => 1 # Go back to the second page - get css_select("li.page-item a.page-link").last["href"] + get css_select("li.page-item .page-link").first["href"] assert_response :success - assert_select "div.diary_post", :count => 20 + assert_select "article.diary_post", :count => 20 assert_select "li.page-item a.page-link", :text => "Older Entries", :count => 1 assert_select "li.page-item a.page-link", :text => "Newer Entries", :count => 1 # Go back to the first page - get css_select("li.page-item a.page-link").last["href"] + get css_select("li.page-item .page-link").first["href"] assert_response :success - assert_select "div.diary_post", :count => 20 + assert_select "article.diary_post", :count => 20 assert_select "li.page-item a.page-link", :text => "Older Entries", :count => 1 assert_select "li.page-item.disabled span.page-link", :text => "Newer Entries", :count => 1 end @@ -695,9 +695,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_template :show # Try a non-integer ID - assert_raise ActionController::RoutingError do - get "/user/#{CGI.escape(user.display_name)}/diary/#{diary_entry.id})" - end + get "/user/#{CGI.escape(user.display_name)}/diary/#{diary_entry.id})" + assert_response :not_found + assert_template "rescues/routing_error" # Try a deleted entry diary_entry_deleted = create(:diary_entry, :user => user, :visible => false) @@ -997,7 +997,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "index" assert_no_missing_translations - assert_select "div.diary_post", entries.count + assert_select "article.diary_post", entries.count entries.each do |entry| assert_select "a[href=?]", "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}"