parent
7d96d5828e
commit
9dd11117db
12 changed files with 149 additions and 11 deletions
|
@ -2087,6 +2087,45 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when sensitive word is set' do
|
||||
let(:custom_before) { true }
|
||||
let(:content) { 'Lorem ipsum' }
|
||||
let(:sensitive_words_all) { 'hello' }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Note',
|
||||
content: content,
|
||||
to: 'https://www.w3.org/ns/activitystreams#Public',
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
Form::AdminSettings.new(sensitive_words_all: sensitive_words_all, sensitive_words: 'ipsum').save
|
||||
subject.perform
|
||||
end
|
||||
|
||||
context 'when not contains sensitive words' do
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.spoiler_text).to eq ''
|
||||
end
|
||||
end
|
||||
|
||||
context 'when contains sensitive words' do
|
||||
let(:content) { 'hello world' }
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.spoiler_text).to_not eq ''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when hashtags limit is set' do
|
||||
let(:post_hash_tags_max) { 2 }
|
||||
let(:custom_before) { true }
|
||||
|
|
|
@ -682,7 +682,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is existing' do
|
||||
describe 'ng rule is set' do
|
||||
context 'when ng rule is match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'example.com', status_text: 'universe')
|
||||
|
@ -707,5 +707,42 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sensitive word is set' do
|
||||
let(:payload) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: 'foo',
|
||||
type: 'Note',
|
||||
content: content,
|
||||
updated: '2021-09-08T22:39:25Z',
|
||||
tag: json_tags,
|
||||
}
|
||||
end
|
||||
|
||||
context 'when hit sensitive words' do
|
||||
let(:content) { 'ng word aiueo' }
|
||||
|
||||
it 'update status' do
|
||||
Form::AdminSettings.new(sensitive_words_all: 'test').save
|
||||
|
||||
subject.call(status, json, json)
|
||||
expect(status.reload.text).to eq content
|
||||
expect(status.spoiler_text).to eq ''
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not hit sensitive words' do
|
||||
let(:content) { 'ng word test' }
|
||||
|
||||
it 'update status' do
|
||||
Form::AdminSettings.new(sensitive_words_all: 'test').save
|
||||
|
||||
subject.call(status, json, json)
|
||||
expect(status.reload.text).to eq content
|
||||
expect(status.spoiler_text).to_not eq ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue