|
98 | 98 | end |
99 | 99 |
|
100 | 100 | context 'default community' do # rubocop:todo RSpec/ContextWording, RSpec/MultipleMemoizedHelpers |
| 101 | + let(:community) { ce_registry } |
101 | 102 | let(:user2) { create(:user) } |
102 | 103 |
|
103 | 104 | # rubocop:todo RSpec/NestedGroups |
|
131 | 132 | # rubocop:todo RSpec/NestedGroups |
132 | 133 | context 'new envelope' do # rubocop:todo RSpec/ContextWording, RSpec/NestedGroups |
133 | 134 | # rubocop:enable RSpec/NestedGroups |
134 | | - # rubocop:todo RSpec/ExampleLength |
| 135 | + # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations |
135 | 136 | it 'returns the newly created envelope with a 201 Created HTTP status code' do |
| 137 | + expect(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| # rubocop:todo RSpec/MessageSpies |
| 138 | + expect(envelope.envelope_community).to eq(community) |
| 139 | + expect(envelope.process_resource).to eq(JSON(resource_json)) |
| 140 | + end.exactly(:twice) |
| 141 | + |
| 142 | + expect(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| # rubocop:todo RSpec/MessageSpies |
| 143 | + expect(envelope.envelope_community).to eq(community) |
| 144 | + expect(envelope.process_resource).to eq(JSON(updated_resource_json)) |
| 145 | + end |
| 146 | + |
136 | 147 | # New envelope |
137 | 148 | travel_to now do |
138 | 149 | post "/resources/organizations/#{organization._ctid}/documents", |
|
199 | 210 | envelope |
200 | 211 | end |
201 | 212 |
|
202 | | - it 'updates the envelope' do # rubocop:todo RSpec/ExampleLength |
| 213 | + it 'updates the envelope' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations |
| 214 | + allow(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| |
| 215 | + expect(envelope.envelope_community).to eq(community) |
| 216 | + expect(envelope.process_resource).to eq(JSON(updated_resource_json)) |
| 217 | + end |
| 218 | + |
203 | 219 | travel_to now do |
204 | 220 | expect do |
205 | 221 | post "/resources/organizations/#{organization._ctid}/documents", |
|
233 | 249 | before do |
234 | 250 | create(:organization_publisher, organization: organization, publisher: user.publisher) |
235 | 251 |
|
| 252 | + allow(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| |
| 253 | + expect(envelope.envelope_community).to eq(community) # rubocop:todo RSpec/ExpectInHook |
| 254 | + expect(envelope.process_resource).to eq(JSON(resource_json)) # rubocop:todo RSpec/ExpectInHook |
| 255 | + end |
| 256 | + |
236 | 257 | travel_to now do |
237 | 258 | post "/resources/organizations/#{organization._ctid}/documents", |
238 | 259 | resource_json, |
|
282 | 303 | super_publisher_user = create(:user, publisher: super_publisher) |
283 | 304 | token = "Token #{super_publisher_user.auth_tokens.first.value}" |
284 | 305 |
|
| 306 | + allow(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| |
| 307 | + expect(envelope.envelope_community).to eq(community) # rubocop:todo RSpec/ExpectInHook |
| 308 | + expect(envelope.process_resource).to eq(JSON(resource_json)) # rubocop:todo RSpec/ExpectInHook |
| 309 | + end |
| 310 | + |
285 | 311 | travel_to now do |
286 | 312 | post "/resources/organizations/#{organization._ctid}/documents", |
287 | 313 | resource_json, 'Authorization' => token |
|
366 | 392 | publisher: user.publisher |
367 | 393 | ) |
368 | 394 |
|
| 395 | + allow(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| |
| 396 | + expect(envelope.envelope_community).to eq(community) # rubocop:todo RSpec/ExpectInHook |
| 397 | + expect(envelope.process_resource).to eq(JSON(resource_json)) # rubocop:todo RSpec/ExpectInHook |
| 398 | + end |
| 399 | + |
369 | 400 | travel_to now do |
370 | 401 | post "/resources/organizations/#{organization._ctid}/documents?" \ |
371 | 402 | "published_by=#{publishing_organization._ctid}", |
|
436 | 467 | end |
437 | 468 |
|
438 | 469 | it 'creates an envelope with provisional publication status' do |
| 470 | + allow(SyncEnvelopeGraphWithS3).to receive(:add) do |envelope| |
| 471 | + expect(envelope.envelope_community).to eq(community) |
| 472 | + expect(envelope.process_resource).to eq(JSON(resource_json)) |
| 473 | + end |
| 474 | + |
439 | 475 | expect do |
440 | 476 | post "/resources/organizations/#{organization._ctid}/documents", |
441 | 477 | resource_json, 'Authorization' => "Token #{user.auth_token.value}" |
|
518 | 554 | # rubocop:enable RSpec/NestedGroups |
519 | 555 | # rubocop:todo RSpec/MultipleExpectations |
520 | 556 | it 'deletes the envelope' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations |
| 557 | + allow(SyncEnvelopeGraphWithS3).to receive(:remove).with(envelope) |
| 558 | + |
521 | 559 | # rubocop:enable RSpec/MultipleExpectations |
522 | 560 | expect do |
523 | 561 | delete_envelope |
|
591 | 629 | # rubocop:enable RSpec/NestedGroups |
592 | 630 | # rubocop:todo RSpec/MultipleExpectations |
593 | 631 | it 'deletes the envelope' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations |
| 632 | + allow(SyncEnvelopeGraphWithS3).to receive(:remove).with(envelope) |
| 633 | + |
594 | 634 | # rubocop:enable RSpec/MultipleExpectations |
595 | 635 | expect do |
596 | 636 | delete_envelope |
|
0 commit comments