|
196 | 196 | end |
197 | 197 | end |
198 | 198 | end |
| 199 | + |
| 200 | + describe "#add_another_answer_forms" do |
| 201 | + let!(:add_another_answer_draft_form) { create(:form, state: "draft", pages: draft_form_pages) } |
| 202 | + let(:draft_form_pages) { pages_with_add_another_answer } |
| 203 | + let!(:add_another_answer_live_form) { create(:form, state: "live", pages: live_form_pages) } |
| 204 | + let(:live_form_pages) do |
| 205 | + [ |
| 206 | + (build :page, answer_type: "name", is_repeatable: true), |
| 207 | + (build :page, answer_type: "text", is_repeatable: true), |
| 208 | + ] |
| 209 | + end |
| 210 | + |
| 211 | + it "obtains all forms in the add another answer report" do |
| 212 | + report = features_report_service.add_another_answer_forms |
| 213 | + |
| 214 | + expect(report[:forms]).to contain_exactly({ |
| 215 | + form_id: add_another_answer_draft_form.id, |
| 216 | + name: add_another_answer_draft_form.name, |
| 217 | + state: add_another_answer_draft_form.state, |
| 218 | + repeatable_pages: contain_exactly({ page_id: draft_form_pages.first.id, question_text: draft_form_pages.first.question_text }), |
| 219 | + }, { |
| 220 | + form_id: add_another_answer_live_form.id, |
| 221 | + name: add_another_answer_live_form.name, |
| 222 | + state: add_another_answer_live_form.state, |
| 223 | + repeatable_pages: contain_exactly( |
| 224 | + { page_id: live_form_pages.first.id, question_text: live_form_pages.first.question_text }, |
| 225 | + { page_id: live_form_pages.second.id, question_text: live_form_pages.second.question_text }, |
| 226 | + ), |
| 227 | + }) |
| 228 | + end |
| 229 | + |
| 230 | + it "returns the count" do |
| 231 | + report = features_report_service.add_another_answer_forms |
| 232 | + expect(report[:count]).to eq 2 |
| 233 | + end |
| 234 | + end |
199 | 235 | end |
0 commit comments