1
1
# frozen_string_literal: true
2
2
RSpec . describe "integration cases" do
3
- def read_json ( case_name , file_name )
4
- JSON . parse (
5
- File . open (
6
- File . join (
7
- File . expand_path ( "../.." , __dir__ ) ,
8
- "spec" ,
9
- "fixtures" ,
10
- "integration" ,
11
- case_name ,
12
- "#{ file_name } .json" ,
13
- ) ,
14
- ) . read ,
15
- ) . with_indifferent_access
16
- end
17
-
18
3
describe "#case 1" do
19
4
let! ( :actor ) { Fabricate ( :discourse_activity_pub_actor_group ) }
20
5
let! ( :remote_actor ) do
21
- json = read_json ( "case_1" , "group_actor" )
6
+ json = read_integration_json ( "case_1" , "group_actor" )
22
7
Fabricate ( :discourse_activity_pub_actor_group , ap_id : json [ :id ] , local : false )
23
8
end
24
9
let! ( :follow ) do
@@ -30,24 +15,24 @@ def read_json(case_name, file_name)
30
15
Jobs . run_immediately!
31
16
SiteSetting . activity_pub_require_signed_requests = false
32
17
33
- stub_object_request ( read_json ( "case_1" , "group_actor" ) )
34
- stub_object_request ( read_json ( "case_1" , "actor_1" ) )
35
- stub_object_request ( read_json ( "case_1" , "actor_2" ) )
36
- stub_object_request ( read_json ( "case_1" , "actor_3" ) )
37
- stub_object_request ( read_json ( "case_1" , "actor_4" ) )
38
- stub_object_request ( read_json ( "case_1" , "actor_5" ) )
39
- stub_object_request ( read_json ( "case_1" , "context_1" ) )
18
+ stub_object_request ( read_integration_json ( "case_1" , "group_actor" ) )
19
+ stub_object_request ( read_integration_json ( "case_1" , "actor_1" ) )
20
+ stub_object_request ( read_integration_json ( "case_1" , "actor_2" ) )
21
+ stub_object_request ( read_integration_json ( "case_1" , "actor_3" ) )
22
+ stub_object_request ( read_integration_json ( "case_1" , "actor_4" ) )
23
+ stub_object_request ( read_integration_json ( "case_1" , "actor_5" ) )
24
+ stub_object_request ( read_integration_json ( "case_1" , "context_1" ) )
40
25
41
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_1" ) )
42
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_2" ) )
43
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_3" ) )
44
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_4" ) )
45
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_5" ) )
46
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_6" ) )
47
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_7" ) )
48
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_8" ) )
49
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_9" ) )
50
- post_to_inbox ( actor , body : read_json ( "case_1" , "received_10" ) )
26
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_1" ) )
27
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_2" ) )
28
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_3" ) )
29
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_4" ) )
30
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_5" ) )
31
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_6" ) )
32
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_7" ) )
33
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_8" ) )
34
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_9" ) )
35
+ post_to_inbox ( actor , body : read_integration_json ( "case_1" , "received_10" ) )
51
36
end
52
37
53
38
it "creates the right Discourse objects" do
@@ -75,7 +60,7 @@ def read_json(case_name, file_name)
75
60
describe "#case 2" do
76
61
let! ( :actor ) { Fabricate ( :discourse_activity_pub_actor_group ) }
77
62
let! ( :remote_actor ) do
78
- json = read_json ( "case_2" , "group_actor" )
63
+ json = read_integration_json ( "case_2" , "group_actor" )
79
64
Fabricate ( :discourse_activity_pub_actor_group , ap_id : json [ :id ] , local : false )
80
65
end
81
66
let! ( :follow ) do
@@ -87,22 +72,15 @@ def read_json(case_name, file_name)
87
72
Jobs . run_immediately!
88
73
SiteSetting . activity_pub_require_signed_requests = false
89
74
90
- stub_object_request ( read_json ( "case_2" , "group_actor" ) )
91
- stub_object_request ( read_json ( "case_2" , "actor_1" ) )
92
- stub_object_request ( read_json ( "case_2" , "actor_2" ) )
93
- stub_object_request ( read_json ( "case_2" , "actor_3" ) )
94
- stub_object_request ( read_json ( "case_2" , "context_1" ) )
75
+ stub_object_request ( read_integration_json ( "case_2" , "group_actor" ) )
76
+ stub_object_request ( read_integration_json ( "case_2" , "actor_1" ) )
77
+ stub_object_request ( read_integration_json ( "case_2" , "actor_2" ) )
78
+ stub_object_request ( read_integration_json ( "case_2" , "actor_3" ) )
79
+ stub_object_request ( read_integration_json ( "case_2" , "context_1" ) )
95
80
96
- threads = [ ]
97
- results = [ ]
98
81
6 . times do |index |
99
- threads << Thread . new do
100
- post_to_inbox ( actor , body : read_json ( "case_2" , "received_#{ index + 1 } " ) )
101
- results << response
102
- sleep 0.01
103
- end
82
+ post_to_inbox ( actor , body : read_integration_json ( "case_2" , "received_#{ index + 1 } " ) )
104
83
end
105
- threads . each ( &:join )
106
84
end
107
85
108
86
it "creates the right Discourse objects" do
0 commit comments