[Rt-commit] rt branch, 4.4/style-custom-field-name, repushed
Maureen Mirville
maureen at bestpractical.com
Tue Aug 29 15:32:33 EDT 2017
The branch 4.4/style-custom-field-name was deleted and repushed:
was 6047e25fc7564c3f99591247016763dd0071296e
now 6b600ca3e34a733ccf73df660f9a5c7998ce6cf0
1: 6713f24 = 1: 6713f24 Target style at custom field name
2: 6047e25 ! 2: 6b600ca Add tests for CF class selector
@@ -1,21 +1,37 @@
Author: Maureen E. Mirville <maureen at bestpractical.com>
- Added tests for CF class selector
+ Add tests for CF class selector
Tests added to verify that each custom field name has a
corresponding class selector with invalid CSS characters escaped.
+
+diff --git a/share/html/Elements/ShowCustomFields b/share/html/Elements/ShowCustomFields
+--- a/share/html/Elements/ShowCustomFields
++++ b/share/html/Elements/ShowCustomFields
+@@
+ % my $count = $Values->Count;
+ % next if $HideEmpty and not $count;
+ % my $CustomFieldName = $CustomField->Name;
+-%# The following line ensures invalid characters are removed (supports world languages).
++%#The following substitution replaces all non-ID_Continue characters with a dash character. The ID_Continue Unicode property was chosen because it (combined with ID_Start) is meant for variable names. ID_Continue includes characters suitable for use in CSS-class names (even non-Latin ones, to support non-English custom field names) and excludes syntactic characters that are not (such as whitespace characters).
+ % $CustomFieldName =~ s/\P{ID_Continue}+/-/g;
+ % my @classes = (
+ % 'custom-field',
diff --git a/t/customfields/api.t b/t/customfields/api.t
--- a/t/customfields/api.t
+++ b/t/customfields/api.t
@@
+-
++use utf8;
+
use strict;
use warnings FATAL => 'all';
-use RT::Test nodata => 1, tests => 157;
+use RT::Test tests => undef;
use Test::Warn;
-+use Mojo::DOM;
++use CGI;
# Before we get going, ditch all object_cfs; this will remove
# all custom fields systemwide;
@@ -39,20 +55,22 @@
+
+ $m->get_ok($baseurl . '/Admin/CustomFields/Modify.html?Create=1');
+ $m->form_name('ModifyCustomField');
-+ $m->field('Name' => 'test$class%name');
++ $m->field('Name' => 'test class% م 例 name');
+ $m->click('Update');
++ my $url = $m->uri;
++ my $cgi = CGI->new($url);
++ my $cf_id = $cgi->param('id');
+
-+ $m->get_ok($baseurl . '/Admin/CustomFields/Objects.html?id=10');
++ $m->get_ok($baseurl . "/Admin/CustomFields/Objects.html?id=$cf_id");
+ $m->submit_form_ok({
+ with_fields => {
-+ 'AddCustomField-10' => 0,
++ "AddCustomField-$cf_id" => 0,
+ },
+ button => 'UpdateObjs',
+ }, 'Added new custom field globally');
+
+ my $res = $m->get($baseurl . '/Ticket/Display.html?id=1');
-+ my $dom = Mojo::DOM->new($res->decoded_content);
-+ my $class = $dom->at('.custom-field-test-class-name');
-+ like($class, qr/test-class-name/, 'Class selector added to custom field, invalid characters have been escaped');
++ my $element = $m->dom->at(".custom-field-$cf_id");
++ like($element->attr('class'), qr/test-class-م-例-name/, 'Class selector added to custom field, invalid characters have been escaped');
+}
+done_testing();
More information about the rt-commit
mailing list