|
21 | 21 | stub_request(:post, "#{test_site}/v1/bulk/gigs")
|
22 | 22 | .to_return(body: File.read('./spec/fixtures/gig_with_filter_and_gig_tasks.json'), headers: { 'Content-Type' => 'application/json' })
|
23 | 23 |
|
24 |
| - created_gig = gig.bulk_create_with(gig_tasks: [gig_task1, gig_task2], worker_invitation_filter: worker_invitation_filter) |
| 24 | + created_gig = gig.bulk_create_with(worker_invitation_filter, [gig_task1, gig_task2]) |
25 | 25 |
|
26 | 26 | expect(created_gig).to be_valid
|
27 |
| - expect(created_gig.id).to eq('12') |
28 |
| - expect(created_gig.worker_invitation_filter.id).to eq('13') |
29 |
| - expect(created_gig.gig_tasks.map(&:id)).to eq(%w[18 19]) |
| 27 | + expect(created_gig.id).to eq('15') |
| 28 | + expect(created_gig.worker_invitation_filter.id).to eq('20') |
| 29 | + expect(created_gig.gig_tasks.map(&:id)).to eq(%w[24 25]) |
30 | 30 | end
|
31 | 31 | end
|
| 32 | + |
| 33 | + # rubocop:disable RSpec/MultipleMemoizedHelpers |
| 34 | + describe 'bulk_archive_with' do |
| 35 | + before do |
| 36 | + configure_api_client |
| 37 | + end |
| 38 | + |
| 39 | + let(:gig_task) { CirroIO::Client::GigTask.new(id: 14) } |
| 40 | + |
| 41 | + let(:gig) do |
| 42 | + described_class.new(id: 10, gig_tasks: [gig_task]) |
| 43 | + end |
| 44 | + |
| 45 | + let(:app_worker1) { CirroIO::Client::AppWorker.new(id: 8) } |
| 46 | + let(:app_worker2) { CirroIO::Client::AppWorker.new(id: 9) } |
| 47 | + |
| 48 | + let(:gig_results) do |
| 49 | + [CirroIO::Client::GigResult.new(app_worker: app_worker1, |
| 50 | + gig_task: gig_task, |
| 51 | + title: Faker::Hipster.sentence, |
| 52 | + description: Faker::Hipster.paragraph, |
| 53 | + quantity: 2), |
| 54 | + CirroIO::Client::GigResult.new(app_worker: app_worker2, |
| 55 | + gig_task: gig_task, |
| 56 | + title: Faker::Hipster.sentence, |
| 57 | + description: Faker::Hipster.paragraph, |
| 58 | + quantity: 4)] |
| 59 | + end |
| 60 | + |
| 61 | + let(:gig_time_activities) do |
| 62 | + [CirroIO::Client::GigTimeActivity.new(app_worker: app_worker1, |
| 63 | + description: Faker::Hipster.paragraph, |
| 64 | + date: Time.current, |
| 65 | + duration_in_ms: 66000), |
| 66 | + CirroIO::Client::GigTimeActivity.new(app_worker: app_worker2, |
| 67 | + description: Faker::Hipster.paragraph, |
| 68 | + date: Time.current, |
| 69 | + duration_in_ms: 56000)] |
| 70 | + end |
| 71 | + |
| 72 | + it 'archives a gig with gig results and gig time activites' do |
| 73 | + stub_request(:post, "#{test_site}/v1/bulk/gigs/10/archive") |
| 74 | + .to_return(body: File.read('./spec/fixtures/archived_gig_with_gig_results_and_gig_time_activities.json'), |
| 75 | + headers: { 'Content-Type' => 'application/json' }) |
| 76 | + |
| 77 | + archived_gig = gig.bulk_archive_with(gig_results, gig_time_activities) |
| 78 | + |
| 79 | + expect(archived_gig).to be_valid |
| 80 | + expect(archived_gig.id).to eq('10') |
| 81 | + expect(archived_gig.archive_at).to eq('2020-11-30T10:30:56.000Z') |
| 82 | + expect(archived_gig.gig_results.map(&:id)).to eq(%w[1 2]) |
| 83 | + expect(archived_gig.gig_time_activities.map(&:id)).to eq(%w[1 2]) |
| 84 | + end |
| 85 | + end |
| 86 | + # rubocop:enable RSpec/MultipleMemoizedHelpers |
32 | 87 | end
|
0 commit comments