mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Inspecting 1484 files
.............................................................................................................................................................................................................................................................................................................C.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C....................C.....................................................................................................................................................................................................................................................................C.........................................................................................................................................................................................................C...........................................................................................................................................................
Offenses:
app/models/product_import/product_importer.rb:290:35: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
return unless @file.path == Rails.root.join('tmp', 'product_import').to_s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:5: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH)}/translations.js"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:5: C: [Correctable] Style/RedundantInterpolation: Prefer to_s over string interpolation.
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, 'translations.js')}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:59: C: [Corrected] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
"#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, "translations.js")}"
^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:25: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
config.fixture_path = "#{::Rails.root}/spec/fixtures"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:25: C: [Correctable] Style/RedundantInterpolation: Prefer to_s over string interpolation.
config.fixture_path = "#{Rails.root.join('spec/fixtures')}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:44: C: [Corrected] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
config.fixture_path = "#{Rails.root.join("spec/fixtures")}"
^^^^^^^^^^^^^^^
spec/models/content_configuration_spec.rb:15:19: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').to_s.
File.exist?(File.join(Rails.root, 'public', default_url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/content_configuration_spec.rb:15:19: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
File.exist?(Rails.root.join('public', default_url).to_s)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/downloads_helper.rb:7:5: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
Rails.root.join("tmp", "capybara")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1484 files inspected, 10 offenses detected, 8 offenses corrected, 2 more offenses can be corrected with `rubocop -A`
45 lines
844 B
Ruby
45 lines
844 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DownloadsHelper
|
|
TIMEOUT = 10
|
|
|
|
def self.path
|
|
Rails.root.join("tmp/capybara")
|
|
end
|
|
|
|
def downloaded_filename
|
|
wait_for_download
|
|
expect(downloaded_filenames.length).to eq(1) # downloads folder should contain 1 file
|
|
downloaded_filenames.first
|
|
end
|
|
|
|
def downloaded_content
|
|
wait_for_download
|
|
File.read(downloaded_filename)
|
|
end
|
|
|
|
private
|
|
|
|
def downloaded_filenames
|
|
Dir[DownloadsHelper.path.join("*")].select { |f| File.file?(f) }
|
|
end
|
|
|
|
def wait_for_download
|
|
Timeout.timeout(TIMEOUT) do
|
|
sleep 0.1 until downloaded?
|
|
end
|
|
end
|
|
|
|
def downloaded?
|
|
!downloading? && downloaded_filenames.any?
|
|
end
|
|
|
|
def downloading?
|
|
downloaded_filenames.grep(/\.crdownload$/).any?
|
|
end
|
|
|
|
def remove_downloaded_files
|
|
FileUtils.rm_f(downloaded_filenames)
|
|
end
|
|
end
|