Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions reporting-app/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ RSpec/NoExpectationExample:
- assert_
- is_expected_in_block

RSpecRails/HaveHttpStatus:
Enabled: true
RSpecRails/HttpStatusNameConsistency:
Enabled: true
RSpecRails/InferredSpecType:
Enabled: false
RSpecRails/NegationBeValid:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
2 changes: 1 addition & 1 deletion reporting-app/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,9 @@ DEPENDENCIES
rspec-rails (~> 8.0.0)
rubocop-rails-omakase
rubocop-rspec
rubocop-rspec_rails
ruby-lsp
ruby-lsp-rails
rubocop-rspec_rails
selenium-webdriver
simplecov
sprockets-rails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create
else
message = "Failed to upload file: #{@batch_upload.errors.full_messages.join(', ')}"
format.html { redirect_to new_certification_batch_upload_path, alert: message }
format.json { render json: { error: message }, status: :unprocessable_entity }
format.json { render json: { error: message }, status: :unprocessable_content }
end
end
end
Expand Down Expand Up @@ -74,7 +74,7 @@ def process_batch
if @batch_upload.processable? == false
message = "This batch cannot be processed. Current status: #{@batch_upload.status}."
format.html { redirect_to certification_batch_upload_path(@batch_upload), alert: message }
format.json { render json: { error: message }, status: :unprocessable_entity }
format.json { render json: { error: message }, status: :unprocessable_content }
elsif ProcessCertificationBatchUploadJob.perform_later(@batch_upload.id)
format.html { redirect_to certification_batch_uploads_path, notice: "Processing started for #{@batch_upload.filename}. Results will be available shortly." }
format.json { head :accepted }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@
expect(flash[:alert]).to eq("Failed to upload file: Filename can't be blank, File must be attached")
end

it "returns unprocessable_entity status for JSON requests" do
it "returns unprocessable_content status for JSON requests" do
post :create, params: { csv_file: csv_file, locale: "en", format: :json }

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unprocessable_content)
end

it "returns error message in JSON for JSON requests" do
Expand Down Expand Up @@ -363,7 +363,7 @@
it "returns unprocessable entity status" do
post :process_batch, params: { id: batch_upload.id, locale: "en", format: :json }

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unprocessable_content)
end

it "returns error message in JSON" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles auth provider errors" do
Expand All @@ -44,7 +44,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles submission by bots" do
Expand All @@ -53,7 +53,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end
end

Expand Down Expand Up @@ -91,7 +91,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles auth provider errors" do
Expand All @@ -104,7 +104,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles submission by bots" do
Expand All @@ -118,7 +118,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles auth provider errors" do
Expand All @@ -57,7 +57,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles submission by bots" do
Expand All @@ -73,7 +73,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end
end

Expand Down Expand Up @@ -107,7 +107,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end

it "handles auth provider errors" do
Expand All @@ -119,7 +119,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
expect(response.body).to have_selector("h1", text: /sign in/i)
expect(response.body).to have_selector(".usa-alert--error")
end
Expand Down Expand Up @@ -108,7 +108,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
end
end

Expand Down Expand Up @@ -141,7 +141,7 @@
locale: "en"
}

expect(response.status).to eq(422)
expect(response).to have_http_status(:unprocessable_content)
expect(response.body).to have_selector(".usa-alert--error")
end

Expand Down
6 changes: 3 additions & 3 deletions reporting-app/spec/forms/users/verify_account_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
it "requires email and code" do
form = described_class.new(email: nil, code: nil)

expect(form).to be_invalid
expect(form).not_to be_valid
expect(form.errors).to be_of_kind(:email, :blank)
expect(form.errors).to be_of_kind(:code, :blank)
end

it "requires email to be a valid email" do
form = described_class.new(email: "invalid-email", code: "123456")

expect(form).to be_invalid
expect(form).not_to be_valid
expect(form.errors).to be_of_kind(:email, :invalid)
end

it "requires code to be 6 characters" do
form = described_class.new(email: "[email protected]", code: "12345")

expect(form).to be_invalid
expect(form).not_to be_valid
expect(form.errors).to be_of_kind(:code, :wrong_length)
end
end