Skip to content

Commit

Permalink
Test note/tag output created at ActiveRecord level
Browse files Browse the repository at this point in the history
Added testing of note XML, JSON and GPX outputs (with tags) when note (and tags) are created on FactoryBot / ActiveRecord level.
  • Loading branch information
nenad-vujicic committed Dec 10, 2024
1 parent 1f304e5 commit bd52817
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/controllers/api/notes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bd52817

Please sign in to comment.