-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvaccinations_search_in_nhs_spec.rb
More file actions
43 lines (36 loc) · 1.29 KB
/
vaccinations_search_in_nhs_spec.rb
File metadata and controls
43 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true
describe "/api/testing/vaccinations-search-in-nhs" do
before { Flipper.enable(:testing_api) }
describe "POST" do
before { allow(EnqueueVaccinationsSearchInNHSJob).to receive(:perform_now) }
it "runs the enqueue job synchronously and responds with accepted" do
post "/api/testing/vaccinations-search-in-nhs"
expect(EnqueueVaccinationsSearchInNHSJob).to have_received(:perform_now)
expect(response).to have_http_status(:accepted)
end
end
describe "GET" do
context "when the search queue is empty" do
before do
allow(Sidekiq::Queue).to receive(:new).with(
"immunisations_api_search"
).and_return(instance_double(Sidekiq::Queue, size: 0))
end
it "responds with ok" do
get "/api/testing/vaccinations-search-in-nhs"
expect(response).to have_http_status(:ok)
end
end
context "when the search queue has pending jobs" do
before do
allow(Sidekiq::Queue).to receive(:new).with(
"immunisations_api_search"
).and_return(instance_double(Sidekiq::Queue, size: 3))
end
it "responds with accepted" do
get "/api/testing/vaccinations-search-in-nhs"
expect(response).to have_http_status(:accepted)
end
end
end
end