style: standardize quotation marks and spacing
- Updated single quotes to double quotes for consistency - Adjusted spacing in array definitions for better readability - Ensured consistent use of quotes in flash messages and method parameters These changes enhance the overall code style without altering any functionality.
This commit is contained in:
parent
5ff05c3dc4
commit
712cd10894
2
Gemfile
2
Gemfile
@ -17,7 +17,7 @@ gem "stimulus-rails"
|
||||
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
||||
gem "jbuilder"
|
||||
|
||||
gem 'bcrypt', '~> 3.1'
|
||||
gem "bcrypt", "~> 3.1"
|
||||
|
||||
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
||||
# gem "bcrypt", "~> 3.1.7"
|
||||
|
10
Guardfile
10
Guardfile
@ -22,7 +22,7 @@ guard :minitest, spring: "bin/rails test", all_on_start: false do
|
||||
watch('config/routes.rb') { interface_tests }
|
||||
watch(%r{app/views/layouts/*}) { interface_tests }
|
||||
watch(%r{âpp/models/(.*?)\.rb$}) do |matches|
|
||||
["test/models/#{matches[1]}_test.rb", "test/integration/microposts_interface_test.rb"]
|
||||
[ "test/models/#{matches[1]}_test.rb", "test/integration/microposts_interface_test.rb" ]
|
||||
end
|
||||
watch(%r{^test/fixtures/(.*?)\.yml$}) do |matches|
|
||||
"test/models/#{matches[1].singularize}_test.rb"
|
||||
@ -37,7 +37,7 @@ guard :minitest, spring: "bin/rails test", all_on_start: false do
|
||||
resource_tests(matches[1])
|
||||
end
|
||||
watch(%r{âpp/views/([^/]*?)/.*\.html\.erb$}) do |matches|
|
||||
["test/controllers/#{matches[1]}_controller_test.rb"] + integration_tests(matches[1])
|
||||
[ "test/controllers/#{matches[1]}_controller_test.rb" ] + integration_tests(matches[1])
|
||||
end
|
||||
watch(%r{âpp/helpers/(.*?)_helper\.rb$}) do |matches| integration_tests(matches[1])
|
||||
end
|
||||
@ -45,11 +45,11 @@ guard :minitest, spring: "bin/rails test", all_on_start: false do
|
||||
end
|
||||
watch('app/helpers/sessions_helper.rb') do integration_tests << 'test/helpers/sessions_helper_test.rb'
|
||||
end
|
||||
watch('app/controllers/sessions_controller.rb') do ['test/controllers/sessions_controller_test.rb', 'test/integration/users_login_test.rb']
|
||||
watch('app/controllers/sessions_controller.rb') do [ 'test/controllers/sessions_controller_test.rb', 'test/integration/users_login_test.rb' ]
|
||||
end
|
||||
watch('app/controllers/account_activations_controller.rb') do 'test/integration/users_signup_test.rb'
|
||||
end
|
||||
watch(%r{app/views/users/*}) do resource_tests('users') + ['test/integration/microposts_interface_test.rb']
|
||||
watch(%r{app/views/users/*}) do resource_tests('users') + [ 'test/integration/microposts_interface_test.rb' ]
|
||||
end
|
||||
end # Returns the integration tests corresponding to the given resource.
|
||||
|
||||
@ -70,4 +70,4 @@ def
|
||||
end # Returns all tests for the given resource.
|
||||
def
|
||||
resource_tests(resource) integration_tests(resource) << controller_test(resource)
|
||||
end
|
||||
end
|
||||
|
@ -9,12 +9,12 @@ class SessionsController < ApplicationController
|
||||
if user&.authenticate(params[:session][:password])
|
||||
forwarding_url = session[:forwarding_url]
|
||||
reset_session
|
||||
params[:session][:remember_me] == '1' ? remember(user) : forget(user)
|
||||
params[:session][:remember_me] == "1" ? remember(user) : forget(user)
|
||||
log_in user
|
||||
redirect_to forwarding_url || user
|
||||
else
|
||||
flash.now[:danger] = 'Invalid email/password combination'
|
||||
render 'new'
|
||||
flash.now[:danger] = "Invalid email/password combination"
|
||||
render "new"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
class UsersController < ApplicationController
|
||||
include SessionsHelper
|
||||
before_action :logged_in_user, only: [:edit, :update]
|
||||
before_action :correct_user, only: [:edit, :update]
|
||||
before_action :logged_in_user, only: [ :edit, :update ]
|
||||
before_action :correct_user, only: [ :edit, :update ]
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
# debugger
|
||||
@ -20,7 +20,7 @@ class UsersController < ApplicationController
|
||||
redirect_to @user
|
||||
# redirect_to user_url(@user)
|
||||
else
|
||||
render 'new'
|
||||
render "new"
|
||||
end
|
||||
end
|
||||
|
||||
@ -35,7 +35,7 @@ class UsersController < ApplicationController
|
||||
redirect_to @user
|
||||
# redirect_to user_url(@user)
|
||||
else
|
||||
render 'edit'
|
||||
render "edit"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
module ApplicationHelper
|
||||
def full_title(page_title = '')
|
||||
def full_title(page_title = "")
|
||||
base_title = "Ruby on Rails Tutorial Sample App"
|
||||
if page_title.empty?
|
||||
base_title
|
||||
|
@ -8,4 +8,4 @@ Rails.application.config.assets.version = "1.0"
|
||||
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap/dist/js")
|
||||
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font")
|
||||
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap/dist/js")
|
||||
Rails.application.config.assets.precompile << "bootstrap.min.js"
|
||||
Rails.application.config.assets.precompile << "bootstrap.min.js"
|
||||
|
@ -8,14 +8,14 @@ Rails.application.routes.draw do
|
||||
|
||||
root "static_pages#home"
|
||||
|
||||
get '/help', to: 'static_pages#help'
|
||||
get '/about', to: 'static_pages#about'
|
||||
get '/contact', to: 'static_pages#contact'
|
||||
get '/signup', to: 'users#new'
|
||||
get "/help", to: "static_pages#help"
|
||||
get "/about", to: "static_pages#about"
|
||||
get "/contact", to: "static_pages#contact"
|
||||
get "/signup", to: "users#new"
|
||||
|
||||
get '/login', to: 'sessions#new'
|
||||
post '/login', to: 'sessions#create'
|
||||
delete '/logout', to: 'sessions#destroy'
|
||||
get "/login", to: "sessions#new"
|
||||
post "/login", to: "sessions#create"
|
||||
delete "/logout", to: "sessions#destroy"
|
||||
|
||||
resources :users
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
require "test_helper"
|
||||
|
||||
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
def setup
|
||||
@base_title = "Ruby on Rails Tutorial Sample App"
|
||||
end
|
||||
@ -30,4 +29,3 @@ class StaticPagesControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_select "title", full_title("Contact")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class ApplicationHelperTest < ActionView::TestCase
|
||||
test "full title helper" do
|
||||
assert_equal full_title, "Ruby on Rails Tutorial Sample App"
|
||||
assert_equal full_title("Contact"), "Contact | Ruby on Rails Tutorial Sample App"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,6 @@
|
||||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class SessionsHelperTest < ActionView::TestCase
|
||||
|
||||
def setup
|
||||
@user = users(:michael)
|
||||
remember(@user)
|
||||
@ -16,4 +15,4 @@ class SessionsHelperTest < ActionView::TestCase
|
||||
@user.update_attribute(:remember_digest, User.digest(User.new_token))
|
||||
assert_nil current_user
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ class SiteLayoutTest < ActionDispatch::IntegrationTest
|
||||
# end
|
||||
test "layout links" do
|
||||
get root_path
|
||||
assert_template 'static_pages/home'
|
||||
assert_template "static_pages/home"
|
||||
assert_select "a[href=?]", root_url, count: 2
|
||||
assert_select "a[href=?]", about_url
|
||||
assert_select "a[href=?]", help_url
|
||||
|
@ -19,7 +19,7 @@ class UsersEditTest < ActionDispatch::IntegrationTest
|
||||
get edit_user_path(@user)
|
||||
log_in_as(@user)
|
||||
assert_redirected_to edit_user_url(@user)
|
||||
assert_template 'users/edit'
|
||||
assert_template "users/edit"
|
||||
name = "Foo Bae"
|
||||
email = "foo@bar.com"
|
||||
patch user_path(@user), params: { user: { name: name,
|
||||
@ -36,13 +36,13 @@ class UsersEditTest < ActionDispatch::IntegrationTest
|
||||
test "unsuccessful edit" do
|
||||
log_in_as(@user)
|
||||
get edit_user_path(@user)
|
||||
assert_template 'users/edit'
|
||||
assert_template "users/edit"
|
||||
patch user_path(@user), params: { user: { name: "",
|
||||
email: "foo@invalid",
|
||||
password: "foo",
|
||||
password_confirmation: "bar"
|
||||
} }
|
||||
assert_template 'users/edit'
|
||||
assert_template "users/edit"
|
||||
end
|
||||
|
||||
test "should redirect edit when not logged in" do
|
||||
|
@ -7,11 +7,11 @@ class UsersLoginTest < ActionDispatch::IntegrationTest
|
||||
|
||||
test "login with valid email/invalid password" do
|
||||
get login_path
|
||||
assert_template 'sessions/new'
|
||||
assert_template "sessions/new"
|
||||
post login_path, params: { session: { email: @user.email,
|
||||
password: "invalid" } }
|
||||
assert_not is_logged_in?
|
||||
assert_template 'sessions/new'
|
||||
assert_template "sessions/new"
|
||||
assert_not flash.empty?
|
||||
get root_path
|
||||
assert flash.empty?
|
||||
@ -19,10 +19,10 @@ class UsersLoginTest < ActionDispatch::IntegrationTest
|
||||
|
||||
test "login with invalid information" do
|
||||
get login_path
|
||||
assert_template 'sessions/new'
|
||||
assert_template "sessions/new"
|
||||
post login_path, params: { session: {
|
||||
email: "", password: "" } }
|
||||
assert_template 'sessions/new'
|
||||
assert_template "sessions/new"
|
||||
assert_not flash.empty?
|
||||
get root_path
|
||||
assert flash.empty?
|
||||
@ -32,11 +32,11 @@ class UsersLoginTest < ActionDispatch::IntegrationTest
|
||||
get login_path
|
||||
post login_path, params: { session: { email:
|
||||
@user.email,
|
||||
password: 'password' } }
|
||||
password: "password" } }
|
||||
assert is_logged_in?
|
||||
assert_redirected_to @user
|
||||
follow_redirect!
|
||||
assert_template 'users/show'
|
||||
assert_template "users/show"
|
||||
assert_select "a[href=?]", login_path, count: 0
|
||||
assert_select "a[href=?]", logout_path
|
||||
assert_select "a[href=?]", user_path(@user)
|
||||
@ -52,13 +52,13 @@ class UsersLoginTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "login with remembering" do
|
||||
log_in_as(@user, remember_me: '1')
|
||||
log_in_as(@user, remember_me: "1")
|
||||
assert_not cookies[:remember_token].blank?
|
||||
end
|
||||
|
||||
test "login without remembering" do
|
||||
log_in_as(@user, remember_me: '1')
|
||||
log_in_as(@user, remember_me: '0')
|
||||
log_in_as(@user, remember_me: "1")
|
||||
log_in_as(@user, remember_me: "0")
|
||||
assert cookies[:remember_token].blank?
|
||||
end
|
||||
end
|
||||
|
@ -3,27 +3,27 @@ require "test_helper"
|
||||
class UsersSignupTest < ActionDispatch::IntegrationTest
|
||||
test "invalid signup information" do
|
||||
get signup_path
|
||||
assert_no_difference 'User.count' do
|
||||
assert_no_difference "User.count" do
|
||||
post users_path, params: { user: { name: "",
|
||||
email: "user@invalid",
|
||||
password: "foo",
|
||||
password_confirmation: "bar" } }
|
||||
end
|
||||
assert_template 'users/new'
|
||||
assert_select 'div#error_explanation'
|
||||
assert_select 'div.alert-danger'
|
||||
assert_template "users/new"
|
||||
assert_select "div#error_explanation"
|
||||
assert_select "div.alert-danger"
|
||||
end
|
||||
|
||||
test "valid signup information" do
|
||||
get signup_path
|
||||
assert_difference 'User.count', 1 do
|
||||
post users_path, params: { user: {name: "Example User",
|
||||
assert_difference "User.count", 1 do
|
||||
post users_path, params: { user: { name: "Example User",
|
||||
email: "user@example.com",
|
||||
password: "password",
|
||||
password_confirmation: "password" } }
|
||||
end
|
||||
follow_redirect!
|
||||
assert_template 'users/show'
|
||||
assert_template "users/show"
|
||||
assert_not flash.notice
|
||||
assert is_logged_in?
|
||||
end
|
||||
|
@ -75,6 +75,6 @@ class UserTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "authenticated? should return false for a user with nil digest" do
|
||||
assert_not @user.authenticated?('')
|
||||
assert_not @user.authenticated?("")
|
||||
end
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ module ActiveSupport
|
||||
end
|
||||
|
||||
class ActionDispatch::IntegrationTest
|
||||
def log_in_as(user, password: 'password', remember_me: '1')
|
||||
def log_in_as(user, password: "password", remember_me: "1")
|
||||
post login_path, params: { session: { email: user.email,
|
||||
password: password,
|
||||
remember_me: remember_me } }
|
||||
|
Loading…
Reference in New Issue
Block a user