4 changed files with 78 additions and 2 deletions
@ -0,0 +1,7 @@
|
||||
class BulkUploadSalesResultsController < ApplicationController |
||||
before_action :authenticate_user! |
||||
|
||||
def show |
||||
@bulk_upload = current_user.bulk_uploads.find(params[:id]) |
||||
end |
||||
end |
||||
@ -0,0 +1,20 @@
|
||||
<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">We found <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in your file</h1> |
||||
|
||||
<div class="govuk-body"> |
||||
Here’s a list of everything that you need to fix your spreadsheet. You can download the specification to help you fix the cells in your CSV file. |
||||
</div> |
||||
|
||||
<h2 class="govuk-heading-m"><%= @bulk_upload.filename %></h2> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-full"> |
||||
<% @bulk_upload.bulk_upload_errors.group_by(&:row).each do |_row, errors_for_row| %> |
||||
<%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row) %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,46 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe BulkUploadSalesResultsController, type: :request do |
||||
let(:user) { create(:user) } |
||||
let(:bulk_upload) { create(:bulk_upload, user:, bulk_upload_errors:) } |
||||
let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) } |
||||
|
||||
before do |
||||
sign_in user |
||||
end |
||||
|
||||
describe "GET /sales-logs/bulk-upload-results/:ID" do |
||||
it "renders correct year" do |
||||
get "/sales-logs/bulk-upload-results/#{bulk_upload.id}" |
||||
|
||||
expect(response).to be_successful |
||||
expect(response.body).to include("Bulk Upload for sales (2022/23)") |
||||
end |
||||
|
||||
it "renders correct number of errors" do |
||||
get "/sales-logs/bulk-upload-results/#{bulk_upload.id}" |
||||
|
||||
expect(response).to be_successful |
||||
expect(response.body).to include("We found 2 errors in your file") |
||||
end |
||||
|
||||
it "renders filename of the upload" do |
||||
get "/sales-logs/bulk-upload-results/#{bulk_upload.id}" |
||||
|
||||
expect(response).to be_successful |
||||
expect(response.body).to include(bulk_upload.filename) |
||||
end |
||||
|
||||
context "when there are errors for more than 1 row" do |
||||
let(:bulk_upload_errors) { [bulk_upload_error_1, bulk_upload_error_2] } |
||||
let(:bulk_upload_error_1) { create(:bulk_upload_error, row: 1) } |
||||
let(:bulk_upload_error_2) { create(:bulk_upload_error, row: 2) } |
||||
|
||||
it "renders no. of tables equal to no. of rows with errors" do |
||||
get "/sales-logs/bulk-upload-results/#{bulk_upload.id}" |
||||
|
||||
expect(response.body).to include("<table").twice |
||||
end |
||||
end |
||||
end |
||||
end |
||||
Loading…
Reference in new issue