|
215 | 215 | end |
216 | 216 | end |
217 | 217 |
|
| 218 | + describe "#submit_without_confirm" do |
| 219 | + let(:form) do |
| 220 | + create :form, |
| 221 | + name_cy: "New Welsh name", |
| 222 | + what_happens_next_markdown: "English what happens next", |
| 223 | + what_happens_next_markdown_cy: "New Welsh what happens next", |
| 224 | + declaration_text: "English declaration", |
| 225 | + declaration_text_cy: "New Welsh declaration", |
| 226 | + support_email: "english-support@example.gov.uk", |
| 227 | + support_email_cy: "new-welsh-support@example.gov.uk", |
| 228 | + support_phone: "English support phone", |
| 229 | + support_phone_cy: "0800 123 4567", |
| 230 | + support_url: "https://www.gov.uk/english-support", |
| 231 | + support_url_cy: "https://www.gov.uk/new-welsh-support", |
| 232 | + support_url_text: "English support url text", |
| 233 | + support_url_text_cy: "New Welsh Support", |
| 234 | + privacy_policy_url: "https://www.gov.uk/english-privacy", |
| 235 | + privacy_policy_url_cy: "https://www.gov.uk/new-welsh-privacy", |
| 236 | + payment_url_cy: "https://www.gov.uk/payments/new-welsh-payment-link", |
| 237 | + available_languages: %w[en cy], |
| 238 | + welsh_completed: true, |
| 239 | + pages: [page] |
| 240 | + end |
| 241 | + |
| 242 | + let(:page) do |
| 243 | + create :page, |
| 244 | + question_text_cy: "Ydych chi'n adnewyddu trwydded?", |
| 245 | + hint_text: "English hint text", |
| 246 | + hint_text_cy: "Dewiswch 'Ydw' os oes gennych drwydded ddilys eisoes.", |
| 247 | + page_heading: "English page heading", |
| 248 | + page_heading_cy: "Trwyddedu", |
| 249 | + guidance_markdown: "English guidance", |
| 250 | + guidance_markdown_cy: "Mae'r rhan hon o'r ffurflen yn ymwneud â thrwyddedu.", |
| 251 | + answer_settings_cy: { |
| 252 | + selection_options: [ |
| 253 | + { name: "Welsh option 1", value: "Option 1" }, |
| 254 | + { name: "Welsh option 2", value: "Option 2" }, |
| 255 | + ], |
| 256 | + none_of_the_above_question: { |
| 257 | + question_text: "Welsh none of the above question?", |
| 258 | + }, |
| 259 | + } |
| 260 | + end |
| 261 | + |
| 262 | + let(:condition) do |
| 263 | + create :condition, |
| 264 | + routing_page: page, |
| 265 | + exit_page_markdown_cy: "Nid ydych yn gymwys", |
| 266 | + exit_page_heading_cy: "Mae'n ddrwg gennym, nid ydych yn gymwys ar gyfer y gwasanaeth hwn." |
| 267 | + end |
| 268 | + |
| 269 | + context "when called" do |
| 270 | + it "returns true" do |
| 271 | + expect(delete_welsh_translation_input.submit_without_confirm).to be true |
| 272 | + end |
| 273 | + |
| 274 | + it "deletes all of the welsh form content" do |
| 275 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { form.reload.what_happens_next_markdown_cy }.to(nil) |
| 276 | + .and change { form.reload.declaration_text_cy }.to(nil) |
| 277 | + .and change { form.reload.support_email_cy }.to(nil) |
| 278 | + .and change { form.reload.support_phone_cy }.to(nil) |
| 279 | + .and change { form.reload.support_url_cy }.to(nil) |
| 280 | + .and change { form.reload.support_url_text_cy }.to(nil) |
| 281 | + .and change { form.reload.privacy_policy_url_cy }.to(nil) |
| 282 | + .and change { form.reload.payment_url_cy }.to(nil) |
| 283 | + end |
| 284 | + |
| 285 | + it "deletes all of the welsh page content" do |
| 286 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { page.reload.question_text_cy }.to(nil) |
| 287 | + .and change { page.reload.hint_text_cy }.to(nil) |
| 288 | + .and change { page.reload.page_heading_cy }.to(nil) |
| 289 | + .and change { page.reload.guidance_markdown_cy }.to(nil) |
| 290 | + .and change { page.reload.answer_settings_cy }.to(nil) |
| 291 | + end |
| 292 | + |
| 293 | + it "deletes all of the welsh condition content" do |
| 294 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { condition.reload.exit_page_markdown_cy }.to(nil) |
| 295 | + .and change { condition.reload.exit_page_heading_cy }.to(nil) |
| 296 | + end |
| 297 | + |
| 298 | + it "resets the available_languages field to only include English" do |
| 299 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { form.reload.available_languages }.to(%w[en]) |
| 300 | + end |
| 301 | + |
| 302 | + it "resets the welsh_completed status" do |
| 303 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { form.reload.welsh_completed }.to(false) |
| 304 | + end |
| 305 | + |
| 306 | + context "when the form is live" do |
| 307 | + let(:form) do |
| 308 | + create :form, |
| 309 | + :live, |
| 310 | + name_cy: "New Welsh name", |
| 311 | + what_happens_next_markdown: "English what happens next", |
| 312 | + what_happens_next_markdown_cy: "New Welsh what happens next", |
| 313 | + declaration_text: "English declaration", |
| 314 | + declaration_text_cy: "New Welsh declaration", |
| 315 | + support_email: "english-support@example.gov.uk", |
| 316 | + support_email_cy: "new-welsh-support@example.gov.uk", |
| 317 | + support_phone: "English support phone", |
| 318 | + support_phone_cy: "0800 123 4567", |
| 319 | + support_url: "https://www.gov.uk/english-support", |
| 320 | + support_url_cy: "https://www.gov.uk/new-welsh-support", |
| 321 | + support_url_text: "English support url text", |
| 322 | + support_url_text_cy: "New Welsh Support", |
| 323 | + privacy_policy_url: "https://www.gov.uk/english-privacy", |
| 324 | + privacy_policy_url_cy: "https://www.gov.uk/new-welsh-privacy", |
| 325 | + payment_url_cy: "https://www.gov.uk/payments/new-welsh-payment-link", |
| 326 | + available_languages: %w[en cy], |
| 327 | + welsh_completed: true, |
| 328 | + pages: [page] |
| 329 | + end |
| 330 | + |
| 331 | + it "sets the form_status to `live_with_draft`" do |
| 332 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { form.reload.state }.to("live_with_draft") |
| 333 | + end |
| 334 | + end |
| 335 | + |
| 336 | + context "when the form is archived" do |
| 337 | + let(:form) do |
| 338 | + create :form, |
| 339 | + :archived, |
| 340 | + name_cy: "New Welsh name", |
| 341 | + what_happens_next_markdown: "English what happens next", |
| 342 | + what_happens_next_markdown_cy: "New Welsh what happens next", |
| 343 | + declaration_text: "English declaration", |
| 344 | + declaration_text_cy: "New Welsh declaration", |
| 345 | + support_email: "english-support@example.gov.uk", |
| 346 | + support_email_cy: "new-welsh-support@example.gov.uk", |
| 347 | + support_phone: "English support phone", |
| 348 | + support_phone_cy: "0800 123 4567", |
| 349 | + support_url: "https://www.gov.uk/english-support", |
| 350 | + support_url_cy: "https://www.gov.uk/new-welsh-support", |
| 351 | + support_url_text: "English support url text", |
| 352 | + support_url_text_cy: "New Welsh Support", |
| 353 | + privacy_policy_url: "https://www.gov.uk/english-privacy", |
| 354 | + privacy_policy_url_cy: "https://www.gov.uk/new-welsh-privacy", |
| 355 | + payment_url_cy: "https://www.gov.uk/payments/new-welsh-payment-link", |
| 356 | + available_languages: %w[en cy], |
| 357 | + welsh_completed: true, |
| 358 | + pages: [page] |
| 359 | + end |
| 360 | + |
| 361 | + it "sets the form_status to `archived_with_draft`" do |
| 362 | + expect { delete_welsh_translation_input.submit_without_confirm }.to change { form.reload.state }.to("archived_with_draft") |
| 363 | + end |
| 364 | + end |
| 365 | + end |
| 366 | + end |
| 367 | + |
218 | 368 | describe "#confirmed?" do |
219 | 369 | context "when the input is invalid" do |
220 | 370 | it "returns false" do |
|
0 commit comments