* Wip * Wip * Wip: History * Wip: テストコード作成 * Fix test * Wip * Wip * Wip * Fix test * Wip * Wip * Wip * Wip * なんとか完成、これから動作確認 * spell miss * Change ng rule timings * Fix test * Wip * Fix test * Wip * Fix form * 表示まわりの改善
This commit is contained in:
parent
0779c748a6
commit
7d96d5828e
56 changed files with 2062 additions and 42 deletions
|
@ -111,6 +111,38 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is existing' do
|
||||
context 'when ng rule is match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'example.com', reaction_type: ['reblog'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let(:object_json) do
|
||||
ActivityPub::TagManager.instance.uri_for(status)
|
||||
end
|
||||
|
||||
it 'does not create a reblog by sender of status' do
|
||||
expect(sender.reblogged?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is not match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'foo.bar', reaction_type: ['reblog'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let(:object_json) do
|
||||
ActivityPub::TagManager.instance.uri_for(status)
|
||||
end
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
expect(sender.reblogged?(status)).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the sender is relayed' do
|
||||
subject { described_class.new(json, sender, relayed_through_actor: relay_account) }
|
||||
|
||||
|
|
|
@ -1560,6 +1560,32 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
expect(vote.uri).to eq object_json[:id]
|
||||
expect(poll.reload.cached_tallies).to eq [1, 0]
|
||||
end
|
||||
|
||||
context 'when ng rule is existing' do
|
||||
let(:custom_before) { true }
|
||||
|
||||
context 'when ng rule is match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'example.com', reaction_type: ['vote'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a reblog by sender of status' do
|
||||
expect(poll.votes.first).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is not match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'foo.bar', reaction_type: ['vote'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
expect(poll.votes.first).to_not be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a vote to an expired local poll' do
|
||||
|
@ -2024,6 +2050,43 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is set' do
|
||||
let(:custom_before) { true }
|
||||
let(:content) { 'Lorem ipsum' }
|
||||
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
|
||||
|
||||
context 'when rule hits' do
|
||||
before do
|
||||
Fabricate(:ng_rule, status_text: 'ipsum', status_allow_follower_mention: false)
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
expect(status).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when rule does not hit' do
|
||||
before do
|
||||
Fabricate(:ng_rule, status_text: 'amely', status_allow_follower_mention: false)
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
expect(status).to_not be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when hashtags limit is set' do
|
||||
let(:post_hash_tags_max) { 2 }
|
||||
let(:custom_before) { true }
|
||||
|
|
|
@ -244,6 +244,33 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
expect(sender.requested?(recipient)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is existing' do
|
||||
context 'when ng rule is match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'example.com', reaction_type: ['follow'])
|
||||
stub_request(:post, 'https://example.com/inbox').to_return(status: 200, body: '', headers: {})
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a reblog by sender of status' do
|
||||
expect(sender.following?(recipient)).to be false
|
||||
expect(sender.requested?(recipient)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is not match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'foo.bar', reaction_type: ['follow'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
expect(sender.following?(recipient)).to be true
|
||||
expect(sender.requested?(recipient)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a follow relationship already exists' do
|
||||
|
|
|
@ -55,6 +55,32 @@ RSpec.describe ActivityPub::Activity::Like do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is existing' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
context 'when ng rule is match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'example.com', reaction_type: ['favourite'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a reblog by sender of status' do
|
||||
expect(sender.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is not match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'foo.bar', reaction_type: ['favourite'])
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
expect(sender.favourited?(status)).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform when receive emoji reaction' do
|
||||
subject do
|
||||
described_class.new(json, sender).perform
|
||||
|
@ -592,6 +618,30 @@ RSpec.describe ActivityPub::Activity::Like do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is existing' do
|
||||
let(:content) { '😀' }
|
||||
|
||||
context 'when ng rule is match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'example.com', reaction_type: ['emoji_reaction'])
|
||||
end
|
||||
|
||||
it 'does not create a reblog by sender of status' do
|
||||
expect(subject.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ng rule is not match' do
|
||||
before do
|
||||
Fabricate(:ng_rule, account_domain: 'foo.bar', reaction_type: ['emoji_reaction'])
|
||||
end
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
expect(subject.count).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform when rejecting favourite domain block' do
|
||||
|
|
24
spec/lib/vacuum/ng_histories_vacuum_spec.rb
Normal file
24
spec/lib/vacuum/ng_histories_vacuum_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Vacuum::NgHistoriesVacuum do
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#perform' do
|
||||
let!(:rule_history_old) { Fabricate(:ng_rule_history, created_at: 30.days.ago) }
|
||||
let!(:rule_history_recent) { Fabricate(:ng_rule_history, created_at: 2.days.ago) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'deletes old history' do
|
||||
expect { rule_history_old.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
it 'does not delete recent history' do
|
||||
expect { rule_history_recent.reload }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue