|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | RSpec.describe Api::V1::ReportsController, type: :request do |
4 | | - describe "GET /features" do |
5 | | - let!(:form_with_repeatable_question) { create(:form, state: :live, pages: [repeatable_page]) } |
6 | | - let(:repeatable_page) { build(:page, answer_type: "text", is_repeatable: true) } |
7 | | - |
8 | | - before do |
9 | | - create :form, state: :live, payment_url: Faker::Internet.url(host: "gov.uk"), submission_type: "email_with_csv", pages: [ |
10 | | - (build :page, answer_type: "text"), |
11 | | - (build :page, answer_type: "text"), |
12 | | - ] |
13 | | - |
14 | | - create :form, state: :live, pages: [ |
15 | | - (build :page, answer_type: "name"), |
16 | | - (build :page, answer_type: "organisation_name"), |
17 | | - (build :page, answer_type: "phone_number"), |
18 | | - (build :page, answer_type: "email"), |
19 | | - (build :page, answer_type: "address"), |
20 | | - (build :page, answer_type: "national_insurance_number"), |
21 | | - (build :page, answer_type: "date"), |
22 | | - (build :page, answer_type: "number"), |
23 | | - (build :page, answer_type: "selection", routing_conditions: [(build :condition)]), |
24 | | - (build :page, answer_type: "text"), |
25 | | - ] |
26 | | - |
27 | | - get "/api/v1/reports/features" |
28 | | - end |
29 | | - |
30 | | - it "returns the breakdown of form features used" do |
31 | | - response_hash = JSON.parse(response.body, symbolize_names: true) |
32 | | - |
33 | | - expect(response_hash).to eq({ |
34 | | - total_live_forms: 3, |
35 | | - live_forms_with_answer_type: { |
36 | | - name: 1, |
37 | | - organisation_name: 1, |
38 | | - phone_number: 1, |
39 | | - email: 1, |
40 | | - address: 1, |
41 | | - national_insurance_number: 1, |
42 | | - date: 1, |
43 | | - number: 1, |
44 | | - selection: 1, |
45 | | - text: 3, |
46 | | - }, |
47 | | - live_pages_with_answer_type: { |
48 | | - name: 1, |
49 | | - organisation_name: 1, |
50 | | - phone_number: 1, |
51 | | - email: 1, |
52 | | - address: 1, |
53 | | - national_insurance_number: 1, |
54 | | - date: 1, |
55 | | - number: 1, |
56 | | - selection: 1, |
57 | | - text: 4, |
58 | | - }, |
59 | | - live_forms_with_payment: 1, |
60 | | - live_forms_with_routing: 1, |
61 | | - live_forms_with_add_another_answer: 1, |
62 | | - live_forms_with_csv_submission_enabled: 1, |
63 | | - all_forms_with_add_another_answer: [{ form_id: form_with_repeatable_question.id, name: form_with_repeatable_question.name, state: form_with_repeatable_question.state, repeatable_pages: [{ page_id: repeatable_page.id, question_text: repeatable_page.question_text }] }], |
64 | | - }) |
65 | | - end |
66 | | - |
67 | | - it "returns http success" do |
68 | | - expect(response).to have_http_status(:success) |
69 | | - end |
70 | | - end |
71 | | - |
72 | 4 | describe "GET /add-another-answer-forms" do |
73 | 5 | let!(:form_with_repeatable_question) { create(:form, state: :live, pages: [repeatable_page]) } |
74 | 6 | let(:repeatable_page) { build(:page, answer_type: "text", is_repeatable: true) } |
|
0 commit comments