From 34e16b7d7a88013578014be0402ab686b03f235b Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 1 Jul 2025 08:40:49 +0200 Subject: lib: Introduce the PlainExporter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This class exports things into plain text. It follows a close format to that of the one for UOC, but without any formatting. Signed-off-by: Miquel Sabaté Solà --- test/controllers/exports_controller_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/controllers') diff --git a/test/controllers/exports_controller_test.rb b/test/controllers/exports_controller_test.rb index fe94362..0b0ba1d 100644 --- a/test/controllers/exports_controller_test.rb +++ b/test/controllers/exports_controller_test.rb @@ -42,4 +42,21 @@ class ExportsControllerTest < ActionDispatch::IntegrationTest assert_equal @response.body, file_fixture('underscores.uoc.tex').read end + + test 'plain: works' do + get search_exports_url(0, format: 'txt') + + assert_equal @response.body, file_fixture('all.txt').read.strip + assert_equal 'text/plain', @response.media_type + end + + test 'plain: underscore is removed for the title' do + things(:thing1).update!(title: 'This is a _title_ with _many_ underscores') + + get search_exports_url(0, format: 'txt') + + body = @response.body.split("\n") + + assert_includes body.last, 'This is a title with many underscores' + end end -- cgit v1.2.3