Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
taketo1113 committed Dec 10, 2024
1 parent fc7f587 commit deddb39
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ group :development, :test do
gem "rubocop-rails-omakase", require: false
end

#group :development do
# group :development do
# gem "capistrano-ext"
# gem "capistrano-rails"
# gem "capistrano-rbenv"
# gem "capistrano-bundler"
#end
# end

group :development do
# gem "web-console"
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class MessagesController < ApplicationController
before_action :set_message, only: [:show, :edit, :update]
before_action :set_message, only: [ :show, :edit, :update ]

# GET /messages/1
# GET /messages/1.json
Expand All @@ -15,7 +15,7 @@ def edit
def update
respond_to do |format|
if @message.update(message_params)
format.html { redirect_to @message, notice: 'Message was successfully updated.' }
format.html { redirect_to @message, notice: "Message was successfully updated." }
format.json { render :show, status: :ok, location: @message }
else
format.html { render :edit, status: :unprocessable_entity }
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ApplicationHelper
def full_title(page_title = nil)
base_title = t('common.site_title')
base_title = t("common.site_title")

if page_title.blank?
base_title
Expand All @@ -20,23 +20,23 @@ def hbr(str)

def datetime_view(datetime)
return nil if datetime.blank?
datetime.strftime(t('time.formats.default'))
datetime.strftime(t("time.formats.default"))
end

def date_view(date)
return nil if date.blank?
date.strftime(t('date.formats.default'))
date.strftime(t("date.formats.default"))
end

# Public: Pick the correct arguments for form_for when shallow routes are used.
#
# parent - The Resource that has_* child
# child - The Resource that belongs_to parent.
def shallow_args(parent, child)
child.new_record? ? [parent, child] : child
child.new_record? ? [ parent, child ] : child
end

def shallow_deep_args(parent, child, grandchild)
grandchild.new_record? ? [parent, child, grandchild] : grandchild
grandchild.new_record? ? [ parent, child, grandchild ] : grandchild
end
end
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }

# Log to STDOUT by default
#config.logger = ActiveSupport::Logger.new(STDOUT)
# config.logger = ActiveSupport::Logger.new(STDOUT)
# .tap { |logger| logger.formatter = ::Logger::Formatter.new }
# .then { |logger| ActiveSupport::TaggedLogging.new(logger) }

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

resource "*",
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
methods: [ :get, :post, :put, :patch, :delete, :options, :head ]
end
end
2 changes: 1 addition & 1 deletion config/initializers/locale.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
Rails.application.config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
Rails.application.config.i18n.load_path += Dir[Rails.root.join("config", "locales", "*.{rb,yml}").to_s]
Rails.application.config.i18n.default_locale = :ja
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
root to: 'messages#show', id: '1'
root to: "messages#show", id: "1"

resources :messages, only: [ :show, :edit, :update ]

Expand Down
36 changes: 17 additions & 19 deletions spec/controllers/messages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.

RSpec.describe MessagesController, :type => :controller do

RSpec.describe MessagesController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# Message. As you add validations to Message, be sure to
# adjust the attributes here as well.
Expand Down Expand Up @@ -60,37 +59,36 @@

it "updates the requested message" do
message = Message.create! valid_attributes
process :update, method: :put, params: { id: message.to_param, :message => new_attributes }, session: valid_session
process :update, method: :put, params: { id: message.to_param, message: new_attributes }, session: valid_session
message.reload
expect(message.body).to eq new_attributes[:body]
end

it "assigns the requested message as @message" do
message = Message.create! valid_attributes
process :update, method: :put, params: { id: message.to_param, :message => valid_attributes }, session: valid_session
process :update, method: :put, params: { id: message.to_param, message: valid_attributes }, session: valid_session
expect(assigns(:message)).to eq(message)
end

it "redirects to the message" do
message = Message.create! valid_attributes
process :update, method: :put, params: { id: message.to_param, :message => valid_attributes }, session: valid_session
process :update, method: :put, params: { id: message.to_param, message: valid_attributes }, session: valid_session
expect(response).to redirect_to(message)
end
end

# describe "with invalid params" do
# it "assigns the message as @message" do
# message = Message.create! valid_attributes
# process :update, method: :put, params: { id: message.to_param, :message => invalid_attributes }, session: valid_session
# expect(assigns(:message)).to eq(message)
# end
#
# it "re-renders the 'edit' template" do
# message = Message.create! valid_attributes
# process :update, method: :put, params: { id: message.to_param, :message => invalid_attributes }, session: valid_session
# expect(response).to render_template("edit")
# end
# end
# describe "with invalid params" do
# it "assigns the message as @message" do
# message = Message.create! valid_attributes
# process :update, method: :put, params: { id: message.to_param, :message => invalid_attributes }, session: valid_session
# expect(assigns(:message)).to eq(message)
# end
#
# it "re-renders the 'edit' template" do
# message = Message.create! valid_attributes
# process :update, method: :put, params: { id: message.to_param, :message => invalid_attributes }, session: valid_session
# expect(response).to render_template("edit")
# end
# end
end

end
2 changes: 1 addition & 1 deletion spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# end
# end
# end
RSpec.describe ApplicationHelper, :type => :helper do
RSpec.describe ApplicationHelper, type: :helper do
describe "nl2br" do
it "replace line break to br tag" do
str = "hoge\nhoge"
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/messages_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe "Messages", :type => :request do
RSpec.describe "Messages", type: :request do
before(:each) do
@message = FactoryBot.create(:message)
end
Expand Down
19 changes: 9 additions & 10 deletions spec/routing/messages_routing_spec.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
require "rails_helper"

RSpec.describe MessagesController, :type => :routing do
RSpec.describe MessagesController, type: :routing do
describe "routing" do

it "routes to root" do
expect(:get => "/").to route_to("messages#show", id: "1")
expect(get: "/").to route_to("messages#show", id: "1")
end

it "routes to #show" do
expect(:get => "/messages/1").to route_to("messages#show", :id => "1")
expect(get: "/messages/1").to route_to("messages#show", id: "1")
end

it "routes to #edit" do
expect(:get => "/messages/1/edit").to route_to("messages#edit", :id => "1")
expect(get: "/messages/1/edit").to route_to("messages#edit", id: "1")
end

it "routes to #update" do
expect(:put => "/messages/1").to route_to("messages#update", :id => "1")
expect(put: "/messages/1").to route_to("messages#update", id: "1")
end

context "not exist" do
it "routes to #create" do
expect(:post => "/messages").not_to route_to("messages#create")
expect(post: "/messages").not_to route_to("messages#create")
end

it "routes to #index" do
expect(:get => "/messages").not_to route_to("messages#index")
expect(get: "/messages").not_to route_to("messages#index")
end

it "routes to #new" do
expect(:get => "/messages/new").not_to route_to("messages#new")
expect(get: "/messages/new").not_to route_to("messages#new")
end

it "routes to #destroy" do
expect(:delete => "/messages/1").not_to route_to("messages#destroy", :id => "1")
expect(delete: "/messages/1").not_to route_to("messages#destroy", id: "1")
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.

# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
Expand All @@ -57,7 +57,7 @@
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
# config.example_status_persistence_file_path = "spec/examples.txt"
# config.example_status_persistence_file_path = "spec/examples.txt"

# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
Expand All @@ -77,7 +77,7 @@
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
# config.profile_examples = 10
# config.profile_examples = 10

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
Expand Down
2 changes: 1 addition & 1 deletion spec/support/committee_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
schema_path: Rails.root.join('docs', 'api.yaml').to_s,
query_hash_key: 'rack.request.query_hash',
parse_response_by_content_type: false,
strict_reference_validation: false,
strict_reference_validation: false
}

include Committee::Rails::Test::Methods
Expand Down
5 changes: 2 additions & 3 deletions spec/views/messages/edit.html.slim_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
require 'rails_helper'

RSpec.describe "messages/edit", :type => :view do
RSpec.describe "messages/edit", type: :view do
before(:each) do
@message = assign(:message, Message.create!(
:body => "MyText"
body: "MyText"
))
end

it "renders the edit message form" do
render

assert_select "form[action=?][method=?]", message_path(@message), "post" do

assert_select "textarea#message_body[name=?]", "message[body]"
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/views/messages/show.html.slim_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'rails_helper'

RSpec.describe "messages/show", :type => :view do
RSpec.describe "messages/show", type: :view do
before(:each) do
@message = assign(:message, Message.create!(
:body => "MyText"
body: "MyText"
))
end

Expand Down

0 comments on commit deddb39

Please sign in to comment.