Skip to content

Commit 1c14d7f

Browse files
committed
Test note/tag output created at POST/HTML level
Added testing of note XML, JSON, GPX, RSS and feed outputs (with tags) when note (and tags) are created by sending POST/HTTP request.
1 parent dcb5242 commit 1c14d7f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/controllers/api/notes_controller_test.rb

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "test_helper"
2+
require "json"
23

34
module Api
45
class NotesControllerTest < ActionDispatch::IntegrationTest
@@ -105,7 +106,18 @@ def test_create_anonymous_success
105106
assert_difference "Note.count", 1 do
106107
assert_difference "NoteComment.count", 1 do
107108
assert_no_difference "NoteSubscription.count" do
108-
post api_notes_path(:lat => -1.0, :lon => -1.0, :text => "This is a comment", :format => "json")
109+
assert_difference "NoteTag.count", 2 do
110+
post api_notes_path(
111+
:lat => -1.0,
112+
:lon => -1.0,
113+
:tags => {
114+
"created_by" => "OSM_TEST",
115+
"삭ÒX~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|傥4ր" => "Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|؇Őϋ"
116+
}.to_json,
117+
:text => "This is a comment",
118+
:format => "json"
119+
)
120+
end
109121
end
110122
end
111123
end
@@ -116,6 +128,9 @@ def test_create_anonymous_success
116128
assert_equal "Point", js["geometry"]["type"]
117129
assert_equal [-1.0, -1.0], js["geometry"]["coordinates"]
118130
assert_equal "open", js["properties"]["status"]
131+
assert_equal 2, js["properties"]["tags"].count
132+
assert_equal "OSM_TEST", js["properties"]["tags"]["created_by"]
133+
assert_equal "Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|؇Őϋ", js["properties"]["tags"]["삭ÒX~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|傥4ր"]
119134
assert_equal 1, js["properties"]["comments"].count
120135
assert_equal "opened", js["properties"]["comments"].last["action"]
121136
assert_equal "This is a comment", js["properties"]["comments"].last["text"]
@@ -131,6 +146,9 @@ def test_create_anonymous_success
131146
assert_equal [-1.0, -1.0], js["geometry"]["coordinates"]
132147
assert_equal id, js["properties"]["id"]
133148
assert_equal "open", js["properties"]["status"]
149+
assert_equal 2, js["properties"]["tags"].count
150+
assert_equal "OSM_TEST", js["properties"]["tags"]["created_by"]
151+
assert_equal "Ƭ߯ĸá~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|؇Őϋ", js["properties"]["tags"]["삭ÒX~`!@#$%^&*()-=_+,<.>/?;:'\"[{}]\\|傥4ր"]
134152
assert_equal 1, js["properties"]["comments"].count
135153
assert_equal "opened", js["properties"]["comments"].last["action"]
136154
assert_equal "This is a comment", js["properties"]["comments"].last["text"]

0 commit comments

Comments
 (0)