From bd52817e9f9b3d1da3fc117a61d07d01e4c6a5de Mon Sep 17 00:00:00 2001 From: Nenad Vujicic Date: Tue, 12 Nov 2024 18:44:12 +0100 Subject: [PATCH] Test note/tag output created at ActiveRecord level Added testing of note XML, JSON and GPX outputs (with tags) when note (and tags) are created on FactoryBot / ActiveRecord level. --- test/controllers/api/notes_controller_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/controllers/api/notes_controller_test.rb b/test/controllers/api/notes_controller_test.rb index 5f69e6a2ac..4399b53b6d 100644 --- a/test/controllers/api/notes_controller_test.rb +++ b/test/controllers/api/notes_controller_test.rb @@ -594,6 +594,8 @@ def test_reopen_fail def test_show_success open_note = create(:note_with_comments) + create(:note_tag, :note => open_note, :k => "created_by", :v => "OSM_TEST") + create(:note_tag, :note => open_note, :k => "삭ÒX~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|傥4ր", :v => "Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|؇Őϋ") get api_note_path(open_note, :format => "xml") assert_response :success @@ -610,6 +612,8 @@ def test_show_success assert_select "comment", :count => 1 end end + assert_select "tag[k='created_by'][v='OSM_TEST']", :count => 1 + assert_select "tag[k='삭ÒX~`!@#$%^&*()-=_+,<.>/?;:\\'\"[{}]\\\\|傥4ր'][v='Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:\\'\"[{}]\\\\|؇Őϋ']", :count => 1 end get api_note_path(open_note, :format => "rss") @@ -643,6 +647,8 @@ def test_show_success assert_equal close_api_note_url(open_note, :format => "json"), js["properties"]["close_url"] assert_equal open_note.created_at.to_s, js["properties"]["date_created"] assert_equal open_note.status, js["properties"]["status"] + assert_equal "OSM_TEST", js["properties"]["tags"]["created_by"] + assert_equal "Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|؇Őϋ", js["properties"]["tags"]["삭ÒX~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|傥4ր"] get api_note_path(open_note, :format => "gpx") assert_response :success @@ -658,6 +664,8 @@ def test_show_success assert_select "url", api_note_url(open_note, :format => "gpx") assert_select "comment_url", comment_api_note_url(open_note, :format => "gpx") assert_select "close_url", close_api_note_url(open_note, :format => "gpx") + assert_select "tag[k='created_by'][v='OSM_TEST']", :count => 1 + assert_select "tag[k='삭ÒX~`!@#$%^&*()-=_+,<.>/?;:\\'\"[{}]\\\\|傥4ր'][v='Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:\\'\"[{}]\\\\|؇Őϋ']", :count => 1 end end end