aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2024-03-20 11:25:44 +0100
committerMiquel Sabaté Solà <msabate@suse.com>2024-03-20 11:25:44 +0100
commit2cf0ffbffc8442efaba12364a07fc0f5e58b7432 (patch)
treec4c253b8adca4491ed506e3762a04e7a41ce4adf /test
parent120658d6b6314f0a90bd7656baee734753bad2db (diff)
downloadoperum-2cf0ffbffc8442efaba12364a07fc0f5e58b7432.tar.gz
operum-2cf0ffbffc8442efaba12364a07fc0f5e58b7432.zip
Support underscore in the exporters on titles
Underscores on titles are meant to be replaced by something else on each exporter (e.g. removed on CSV, or surrounded by \emph on UOC). Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'test')
-rw-r--r--test/controllers/exports_controller_test.rb18
-rw-r--r--test/fixtures/files/underscores.uoc.tex9
2 files changed, 27 insertions, 0 deletions
diff --git a/test/controllers/exports_controller_test.rb b/test/controllers/exports_controller_test.rb
index 9e69df8..eefff6f 100644
--- a/test/controllers/exports_controller_test.rb
+++ b/test/controllers/exports_controller_test.rb
@@ -15,10 +15,28 @@ class ExportsControllerTest < ActionDispatch::IntegrationTest
assert_equal 'text/csv', @response.media_type
end
+ test 'csv: underscore is removed for the title' do
+ things(:thing1).update!(title: 'This is a _title_ with _many_ underscores')
+
+ get search_exports_url(0, format: 'csv')
+
+ body = @response.body.split("\n")
+
+ assert_equal 'This is a title with many underscores', body.last.split(',')[7]
+ end
+
test 'uoc: works' do
get search_exports_url(0, format: 'uoc')
assert_equal @response.body, file_fixture('all.uoc.tex').read
assert_equal 'application/x-tex', @response.media_type
end
+
+ test 'uoc: underscore is supported for the title' do
+ things(:thing1).update!(title: 'This is a _title_ with _many_ underscores')
+
+ get search_exports_url(0, format: 'uoc')
+
+ assert_equal @response.body, file_fixture('underscores.uoc.tex').read
+ end
end
diff --git a/test/fixtures/files/underscores.uoc.tex b/test/fixtures/files/underscores.uoc.tex
new file mode 100644
index 0000000..0c86890
--- /dev/null
+++ b/test/fixtures/files/underscores.uoc.tex
@@ -0,0 +1,9 @@
+\chapter{Bibliografia}
+
+{\setlength{\parskip}{-0.3cm}
+
+\hypertarget{target2}{\textsc{Sabaté}, Miquel; \textsc{Nom} (eds.) (2024). \emph{This is a 2}. Dins de \emph{Some other thing}, 22-24. This is a note 2. Publisher 2, Address 2: 2024.}
+
+\\~\\\hypertarget{target1}{\textsc{Sabaté}, Miquel; \textsc{Smith}, John; \textsc{cognom2}, Nom cognom1; \textsc{cognom3 cognom4}, Nom (2024). \emph{This is a }title\emph{ with }many\emph{ underscores}. Dins de \emph{Some other thing}, 22-24. This is a note 1. Publisher 1. [\url{http://example.com}]. [Última data de consulta: 24 de febrer de 2024].}
+
+}