Skip to content

Commit f567014

Browse files
committed
rubocop autocorrect
1 parent 411a287 commit f567014

16 files changed

+45
-47
lines changed

Gemfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ gem "redis", ">= 4.0.1"
3939
# gem "bcrypt", "~> 3.1.7"
4040

4141
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
42-
gem "tzinfo-data", platforms: %i[ windows jruby ]
42+
gem "tzinfo-data", platforms: %i[windows jruby]
4343

4444
# Reduces boot times through caching; required in config/boot.rb
4545
gem "bootsnap", require: false
@@ -50,10 +50,9 @@ gem "bootsnap", require: false
5050
gem "simple_form", "~> 5.3"
5151
gem "devise", "~> 4.9"
5252

53-
5453
group :development, :test do
5554
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
56-
gem "debug", platforms: %i[ mri windows ]
55+
gem "debug", platforms: %i[mri windows]
5756
gem "dotenv", "~> 3.1"
5857

5958
gem "rubocop"

app/controllers/line_item_dates_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def update
3636
end
3737

3838
def destroy
39-
@line_item_date.destroy
39+
@line_item_date.destroy
4040

41-
respond_to do |format|
42-
notice = "Date was successfully destroyed."
43-
format.html { redirect_to quote_path(@quote), notice: }
44-
format.turbo_stream { flash.now[:notice] = notice }
41+
respond_to do |format|
42+
notice = "Date was successfully destroyed."
43+
format.html { redirect_to quote_path(@quote), notice: }
44+
format.turbo_stream { flash.now[:notice] = notice }
45+
end
4546
end
46-
end
4747

4848
private
4949

app/controllers/line_items_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def update
3939
def destroy
4040
@line_item.destroy
4141

42-
respond_to do |format|
43-
notice = "Date was successfully destroyed."
44-
format.html { redirect_to quote_path(@quote), notice: }
45-
format.turbo_stream { flash.now[:notice] = notice }
46-
end
42+
respond_to do |format|
43+
notice = "Date was successfully destroyed."
44+
format.html { redirect_to quote_path(@quote), notice: }
45+
format.turbo_stream { flash.now[:notice] = notice }
46+
end
4747
end
4848

4949
private

app/controllers/quotes_controller.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ def create
1919
@quote = current_company.quotes.build(quote_params)
2020

2121
if @quote.save
22-
respond_to do |format|
23-
notice = "Quote was successfully created."
24-
format.html { redirect_to quotes_path, notice: }
25-
format.turbo_stream { flash.now[:notice] = notice }
22+
respond_to do |format|
23+
notice = "Quote was successfully created."
24+
format.html { redirect_to quotes_path, notice: }
25+
format.turbo_stream { flash.now[:notice] = notice }
26+
end
27+
else
28+
render :new, status: :unprocessable_entity
2629
end
27-
else
28-
render :new, status: :unprocessable_entity
29-
end
3030
end
3131

3232
def edit

app/models/line_item.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ class LineItem < ApplicationRecord
22
belongs_to :line_item_date
33

44
validates :name, presence: true
5-
validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 }
6-
validates :unit_price, presence: true, numericality: { greater_than: 0 }
5+
validates :quantity, presence: true, numericality: {only_integer: true, greater_than: 0}
6+
validates :unit_price, presence: true, numericality: {greater_than: 0}
77

88
delegate :quote, to: :line_item_date
99

app/models/line_item_date.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class LineItemDate < ApplicationRecord
22
belongs_to :quote
3-
has_many :line_items, dependent: :destroy #, strict_loading: true
3+
has_many :line_items, dependent: :destroy # TODO:, strict_loading: true
44

5-
validates :date, presence: true, uniqueness: { scope: :quote_id }
5+
validates :date, presence: true, uniqueness: {scope: :quote_id}
66

77
scope :ordered, -> { order(date: :asc) }
88

99
def previous_date
10-
quote.line_item_dates.ordered.where("date < ?", date).last
10+
quote.line_item_dates.ordered.where(date: ...date).last
1111
end
1212
end

app/models/quote.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Quote < ApplicationRecord
22
belongs_to :company
3-
has_many :line_item_dates, dependent: :destroy #, strict_loading: true
3+
has_many :line_item_dates, dependent: :destroy # TODO, strict_loading: true
44
has_many :line_items, through: :line_item_dates
55

66
validates :name, presence: true

config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Application < Rails::Application
1414
# Please, add to the `ignore` list any other `lib` subdirectories that do
1515
# not contain `.rb` files, or that should not be reloaded or eager loaded.
1616
# Common ones are `templates`, `generators`, or `middleware`, for example.
17-
config.autoload_lib(ignore: %w(assets tasks))
17+
config.autoload_lib(ignore: %w[assets tasks])
1818

1919
# Configuration for the application, engines, and railties goes here.
2020
#

config/environments/production.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
config.force_ssl = true
5353

5454
# Log to STDOUT by default
55-
config.logger = ActiveSupport::Logger.new(STDOUT)
56-
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
55+
config.logger = ActiveSupport::Logger.new($stdout)
56+
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
5757
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
5858

5959
# Prepend all log lines with the following tags.
60-
config.log_tags = [ :request_id ]
60+
config.log_tags = [:request_id]
6161

6262
# "info" includes generic and useful information about system operation, but avoids logging too much
6363
# information to avoid inadvertent exposure of personally identifiable information (PII). If you

config/initializers/devise.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# Configure the e-mail address which will be shown in Devise::Mailer,
2525
# note that it will be overwritten if you use your own mailer class
2626
# with default "from" parameter.
27-
config.mailer_sender = '[email protected]'
27+
config.mailer_sender = "[email protected]"
2828

2929
# Configure the class responsible to send e-mails.
3030
# config.mailer = 'Devise::Mailer'
@@ -36,7 +36,7 @@
3636
# Load and configure the ORM. Supports :active_record (default) and
3737
# :mongoid (bson_ext recommended) by default. Other ORMs may be
3838
# available as additional gems.
39-
require 'devise/orm/active_record'
39+
require "devise/orm/active_record"
4040

4141
# ==> Configuration for any authentication mechanism
4242
# Configure which keys are used when authenticating a user. The default is

config/initializers/simple_form.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
2-
#
2+
33
# Uncomment this and change the path if necessary to include your own
44
# components.
55
# See https://github.com/heartcombo/simple_form#custom-components to know
@@ -68,11 +68,11 @@
6868
# b.use :full_error, wrap_with: { tag: :span, class: :error }
6969
end
7070

71-
# Default configuration FROM TUTORIAL
71+
# Default configuration FROM TUTORIAL
7272
config.generate_additional_classes_for = []
7373
# config.default_wrapper = :default
7474
# config.button_class = "btn"
75-
config.label_text = lambda { |label, _, _| label }
75+
config.label_text = lambda { |label, _, _| label }
7676
# config.error_notification_tag = :div
7777
# config.error_notification_class = "error_notification"
7878

@@ -86,7 +86,7 @@
8686
config.boolean_style = :nested
8787

8888
# Default class for buttons
89-
config.button_class = 'btn'
89+
config.button_class = "btn"
9090

9191
# Method used to tidy up errors. Specify any Rails Array method.
9292
# :first lists the first message for each field.
@@ -97,7 +97,7 @@
9797
config.error_notification_tag = :div
9898

9999
# CSS class to add for error notification helper.
100-
config.error_notification_class = 'error_notification'
100+
config.error_notification_class = "error_notification"
101101

102102
# Series of attempts to detect a default label method for collection.
103103
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
@@ -173,7 +173,7 @@
173173
# config.input_class = nil
174174

175175
# Define the default class of the input wrapper of the boolean input.
176-
config.boolean_label_class = 'checkbox'
176+
config.boolean_label_class = "checkbox"
177177

178178
# Defines if the default input wrapper class should be included in radio
179179
# collection wrappers.

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
66
# Can be used by load balancers and uptime monitors to verify that the app is live.
7-
get "up" => "rails/health#show", as: :rails_health_check
7+
get "up" => "rails/health#show", :as => :rails_health_check
88

99
root to: "pages#home"
1010

db/seeds.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
# MovieGenre.find_or_create_by!(name: genre_name)
99
# end
1010

11-
puts "\n== Seeding the database with fixtures =="
11+
Rails.logger.debug "\n== Seeding the database with fixtures =="
1212
system("bin/rails db:fixtures:load")

test/controllers/quotes_controller_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class QuotesControllerTest < ActionDispatch::IntegrationTest
1818

1919
test "should create quote" do
2020
assert_difference("Quote.count") do
21-
post quotes_url, params: { quote: { name: 'test quote' } }
21+
post quotes_url, params: {quote: {name: "test quote"}}
2222
end
2323

2424
assert_redirected_to quotes_url
@@ -35,8 +35,7 @@ class QuotesControllerTest < ActionDispatch::IntegrationTest
3535
end
3636

3737
test "should update quote" do
38-
patch quote_url(@quote), params: { quote: { name: 'different name' } }
39-
# assert_redirected_to quote_url(@quote)
38+
patch quote_url(@quote), params: {quote: {name: "different name"}}
4039
assert_redirected_to quotes_url
4140
end
4241

test/system/line_item_dates_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class LineItemDatesTest < ApplicationSystemTestCase
66
setup do
77
login_as users(:accountant)
88

9-
@quote = quotes(:one)
9+
@quote = quotes(:one)
1010
@line_item_date = line_item_dates(:today)
1111

1212
visit quote_path(@quote)

test/system/line_items_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ class LineItemSystemTest < ApplicationSystemTestCase
66
setup do
77
login_as users(:accountant)
88

9-
@quote = quotes(:one)
9+
@quote = quotes(:one)
1010
@line_item_date = line_item_dates(:today)
11-
@line_item = line_items(:room_today)
11+
@line_item = line_items(:room_today)
1212

1313
visit quote_path(@quote)
1414
end

0 commit comments

Comments
 (0)