Skip to content

Commit

Permalink
Add latest rubocop tests and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Aug 1, 2022
1 parent ee5812d commit ca63e41
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
34 changes: 32 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ Metrics/PerceivedComplexity:
Style/SlicingWithRange:
Enabled: false

Gemspec/DateAssignment: # (new in 1.10)
Enabled: true
Layout/SpaceBeforeBrackets: # (new in 1.7)
Enabled: true
Lint/AmbiguousAssignment: # (new in 1.7)
Expand Down Expand Up @@ -279,3 +277,35 @@ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
Enabled: true
RSpec/Rails/AvoidSetupHook: # new in 2.4
Enabled: true
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
Enabled: true
Layout/LineContinuationLeadingSpace: # new in 1.31
Enabled: true
Layout/LineContinuationSpacing: # new in 1.31
Enabled: true
Lint/ConstantOverwrittenInRescue: # new in 1.31
Enabled: true
Lint/NonAtomicFileOperation: # new in 1.31
Enabled: true
Lint/RequireRangeParentheses: # new in 1.32
Enabled: true
Style/EmptyHeredoc: # new in 1.32
Enabled: true
Style/EnvHome: # new in 1.29
Enabled: true
Style/MapCompactWithConditionalBlock: # new in 1.30
Enabled: true
Rails/DotSeparatedKeys: # new in 2.15
Enabled: true
Rails/RootPublicPath: # new in 2.15
Enabled: true
Rails/StripHeredoc: # new in 2.15
Enabled: true
Rails/ToFormattedS: # new in 2.15
Enabled: true
RSpec/ChangeByZero: # new in 2.11.0
Enabled: true
RSpec/Capybara/SpecificMatcher: # new in 2.12
Enabled: true
RSpec/Rails/HaveHttpStatus: # new in 2.12
Enabled: true
4 changes: 2 additions & 2 deletions app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def can_run

render json: {
stream: "internalerr",
text: "You currently can't start a scraper run." \
" See https://morph.io for more details"
text: "You currently can't start a scraper run. " \
"See https://morph.io for more details"
}
end

Expand Down
8 changes: 4 additions & 4 deletions app/lib/morph/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def self.backup_mysql
FileUtils.rm_f "db/backups/mysql_backup.sql.bz2"
FileUtils.mkdir_p "db/backups"
Rails.logger.info "Backing up MySQL..."
system "mysqldump #{mysql_auth} #{mysql_database}" \
" > db/backups/mysql_backup.sql"
system "mysqldump #{mysql_auth} #{mysql_database} " \
"> db/backups/mysql_backup.sql"
Rails.logger.info "Compressing MySQL backup..."
system "bzip2 db/backups/mysql_backup.sql"
end
Expand All @@ -43,8 +43,8 @@ def self.restore_mysql
Rails.logger.info "Uncompressing MySQL backup..."
system "bunzip2 -k db/backups/mysql_backup.sql.bz2"
Rails.logger.info "Restoring from MySQL backup..."
system "mysql #{mysql_auth} #{mysql_database}" \
" < db/backups/mysql_backup.sql"
system "mysql #{mysql_auth} #{mysql_database} " \
"< db/backups/mysql_backup.sql"
FileUtils.rm_f "db/backups/mysql_backup.sql"
end

Expand Down
2 changes: 1 addition & 1 deletion app/lib/morph/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def sqlite_total_rows
end

def clear
FileUtils.rm sqlite_db_path if File.exist?(sqlite_db_path)
FileUtils.rm_f sqlite_db_path
end

def write_sqlite_database(content)
Expand Down
8 changes: 4 additions & 4 deletions lib/tasks/app.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace :app do
end
end

desc "Run scrapers that need to run once per day" \
" (this task should be called from a cron job)"
desc "Run scrapers that need to run once per day " \
"(this task should be called from a cron job)"
task auto_run_scrapers: :environment do
# All the scrapers that need running in a random order
scraper_ids = Scraper.where(auto_run: true).map(&:id).shuffle
Expand Down Expand Up @@ -96,8 +96,8 @@ namespace :app do

desc "Restore databases from db/backups"
task restore: :environment do
if confirm "Are you sure?" \
" This will overwrite the databases and Redis needs to be shutdown."
if confirm "Are you sure? " \
"This will overwrite the databases and Redis needs to be shutdown."
Morph::Backup.restore
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/api_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
parsed = response.body.split("\n").map { |l| JSON.parse(l) }
expect(parsed).to eq [{
"stream" => "internalerr",
"text" => "You currently can't start a scraper run." \
" See https://morph.io for more details"
"text" => "You currently can't start a scraper run. " \
"See https://morph.io for more details"
}]
end

Expand Down
9 changes: 0 additions & 9 deletions spec/lib/morph/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
end
end

describe "#clear" do
it "does not attempt to remove the file if it's not there" do
expect(FileUtils).not_to receive(:rm)
VCR.use_cassette("scraper_validations", allow_playback_repeats: true) do
described_class.new(create(:scraper).data_path).clear
end
end
end

describe "#backup" do
it "backups the database file" do
# Create a fake database file
Expand Down
2 changes: 1 addition & 1 deletion spec/models/scraper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
scraper = create(:scraper)
expect do
scraper.deliver_webhooks(run)
end.to change(DeliverWebhookWorker.jobs, :size).by(0)
end.not_to change(DeliverWebhookWorker.jobs, :size)
end
end
end
Expand Down

0 comments on commit ca63e41

Please sign in to comment.