|
20 | 20 | end |
21 | 21 | end |
22 | 22 |
|
23 | | - describe "GET :early_access_users" do |
24 | | - it "renders a successful JSON response" do |
25 | | - get admin_metrics_early_access_users_path |
26 | | - expect(response).to have_http_status(:ok) |
27 | | - expect(response.headers["Content-Type"]).to match("application/json") |
28 | | - expect(JSON.parse(response.body)).to eq([]) |
29 | | - end |
30 | | - |
31 | | - it "returns data of the combined current and deleted early access users by source and hour" do |
32 | | - create_list(:early_access_user, 5, created_at: 4.hours.ago, source: :admin_added) |
33 | | - create_list(:early_access_user, 2, created_at: 1.hour.ago, source: :admin_added) |
34 | | - create_list(:early_access_user, 3, created_at: 1.hour.ago, source: :instant_signup) |
35 | | - create_list(:deleted_early_access_user, 2, user_created_at: 1.hour.ago, user_source: :instant_signup) |
36 | | - create(:early_access_user, created_at: 25.hours.ago) |
37 | | - create(:deleted_early_access_user, user_created_at: 25.hours.ago) |
38 | | - |
39 | | - get admin_metrics_early_access_users_path |
40 | | - |
41 | | - expect(JSON.parse(response.body)).to contain_exactly( |
42 | | - { "name" => "admin_added", "data" => counts_for_last_24_hours(hours_ago_4: 5, hours_ago_1: 2) }, |
43 | | - { "name" => "instant_signup", "data" => counts_for_last_24_hours(hours_ago_1: 5) }, |
44 | | - ) |
45 | | - end |
46 | | - |
47 | | - context "when period is last_7_days" do |
48 | | - it "returns data of the combined current and deleted early access users by source and date" do |
49 | | - create_list(:early_access_user, 5, created_at: 4.days.ago, source: :admin_added) |
50 | | - create_list(:early_access_user, 2, created_at: 1.day.ago, source: :admin_added) |
51 | | - create_list(:early_access_user, 3, created_at: 1.day.ago, source: :instant_signup) |
52 | | - create_list(:deleted_early_access_user, 2, user_created_at: 1.day.ago, user_source: :instant_signup) |
53 | | - |
54 | | - get admin_metrics_early_access_users_path(period: "last_7_days") |
55 | | - |
56 | | - expect(JSON.parse(response.body)).to contain_exactly( |
57 | | - { "name" => "admin_added", "data" => counts_for_last_7_days(days_ago_4: 5, days_ago_1: 2) }, |
58 | | - { "name" => "instant_signup", "data" => counts_for_last_7_days(days_ago_1: 5) }, |
59 | | - ) |
60 | | - end |
61 | | - end |
62 | | - end |
63 | | - |
64 | | - describe "GET :waiting_list_users" do |
65 | | - it "renders a successful JSON response" do |
66 | | - get admin_metrics_waiting_list_users_path |
67 | | - expect(response).to have_http_status(:ok) |
68 | | - expect(response.headers["Content-Type"]).to match("application/json") |
69 | | - expect(JSON.parse(response.body)).to eq([]) |
70 | | - end |
71 | | - |
72 | | - it "returns data of the combined current and deleted waiting list users by source and hour" do |
73 | | - create_list(:waiting_list_user, 2, created_at: 5.hours.ago, source: :admin_added) |
74 | | - create(:deleted_waiting_list_user, user_created_at: 5.hours.ago, user_source: :admin_added) |
75 | | - create_list(:deleted_waiting_list_user, 4, user_source: :insufficient_instant_places) |
76 | | - create(:waiting_list_user, created_at: 25.hours.ago) |
77 | | - create(:deleted_waiting_list_user, user_created_at: 25.hours.ago) |
78 | | - |
79 | | - get admin_metrics_waiting_list_users_path |
80 | | - |
81 | | - expect(JSON.parse(response.body)).to contain_exactly( |
82 | | - { "name" => "admin_added", "data" => counts_for_last_24_hours(hours_ago_5: 3) }, |
83 | | - { "name" => "insufficient_instant_places", "data" => counts_for_last_24_hours(hours_ago_0: 4) }, |
84 | | - ) |
85 | | - end |
86 | | - |
87 | | - context "when period is last_7_days" do |
88 | | - it "returns data of the combined current and deleted waiting list users by source and date" do |
89 | | - create_list(:waiting_list_user, 2, created_at: 5.days.ago, source: :admin_added) |
90 | | - create(:deleted_waiting_list_user, user_created_at: 5.days.ago, user_source: :admin_added) |
91 | | - create_list(:deleted_waiting_list_user, 4, user_source: :insufficient_instant_places) |
92 | | - |
93 | | - get admin_metrics_waiting_list_users_path(period: "last_7_days") |
94 | | - |
95 | | - expect(JSON.parse(response.body)).to contain_exactly( |
96 | | - { "name" => "admin_added", "data" => counts_for_last_7_days(days_ago_5: 3) }, |
97 | | - { "name" => "insufficient_instant_places", "data" => counts_for_last_7_days(days_ago_0: 4) }, |
98 | | - ) |
99 | | - end |
100 | | - end |
101 | | - end |
102 | | - |
103 | 23 | describe "GET :conversations" do |
104 | 24 | it "renders a successful JSON response" do |
105 | 25 | get admin_metrics_conversations_path |
|
0 commit comments