From: Alexandre Terrasa Date: Tue, 1 May 2018 19:30:11 +0000 (-0400) Subject: doc/commands: parse CmdEntityLink commands from http X-Git-Url: http://nitlanguage.org doc/commands: parse CmdEntityLink commands from http Signed-off-by: Alexandre Terrasa --- diff --git a/src/doc/commands/commands_http.nit b/src/doc/commands/commands_http.nit index d35161b..70d2062 100644 --- a/src/doc/commands/commands_http.nit +++ b/src/doc/commands/commands_http.nit @@ -85,6 +85,14 @@ redef class CmdComment end end +redef class CmdEntityLink + redef fun http_init(req) do + text = req.string_arg("text") + title = req.string_arg("title") + return super + end +end + redef class CmdAncestors redef fun http_init(req) do parents = req.bool_arg("parents") or else true diff --git a/src/doc/commands/tests/test_commands_http.nit b/src/doc/commands/tests/test_commands_http.nit index 7cdd240..c081699 100644 --- a/src/doc/commands/tests/test_commands_http.nit +++ b/src/doc/commands/tests/test_commands_http.nit @@ -77,6 +77,44 @@ class TestCommandsHttp assert res isa WarningNoMDoc end + # CmdEntityLink + + fun test_cmd_http_link is test do + var req = new_request("/test_prog::Character") + var cmd = new CmdEntityLink(test_view) + var res = cmd.http_init(req) + assert res isa CmdSuccess + assert cmd.text == "Character" + assert cmd.title == "Characters can be played by both the human or the machine." + end + + fun test_cmd_http_link_with_text is test do + var req = new_request("/test_prog::Character?text=foo") + var cmd = new CmdEntityLink(test_view) + var res = cmd.http_init(req) + assert res isa CmdSuccess + assert cmd.text == "foo" + assert cmd.title == "Characters can be played by both the human or the machine." + end + + fun test_cmd_http_link_with_title is test do + var req = new_request("/test_prog::Character?title=bar") + var cmd = new CmdEntityLink(test_view) + var res = cmd.http_init(req) + assert res isa CmdSuccess + assert cmd.text == "Character" + assert cmd.title == "bar" + end + + fun test_cmd_http_link_with_text_and_title is test do + var req = new_request("/test_prog::Character?text=foo&title=bar") + var cmd = new CmdEntityLink(test_view) + var res = cmd.http_init(req) + assert res isa CmdSuccess + assert cmd.text == "foo" + assert cmd.title == "bar" + end + # CmdInheritance fun test_cmd_http_parents is test do