From b41dfb8c68561148b33a5fda232845d4670d63e8 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 1 May 2018 15:30:11 -0400 Subject: [PATCH] doc/commands: parse CmdEntityLink commands from http Signed-off-by: Alexandre Terrasa --- src/doc/commands/commands_http.nit | 8 ++++++ src/doc/commands/tests/test_commands_http.nit | 38 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) 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 -- 1.7.9.5