1
0
Fork 0
forked from gitea/nas

Fix filter test code better

This commit is contained in:
KMY 2023-08-11 13:25:15 +09:00
parent 3c0bc6cb57
commit 389a0bd123
2 changed files with 9 additions and 8 deletions

View file

@ -35,20 +35,23 @@ describe Api::V1::Timelines::PublicController do
context 'with filter' do context 'with filter' do
subject do subject do
Fabricate(:follow, account: account, target_account: remote_account)
get :show get :show
body_as_json.filter { |status| status[:filtered].empty? || status[:filtered][0][:filter][:id] != filter.id.to_s }.map { |status| status[:id].to_i } body_as_json.filter { |status| status[:filtered].empty? || status[:filtered][0][:filter][:id] != filter.id.to_s }.map { |status| status[:id].to_i }
end end
before do
Fabricate(:custom_filter_keyword, custom_filter: filter, keyword: 'ohagi')
Fabricate(:follow, account: account, target_account: remote_account)
end
let(:exclude_follows) { false } let(:exclude_follows) { false }
let(:exclude_localusers) { false } let(:exclude_localusers) { false }
let!(:filter) { Fabricate(:custom_filter, account: account, exclude_follows: exclude_follows, exclude_localusers: exclude_localusers) } let!(:filter) { Fabricate(:custom_filter, account: account, exclude_follows: exclude_follows, exclude_localusers: exclude_localusers) }
let!(:filter_keyword) { Fabricate(:custom_filter_keyword, custom_filter: filter, keyword: 'ohagi') } # rubocop:disable RSpec/LetSetup
it 'load statuses', :aggregate_failures do it 'load statuses', :aggregate_failures do
ids = subject ids = subject
expect(ids).to exclude(local_status.id) expect(ids).to_not include(local_status.id)
expect(ids).to exclude(remote_status.id) expect(ids).to_not include(remote_status.id)
end end
context 'when exclude_followers' do context 'when exclude_followers' do
@ -56,7 +59,7 @@ describe Api::V1::Timelines::PublicController do
it 'load statuses', :aggregate_failures do it 'load statuses', :aggregate_failures do
ids = subject ids = subject
expect(ids).to exclude(local_status.id) expect(ids).to_not include(local_status.id)
expect(ids).to include(remote_status.id) expect(ids).to include(remote_status.id)
end end
end end
@ -67,7 +70,7 @@ describe Api::V1::Timelines::PublicController do
it 'load statuses', :aggregate_failures do it 'load statuses', :aggregate_failures do
ids = subject ids = subject
expect(ids).to include(local_status.id) expect(ids).to include(local_status.id)
expect(ids).to exclude(remote_status.id) expect(ids).to_not include(remote_status.id)
end end
end end
end end

View file

@ -2,8 +2,6 @@
require 'rspec/retry' require 'rspec/retry'
RSpec::Matchers.define_negated_matcher :exclude, :include
if ENV['DISABLE_SIMPLECOV'] != 'true' if ENV['DISABLE_SIMPLECOV'] != 'true'
require 'simplecov' require 'simplecov'
SimpleCov.start 'rails' do SimpleCov.start 'rails' do