Add match_json_values
and use in AP worker specs (#30720)
This commit is contained in:
parent
53776cd58f
commit
84a31319e9
@ -6,3 +6,14 @@ RSpec::Matchers.define :match_json_schema do |schema|
|
|||||||
JSON::Validator.validate(schema_path, input_json, validate_schema: true)
|
JSON::Validator.validate(schema_path, input_json, validate_schema: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RSpec::Matchers.define :match_json_values do |values|
|
||||||
|
match do |string|
|
||||||
|
expect(json_str_to_hash(string))
|
||||||
|
.to include(values)
|
||||||
|
end
|
||||||
|
|
||||||
|
failure_message do |value|
|
||||||
|
"expected that #{value} would have the same values as #{values}."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -16,7 +16,7 @@ describe ActivityPub::DistributePollUpdateWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com']]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com']]) do
|
||||||
subject.perform(status.id)
|
subject.perform(status.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ describe ActivityPub::DistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
||||||
subject.perform(status.id)
|
subject.perform(status.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -31,7 +31,7 @@ describe ActivityPub::DistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
||||||
subject.perform(status.id)
|
subject.perform(status.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -46,7 +46,7 @@ describe ActivityPub::DistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to mentioned accounts' do
|
it 'delivers to mentioned accounts' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'https://foo.bar/inbox', anything]]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything]]) do
|
||||||
subject.perform(status.id)
|
subject.perform(status.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,12 +16,16 @@ describe ActivityPub::MoveDistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers and known blockers' do
|
it 'delivers to followers and known blockers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, expected_migration_deliveries) do
|
||||||
[kind_of(String), migration.account.id, 'http://example.com'],
|
|
||||||
[kind_of(String), migration.account.id, 'http://example2.com'],
|
|
||||||
]) do
|
|
||||||
subject.perform(migration.id)
|
subject.perform(migration.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expected_migration_deliveries
|
||||||
|
[
|
||||||
|
[match_json_values(type: 'Move'), migration.account.id, 'http://example.com'],
|
||||||
|
[match_json_values(type: 'Move'), migration.account.id, 'http://example2.com'],
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ describe ActivityPub::StatusUpdateDistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), status.account.id, 'http://example.com', anything]]) do
|
||||||
subject.perform(status.id)
|
subject.perform(status.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -37,7 +37,7 @@ describe ActivityPub::StatusUpdateDistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), status.account.id, 'http://example.com', anything]]) do
|
||||||
subject.perform(status.id)
|
subject.perform(status.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ describe ActivityPub::UpdateDistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com', anything]]) do
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com', anything]]) do
|
||||||
subject.perform(account.id)
|
subject.perform(account.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user