Browse Source

CLDC-2505 Bulk upload email link journey (#1825)

* CLDC-2505: "complete" tag added and implemented to bulk upload status

* CLDC-2505: complete option added to choice

* CLDC-2505: lettings changes made to sales

* CLDC-2505: tests added, bulk_upload model changed, redirect changed

* CLDC-2505: Content update

* CLDC-2505: Tests fixed and moved to correct controller spec

* CLDC-2505: linting

* CLDC-2505: test linting fix

* CLDC-2505: Content fix

* Update content

---------

Co-authored-by: Kat <katrina@kosiak.co.uk>
pull/1944/head
Aaron Spencer 1 year ago committed by GitHub
parent
commit
47dc8279c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/models/bulk_upload.rb
  2. 2
      app/models/forms/bulk_upload_lettings_resume/chosen.rb
  3. 2
      app/models/forms/bulk_upload_sales_resume/chosen.rb
  4. 14
      app/views/bulk_upload_lettings_resume/completed.html.erb
  5. 4
      app/views/bulk_upload_lettings_soft_validations_check/chosen.html.erb
  6. 14
      app/views/bulk_upload_sales_resume/completed.html.erb
  7. 4
      app/views/bulk_upload_sales_soft_validations_check/chosen.html.erb
  8. 21
      spec/models/bulk_upload_spec.rb
  9. 17
      spec/requests/bulk_upload_lettings_resume_controller_spec.rb
  10. 33
      spec/requests/bulk_upload_sales_resume_controller_spec.rb

5
app/models/bulk_upload.rb

@ -10,6 +10,11 @@ class BulkUpload < ApplicationRecord
after_initialize :generate_identifier, unless: :identifier
def completed?
incomplete_logs = logs.where.not(status: "completed")
!incomplete_logs.exists?
end
def year_combo
"#{year}/#{year - 2000 + 1}"
end

2
app/models/forms/bulk_upload_lettings_resume/chosen.rb

@ -8,7 +8,7 @@ module Forms
attribute :bulk_upload
def view_path
"bulk_upload_lettings_resume/chosen"
bulk_upload.completed? ? "bulk_upload_lettings_resume/completed" : "bulk_upload_lettings_resume/chosen"
end
def back_path

2
app/models/forms/bulk_upload_sales_resume/chosen.rb

@ -8,7 +8,7 @@ module Forms
attribute :bulk_upload
def view_path
"bulk_upload_sales_resume/chosen"
bulk_upload.completed? ? "bulk_upload_sales_resume/completed" : "bulk_upload_sales_resume/chosen"
end
def back_path

14
app/views/bulk_upload_lettings_resume/completed.html.erb

@ -0,0 +1,14 @@
<% content_for :before_content do %>
<%= govuk_back_link href: @form.back_path %>
<% end %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">These logs are complete</h1>
<p class="govuk-body">You have created logs from your bulk upload, and the logs are complete. Return to lettings logs to view them.</p>
<%= govuk_button_link_to "Return to lettings logs", lettings_logs_path %>
</div>
</div>

4
app/views/bulk_upload_lettings_soft_validations_check/chosen.html.erb

@ -5,9 +5,9 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">These logs have been created</h1>
<h1 class="govuk-heading-l">These logs are complete</h1>
<p class="govuk-body">You have created logs from your bulk upload. Return to lettings logs to view them.</p>
<p class="govuk-body">You have created logs from your bulk upload, and the logs are complete. Return to lettings logs to view them.</p>
<%= govuk_button_link_to "Return to lettings logs", lettings_logs_path %>
</div>

14
app/views/bulk_upload_sales_resume/completed.html.erb

@ -0,0 +1,14 @@
<% content_for :before_content do %>
<%= govuk_back_link href: @form.back_path %>
<% end %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">These logs are complete</h1>
<p class="govuk-body">You have created logs from your bulk upload, and the logs are complete. Return to sales logs to view them.</p>
<%= govuk_button_link_to "Return to sales logs", sales_logs_path %>
</div>
</div>

4
app/views/bulk_upload_sales_soft_validations_check/chosen.html.erb

@ -5,9 +5,9 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">These logs have been created</h1>
<h1 class="govuk-heading-l">These logs are complete</h1>
<p class="govuk-body">You have created logs from your bulk upload. Return to sales logs to view them.</p>
<p class="govuk-body">You have created logs from your bulk upload, and the logs are complete. Return to sales logs to view them.</p>
<%= govuk_button_link_to "Return to sales logs", sales_logs_path %>
</div>

21
spec/models/bulk_upload_spec.rb

@ -0,0 +1,21 @@
require "rails_helper"
RSpec.describe BulkUpload, type: :model do
let(:bulk_upload) { create(:bulk_upload, log_type: "lettings") }
describe "def bulk_upload.completed?" do
context "when there are incomplete logs" do
it "returns false" do
create_list(:lettings_log, 2, :in_progress, bulk_upload:)
expect(bulk_upload.completed?).to equal(false)
end
end
context "when there are no incomplete logs" do
it "returns true" do
create_list(:lettings_log, 2, :completed, bulk_upload:)
expect(bulk_upload.completed?).to equal(true)
end
end
end
end

17
spec/requests/bulk_upload_lettings_resume_controller_spec.rb

@ -10,6 +10,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do
end
describe "GET /lettings-logs/bulk-upload-resume/:ID/start" do
context "when a choice has not been made" do
it "redirects to choice page" do
get "/lettings-logs/bulk-upload-resume/#{bulk_upload.id}/start"
@ -17,6 +18,22 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do
end
end
context "when a choice has been made and then the logs have been completed" do
let(:lettings_log) { create_list(:lettings_log, 2, :completed, bulk_upload:) }
it "redirects to the complete page if the bulk uploads are completed" do
bulk_upload.update!(choice: "create-fix-inline")
get "/lettings-logs/bulk-upload-resume/#{bulk_upload.id}/start"
follow_redirect!
expect(response).to redirect_to("/lettings-logs/bulk-upload-resume/#{bulk_upload.id}/chosen")
follow_redirect!
expect(response.body).to include("You have created logs from your bulk upload, and the logs are complete. Return to lettings logs to view them.")
end
end
end
describe "GET /lettings-logs/bulk-upload-resume/:ID/fix-choice" do
it "renders the page correctly" do
get "/lettings-logs/bulk-upload-resume/#{bulk_upload.id}/fix-choice"

33
spec/requests/bulk_upload_sales_resume_controller_spec.rb

@ -9,14 +9,6 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do
sign_in user
end
describe "GET /sales-logs/bulk-upload-resume/:ID/start" do
it "redirects to choice page" do
get "/sales-logs/bulk-upload-resume/#{bulk_upload.id}/start"
expect(response).to redirect_to("/sales-logs/bulk-upload-resume/#{bulk_upload.id}/fix-choice")
end
end
describe "GET /sales-logs/bulk-upload-resume/:ID/fix-choice" do
it "renders the page correctly" do
get "/sales-logs/bulk-upload-resume/#{bulk_upload.id}/fix-choice"
@ -142,11 +134,28 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do
end
end
describe "GET /sales-logs/bulk-upload-resume/:ID/chosen" do
it "displays correct content" do
get "/sales-logs/bulk-upload-resume/#{bulk_upload.id}/chosen"
describe "GET /sales-logs/bulk-upload-resume/:ID/start" do
context "when a choice has not been made" do
it "redirects to choice page" do
get "/sales-logs/bulk-upload-resume/#{bulk_upload.id}/start"
expect(response.body).to include("You need to fix logs from your bulk upload")
expect(response).to redirect_to("/sales-logs/bulk-upload-resume/#{bulk_upload.id}/fix-choice")
end
end
context "when a choice has been made and then the logs have been completed" do
let(:sales_log) { create_list(:sales_log, 2, :completed, bulk_upload:) }
it "redirects to the complete page if the bulk uploads are completed" do
bulk_upload.update!(choice: "create-fix-inline")
get "/sales-logs/bulk-upload-resume/#{bulk_upload.id}/start"
follow_redirect!
expect(response).to redirect_to("/sales-logs/bulk-upload-resume/#{bulk_upload.id}/chosen")
follow_redirect!
expect(response.body).to include("You have created logs from your bulk upload, and the logs are complete. Return to sales logs to view them.")
end
end
end
end

Loading…
Cancel
Save