mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Safely autocorrect Rails/RootPublicPath
Inspecting 1484 files
.............................................................................................C........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.........................................................................................C..........C..........................................................................................................................................................................................................................................................................................................C....................................................................................................................................................................C...................C.............................................................C.C.......C....................
Offenses:
app/controllers/concerns/request_timeouts.rb:19:22: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
file: Rails.root.join("public/500.html"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/spree/core/controller_helpers/common.rb:45:30: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
file: Rails.root.join("public/404.html"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/api/v0/product_images_controller_spec.rb:13:22: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:pdf_path) { Rails.root.join("public/Terms-of-service.pdf") }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/api/v0/terms_and_conditions_controller_spec.rb:15:31: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:terms_file_path) { Rails.root.join("public/Terms-of-service.pdf") }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/terms_of_service_file_spec.rb:6:25: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:pdf) { File.open(Rails.root.join("public/Terms-of-service.pdf")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_product_update_spec.rb:907:37: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
attach_file 'image-upload', Rails.root.join("public/500.jpg"), visible: false
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprises/terms_and_conditions_spec.rb:27:30: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:original_terms) { Rails.root.join("public/Terms-of-service.pdf") }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprises/terms_and_conditions_spec.rb:28:29: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:updated_terms) { Rails.root.join("public/Terms-of-ServiceUK.pdf") }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/checkout_spec.rb:94:9: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
Rails.root.join("public/Terms-of-service.pdf"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/embedded_groups_spec.rb:18:9: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
Rails.root.join("public/embedded-group-preview.html")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/embedded_groups_spec.rb:26:9: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
Rails.root.join("public/embedded-group-preview.html")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/split_checkout_spec.rb:986:35: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:system_terms_path) { Rails.root.join("public/Terms-of-service.pdf") }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/split_checkout_spec.rb:987:33: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
let(:shop_terms_path) { Rails.root.join("public/Terms-of-ServiceUK.pdf") }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1484 files inspected, 13 offenses detected, 13 offenses corrected
This commit is contained in:
@@ -684,21 +684,6 @@ Rails/RootPathnameMethods:
|
||||
- 'spec/models/terms_of_service_file_spec.rb'
|
||||
- 'spec/system/admin/configuration/terms_of_service_files_spec.rb'
|
||||
|
||||
# Offense count: 13
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/RootPublicPath:
|
||||
Exclude:
|
||||
- 'app/controllers/concerns/request_timeouts.rb'
|
||||
- 'lib/spree/core/controller_helpers/common.rb'
|
||||
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
|
||||
- 'spec/models/terms_of_service_file_spec.rb'
|
||||
- 'spec/system/admin/bulk_product_update_spec.rb'
|
||||
- 'spec/system/admin/enterprises/terms_and_conditions_spec.rb'
|
||||
- 'spec/system/consumer/shopping/checkout_spec.rb'
|
||||
- 'spec/system/consumer/shopping/embedded_groups_spec.rb'
|
||||
- 'spec/system/consumer/split_checkout_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: ForbiddenMethods, AllowedMethods.
|
||||
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
|
||||
|
||||
@@ -16,7 +16,7 @@ module RequestTimeouts
|
||||
respond_to do |type|
|
||||
type.html {
|
||||
render status: :gateway_timeout,
|
||||
file: Rails.root.join("public/500.html"),
|
||||
file: Rails.public_path.join('500.html'),
|
||||
formats: [:html],
|
||||
layout: nil
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ module Spree
|
||||
respond_to do |type|
|
||||
type.html {
|
||||
render status: :not_found,
|
||||
file: Rails.root.join("public/404.html"),
|
||||
file: Rails.public_path.join('404.html'),
|
||||
formats: [:html],
|
||||
layout: nil
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ describe Api::V0::ProductImagesController, type: :controller do
|
||||
describe "uploading an image" do
|
||||
let(:image) { Rack::Test::UploadedFile.new(black_logo_file, 'image/png') }
|
||||
let(:pdf) { Rack::Test::UploadedFile.new(pdf_path, 'application/pdf') }
|
||||
let(:pdf_path) { Rails.root.join("public/Terms-of-service.pdf") }
|
||||
let(:pdf_path) { Rails.public_path.join('Terms-of-service.pdf') }
|
||||
let(:product_without_image) { create(:product) }
|
||||
let(:product_with_image) { create(:product_with_image) }
|
||||
let(:current_api_user) { create(:admin_user) }
|
||||
|
||||
@@ -12,7 +12,7 @@ module Api
|
||||
let(:enterprise_manager) { create(:user, enterprises: [enterprise]) }
|
||||
|
||||
describe "removing terms and conditions file" do
|
||||
let(:terms_file_path) { Rails.root.join("public/Terms-of-service.pdf") }
|
||||
let(:terms_file_path) { Rails.public_path.join('Terms-of-service.pdf') }
|
||||
let(:terms_and_conditions_file) {
|
||||
Rack::Test::UploadedFile.new(terms_file_path, "application/pdf")
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe TermsOfServiceFile do
|
||||
let(:pdf) { File.open(Rails.root.join("public/Terms-of-service.pdf")) }
|
||||
let(:pdf) { File.open(Rails.public_path.join('Terms-of-service.pdf')) }
|
||||
let(:upload) { Rack::Test::UploadedFile.new(pdf, "application/pdf") }
|
||||
|
||||
describe ".current" do
|
||||
|
||||
@@ -904,7 +904,7 @@ describe '
|
||||
expect(page).to have_css "img.preview"
|
||||
|
||||
# Upload a new image file
|
||||
attach_file 'image-upload', Rails.root.join("public/500.jpg"), visible: false
|
||||
attach_file 'image-upload', Rails.public_path.join('500.jpg'), visible: false
|
||||
|
||||
# Shows spinner whilst loading
|
||||
expect(page).to have_css ".spinner"
|
||||
|
||||
@@ -24,8 +24,8 @@ describe "Uploading Terms and Conditions PDF" do
|
||||
end
|
||||
end
|
||||
|
||||
let(:original_terms) { Rails.root.join("public/Terms-of-service.pdf") }
|
||||
let(:updated_terms) { Rails.root.join("public/Terms-of-ServiceUK.pdf") }
|
||||
let(:original_terms) { Rails.public_path.join('Terms-of-service.pdf') }
|
||||
let(:updated_terms) { Rails.public_path.join('Terms-of-ServiceUK.pdf') }
|
||||
|
||||
it "uploading terms and conditions" do
|
||||
go_to_business_details
|
||||
|
||||
@@ -91,7 +91,7 @@ describe "As a consumer I want to check out my cart" do
|
||||
let(:user) { create(:user) }
|
||||
let(:pdf_upload) {
|
||||
Rack::Test::UploadedFile.new(
|
||||
Rails.root.join("public/Terms-of-service.pdf"),
|
||||
Rails.public_path.join('Terms-of-service.pdf'),
|
||||
"application/pdf"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "Using embedded shopfront functionality" do
|
||||
|
||||
FileUtils.copy(
|
||||
Rails.root.join("spec/fixtures/files/embedded-group-preview.html"),
|
||||
Rails.root.join("public/embedded-group-preview.html")
|
||||
Rails.public_path.join('embedded-group-preview.html')
|
||||
)
|
||||
|
||||
visit "/embedded-group-preview.html?#{group.permalink}"
|
||||
@@ -23,7 +23,7 @@ describe "Using embedded shopfront functionality" do
|
||||
|
||||
after do
|
||||
FileUtils.remove(
|
||||
Rails.root.join("public/embedded-group-preview.html")
|
||||
Rails.public_path.join('embedded-group-preview.html')
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -993,8 +993,8 @@ describe "As a consumer, I want to checkout my order" do
|
||||
describe "terms and conditions" do
|
||||
let(:customer) { create(:customer, enterprise: order.distributor, user: user) }
|
||||
let(:tos_url) { "https://example.org/tos" }
|
||||
let(:system_terms_path) { Rails.root.join("public/Terms-of-service.pdf") }
|
||||
let(:shop_terms_path) { Rails.root.join("public/Terms-of-ServiceUK.pdf") }
|
||||
let(:system_terms_path) { Rails.public_path.join('Terms-of-service.pdf') }
|
||||
let(:shop_terms_path) { Rails.public_path.join('Terms-of-ServiceUK.pdf') }
|
||||
let(:system_terms) {
|
||||
Rack::Test::UploadedFile.new(system_terms_path, "application/pdf")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user