From 3fbf4205a0dc4d5d6137492dfc7229287b9029ee Mon Sep 17 00:00:00 2001 From: KMY Date: Thu, 22 Feb 2024 14:09:02 +0900 Subject: [PATCH] Fix test --- app/models/admin/ng_rule.rb | 2 +- spec/models/admin/ng_rule_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/admin/ng_rule.rb b/app/models/admin/ng_rule.rb index aeb13e62ac11f4..f63b2ee08bd925 100644 --- a/app/models/admin/ng_rule.rb +++ b/app/models/admin/ng_rule.rb @@ -198,7 +198,7 @@ def detect_keyword?(text, arr) class << self def string_to_array(text) - text.split("\n") + text.delete("\r").split("\n") end def detect_keyword(text, arr) diff --git a/spec/models/admin/ng_rule_spec.rb b/spec/models/admin/ng_rule_spec.rb index f4e9d337ecbb1a..df4081a6876587 100644 --- a/spec/models/admin/ng_rule_spec.rb +++ b/spec/models/admin/ng_rule_spec.rb @@ -71,6 +71,14 @@ it_behaves_like 'matches rule', 'account' end + context 'with display name rule' do + let(:uri) { '' } + let(:account) { Fabricate(:account, display_name: '') } + let(:ng_rule) { Fabricate(:ng_rule, account_display_name: "?^$\r\n?[a-z0-9]{10}", account_include_local: true) } + + it_behaves_like 'matches rule', 'account' + end + context 'with field name rule' do let(:account) { Fabricate(:account, fields_attributes: { '0' => { name: 'Name', value: 'Value' } }, domain: 'example.com', uri: uri) } let(:ng_rule) { Fabricate(:ng_rule, account_field_name: 'Name') }