From 3ef18a8886505c816e2f969f777f805d08a1b64b Mon Sep 17 00:00:00 2001 From: abdulhamiid Date: Fri, 12 Jan 2024 23:56:46 +0100 Subject: [PATCH] Fix errors --- .stylelintrc | 32 ------ Gemfile | 4 +- app/channels/application_cable/channel.rb | 2 + app/channels/application_cable/connection.rb | 2 + .../api/v1/authentication_controller.rb | 2 + app/controllers/api/v1/comments_controller.rb | 2 + app/controllers/api/v1/posts_controller.rb | 2 + app/controllers/api/v1/users_controller.rb | 2 + app/controllers/api_controller.rb | 2 + app/controllers/application_controller.rb | 2 + app/controllers/comments_controller.rb | 2 + app/controllers/likes_controller.rb | 2 + app/controllers/posts_controller.rb | 2 + app/controllers/users_controller.rb | 2 + app/helpers/application_helper.rb | 2 + app/helpers/posts_helper.rb | 2 + app/helpers/users_helper.rb | 2 + app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 2 + app/models/ability.rb | 2 + app/models/application_record.rb | 2 + app/models/comment.rb | 2 + app/models/like.rb | 2 + app/models/post.rb | 2 + app/models/user.rb | 2 + app/serializers/comment_serializer.rb | 2 + app/serializers/like_serializer.rb | 2 + app/serializers/post_serializer.rb | 2 + app/serializers/user_serializer.rb | 2 + app/services/authentication_token_service.rb | 4 +- config.ru | 2 + config/importmap.rb | 4 +- .../initializers/active_model_serializer.rb | 4 +- config/initializers/assets.rb | 2 +- config/routes.rb | 9 +- db/migrate/20220922173956_create_users.rb | 2 + db/migrate/20220923072124_create_posts.rb | 2 + .../20220923073719_add_user_ref_to_posts.rb | 2 + db/migrate/20220923075125_create_likes.rb | 2 + .../20220923075205_add_user_ref_to_likes.rb | 2 + .../20220923075818_add_posts_ref_to_likes.rb | 2 + db/migrate/20220923075848_create_comments.rb | 2 + ...0220923075906_add_users_ref_to_comments.rb | 2 + ...0220923075931_add_posts_ref_to_comments.rb | 2 + .../20220924011718_rename_column_in_posts.rb | 2 + ...0220924011808_rename_column_in_comments.rb | 2 + .../20220924011859_rename_column_in_likes.rb | 2 + .../20221007101943_add_devise_to_users.rb | 4 +- .../20221013055601_add_role_to_users.rb | 2 + db/schema.rb | 102 +++++++++--------- package-lock.json | 6 ++ spec/features/post_index_spec.rb | 2 + spec/features/post_show_spec.rb | 2 + spec/features/user_index_spec.rb | 2 + spec/features/user_show_spec.rb | 2 + spec/helpers/posts_helper_spec.rb | 2 + spec/helpers/users_helper_spec.rb | 2 + spec/models/comment_spec.rb | 2 + spec/models/like_spec.rb | 2 + spec/models/post_spec.rb | 2 + spec/models/user_spec.rb | 2 + spec/rails_helper.rb | 2 + spec/requests/posts_spec.rb | 2 + spec/requests/users_spec.rb | 2 + spec/spec_helper.rb | 2 + test/application_system_test_case.rb | 2 + .../application_cable/connection_test.rb | 2 + test/test_helper.rb | 2 + 68 files changed, 192 insertions(+), 95 deletions(-) delete mode 100644 .stylelintrc create mode 100644 package-lock.json diff --git a/.stylelintrc b/.stylelintrc deleted file mode 100644 index 5fa8628c..00000000 --- a/.stylelintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "extends": ["stylelint-config-standard"], - "plugins": ["stylelint-scss", "stylelint-csstree-validator"], - "rules": { - "at-rule-no-unknown": [ - true, - { - "ignoreAtRules": [ - "tailwind", - "apply", - "variants", - "responsive", - "screen" - ] - } - ], - "scss/at-rule-no-unknown": [ - true, - { - "ignoreAtRules": [ - "tailwind", - "apply", - "variants", - "responsive", - "screen" - ] - } - ], - "csstree/validator": true - }, - "ignoreFiles": ["build/**", "dist/**", "**/reset*.css", "**/bootstrap*.css"] -} \ No newline at end of file diff --git a/Gemfile b/Gemfile index a136d583..765a5b56 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } @@ -89,6 +91,6 @@ group :test do gem 'webdrivers' end -gem "sassc-rails" +gem 'sassc-rails' gem 'active_model_serializers', '~> 0.10.13' diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d6726972..9aec2305 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442f..8d6c2a1b 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/app/controllers/api/v1/authentication_controller.rb b/app/controllers/api/v1/authentication_controller.rb index 76edbcfe..ccf57ac9 100644 --- a/app/controllers/api/v1/authentication_controller.rb +++ b/app/controllers/api/v1/authentication_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class AuthenticationController < ApiController diff --git a/app/controllers/api/v1/comments_controller.rb b/app/controllers/api/v1/comments_controller.rb index 49cc43a7..85dcf516 100644 --- a/app/controllers/api/v1/comments_controller.rb +++ b/app/controllers/api/v1/comments_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class CommentsController < AuthenticationController diff --git a/app/controllers/api/v1/posts_controller.rb b/app/controllers/api/v1/posts_controller.rb index 80497c4c..045cf083 100644 --- a/app/controllers/api/v1/posts_controller.rb +++ b/app/controllers/api/v1/posts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PostsController < AuthenticationController diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index daea75bd..34701251 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class UsersController < AuthenticationController diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index d5dff0b0..857564b2 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApiController < ActionController::API include ActionController::HttpAuthentication::Token::ControllerMethods def authorize_request diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56a181d3..9dd5123f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base before_action :authenticate_user! diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f029b589..985e9a30 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CommentsController < ApplicationController def index @user = User.includes(posts: [:comments]).find(params[:user_id]) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 66be9564..4ced5e11 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class LikesController < ApplicationController def new; end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index cb1d08b9..0f2e1f35 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PostsController < ApplicationController def index @user = User.find(params[:user_id].to_i) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7ee3956a..f2e631ef 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UsersController < ApplicationController def index @users = User.all diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..15b06f0f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module ApplicationHelper end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index a7b8cec8..f7f46979 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module PostsHelper end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2310a240..4dc909ed 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module UsersHelper end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index d394c3d1..bef39599 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b2239..d84cb6e7 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' diff --git a/app/models/ability.rb b/app/models/ability.rb index e8564db7..bfdcbd69 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Ability include CanCan::Ability diff --git a/app/models/application_record.rb b/app/models/application_record.rb index b63caeb8..08dc5379 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base primary_abstract_class end diff --git a/app/models/comment.rb b/app/models/comment.rb index 75d655c2..84269e31 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Comment < ApplicationRecord belongs_to :author, class_name: 'User' belongs_to :post diff --git a/app/models/like.rb b/app/models/like.rb index 4aba97e3..f1d39cb6 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Like < ApplicationRecord belongs_to :author, class_name: 'User' belongs_to :post diff --git a/app/models/post.rb b/app/models/post.rb index ee02dbdd..fa992650 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Post < ApplicationRecord belongs_to :author, class_name: 'User' has_many :likes, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 9be66d34..ce03b5e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class User < ApplicationRecord ROLES = %w[user admin].freeze diff --git a/app/serializers/comment_serializer.rb b/app/serializers/comment_serializer.rb index 9b79f9cd..ed9c1041 100644 --- a/app/serializers/comment_serializer.rb +++ b/app/serializers/comment_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CommentSerializer < ActiveModel::Serializer attributes :id, :text end diff --git a/app/serializers/like_serializer.rb b/app/serializers/like_serializer.rb index 06c4cf46..af1775f7 100644 --- a/app/serializers/like_serializer.rb +++ b/app/serializers/like_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class LikeSerializer < ActiveModel::Serializer attributes :id end diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb index 105e913e..8924b446 100644 --- a/app/serializers/post_serializer.rb +++ b/app/serializers/post_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PostSerializer < ActiveModel::Serializer attributes :id, :title, :text, :comments_counter has_many :likes diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 70be282c..954dd721 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UserSerializer < ActiveModel::Serializer attributes :id, :name, :bio, :photo, :role, :posts_counter has_many :posts diff --git a/app/services/authentication_token_service.rb b/app/services/authentication_token_service.rb index 1999ad59..9c7e0b95 100644 --- a/app/services/authentication_token_service.rb +++ b/app/services/authentication_token_service.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AuthenticationTokenService - HMAC_SECRET = 'my$ecretK3y'.freeze + HMAC_SECRET = 'my$ecretK3y' def self.encode(id) payload = { user_id: id } JWT.encode payload, HMAC_SECRET, 'HS256' diff --git a/config.ru b/config.ru index ad1fbf29..6dc83218 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require_relative 'config/environment' diff --git a/config/importmap.rb b/config/importmap.rb index d3f2e09c..ccb8d01b 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -8,5 +8,5 @@ pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js', preload: true pin_all_from 'app/javascript/controllers', under: 'controllers' -pin "bootstrap", to: "bootstrap.min.js", preload: true -pin "@popperjs/core", to: "popper.js", preload: true \ No newline at end of file +pin 'bootstrap', to: 'bootstrap.min.js', preload: true +pin '@popperjs/core', to: 'popper.js', preload: true diff --git a/config/initializers/active_model_serializer.rb b/config/initializers/active_model_serializer.rb index bae08322..6f857680 100644 --- a/config/initializers/active_model_serializer.rb +++ b/config/initializers/active_model_serializer.rb @@ -1 +1,3 @@ -ActiveModelSerializers.config.adapter = :json_api \ No newline at end of file +# frozen_string_literal: true + +ActiveModelSerializers.config.adapter = :json_api diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index ce1ee977..269a838f 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -14,4 +14,4 @@ # Rails.application.config.assets.precompile += %w( admin.js admin.css ) # config/initializers/assets.rb -Rails.application.config.assets.precompile += %w(bootstrap.min.js popper.js) +Rails.application.config.assets.precompile += %w[bootstrap.min.js popper.js] diff --git a/config/routes.rb b/config/routes.rb index 57e0b43b..6ce03038 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true Rails.application.routes.draw do - namespace :api do namespace :v1 do post 'authenticate', to: 'authentication#create' @@ -14,16 +13,16 @@ end devise_for :users - devise_scope :user do + devise_scope :user do get '/users/sign_out' => 'devise/sessions#destroy' end # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - root "users#index" + root 'users#index' - resources :users, only: [:index, :show] do + resources :users, only: %i[index show] do resources :posts do resources :comments - resources :likes, only: [:new, :create] + resources :likes, only: %i[new create] end end # Defines the root path route ("/") diff --git a/db/migrate/20220922173956_create_users.rb b/db/migrate/20220922173956_create_users.rb index ff5126b9..a05f61f2 100644 --- a/db/migrate/20220922173956_create_users.rb +++ b/db/migrate/20220922173956_create_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateUsers < ActiveRecord::Migration[7.0] def change create_table :users do |t| diff --git a/db/migrate/20220923072124_create_posts.rb b/db/migrate/20220923072124_create_posts.rb index 6e299052..79c12d81 100644 --- a/db/migrate/20220923072124_create_posts.rb +++ b/db/migrate/20220923072124_create_posts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePosts < ActiveRecord::Migration[7.0] def change create_table :posts do |t| diff --git a/db/migrate/20220923073719_add_user_ref_to_posts.rb b/db/migrate/20220923073719_add_user_ref_to_posts.rb index 699ea020..c21c511b 100644 --- a/db/migrate/20220923073719_add_user_ref_to_posts.rb +++ b/db/migrate/20220923073719_add_user_ref_to_posts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUserRefToPosts < ActiveRecord::Migration[7.0] def change add_reference :posts, :user, null: false, foreign_key: true, index: true diff --git a/db/migrate/20220923075125_create_likes.rb b/db/migrate/20220923075125_create_likes.rb index 75adbbef..6459a6bf 100644 --- a/db/migrate/20220923075125_create_likes.rb +++ b/db/migrate/20220923075125_create_likes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateLikes < ActiveRecord::Migration[7.0] def change create_table :likes, &:timestamps diff --git a/db/migrate/20220923075205_add_user_ref_to_likes.rb b/db/migrate/20220923075205_add_user_ref_to_likes.rb index 3d830cc3..9bc2e0b4 100644 --- a/db/migrate/20220923075205_add_user_ref_to_likes.rb +++ b/db/migrate/20220923075205_add_user_ref_to_likes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUserRefToLikes < ActiveRecord::Migration[7.0] def change add_reference :likes, :user, null: false, foreign_key: true, index: true diff --git a/db/migrate/20220923075818_add_posts_ref_to_likes.rb b/db/migrate/20220923075818_add_posts_ref_to_likes.rb index 2f7f8a28..b0f3b114 100644 --- a/db/migrate/20220923075818_add_posts_ref_to_likes.rb +++ b/db/migrate/20220923075818_add_posts_ref_to_likes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPostsRefToLikes < ActiveRecord::Migration[7.0] def change add_reference :likes, :post, null: false, foreign_key: true, index: true diff --git a/db/migrate/20220923075848_create_comments.rb b/db/migrate/20220923075848_create_comments.rb index df799a88..a782a1dc 100644 --- a/db/migrate/20220923075848_create_comments.rb +++ b/db/migrate/20220923075848_create_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateComments < ActiveRecord::Migration[7.0] def change create_table :comments do |t| diff --git a/db/migrate/20220923075906_add_users_ref_to_comments.rb b/db/migrate/20220923075906_add_users_ref_to_comments.rb index b3e2b949..a087a179 100644 --- a/db/migrate/20220923075906_add_users_ref_to_comments.rb +++ b/db/migrate/20220923075906_add_users_ref_to_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUsersRefToComments < ActiveRecord::Migration[7.0] def change add_reference :comments, :user, null: false, foreign_key: true, index: true diff --git a/db/migrate/20220923075931_add_posts_ref_to_comments.rb b/db/migrate/20220923075931_add_posts_ref_to_comments.rb index e02f9c2c..a3416a7f 100644 --- a/db/migrate/20220923075931_add_posts_ref_to_comments.rb +++ b/db/migrate/20220923075931_add_posts_ref_to_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPostsRefToComments < ActiveRecord::Migration[7.0] def change add_reference :comments, :post, null: false, foreign_key: true, index: true diff --git a/db/migrate/20220924011718_rename_column_in_posts.rb b/db/migrate/20220924011718_rename_column_in_posts.rb index bec9bfcc..5e88911d 100644 --- a/db/migrate/20220924011718_rename_column_in_posts.rb +++ b/db/migrate/20220924011718_rename_column_in_posts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameColumnInPosts < ActiveRecord::Migration[7.0] def change rename_column :posts, :user_id, :author_id diff --git a/db/migrate/20220924011808_rename_column_in_comments.rb b/db/migrate/20220924011808_rename_column_in_comments.rb index bb7cadf8..963b7c05 100644 --- a/db/migrate/20220924011808_rename_column_in_comments.rb +++ b/db/migrate/20220924011808_rename_column_in_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameColumnInComments < ActiveRecord::Migration[7.0] def change rename_column :comments, :user_id, :author_id diff --git a/db/migrate/20220924011859_rename_column_in_likes.rb b/db/migrate/20220924011859_rename_column_in_likes.rb index c7d81573..2c6006be 100644 --- a/db/migrate/20220924011859_rename_column_in_likes.rb +++ b/db/migrate/20220924011859_rename_column_in_likes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameColumnInLikes < ActiveRecord::Migration[7.0] def change rename_column :likes, :user_id, :author_id diff --git a/db/migrate/20221007101943_add_devise_to_users.rb b/db/migrate/20221007101943_add_devise_to_users.rb index d1437134..b24d9105 100644 --- a/db/migrate/20221007101943_add_devise_to_users.rb +++ b/db/migrate/20221007101943_add_devise_to_users.rb @@ -4,8 +4,8 @@ class AddDeviseToUsers < ActiveRecord::Migration[7.0] def self.up change_table :users do |t| ## Database authenticatable - t.string :email, null: false, default: "" - t.string :encrypted_password, null: false, default: "" + t.string :email, null: false, default: '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token diff --git a/db/migrate/20221013055601_add_role_to_users.rb b/db/migrate/20221013055601_add_role_to_users.rb index 6c92f4bf..fdf5813b 100644 --- a/db/migrate/20221013055601_add_role_to_users.rb +++ b/db/migrate/20221013055601_add_role_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRoleToUsers < ActiveRecord::Migration[7.0] def change add_column :users, :role, :string diff --git a/db/schema.rb b/db/schema.rb index 8a008f6b..06334b4b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,64 +12,64 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_10_13_055601) do +ActiveRecord::Schema[7.0].define(version: 20_221_013_055_601) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension 'plpgsql' - create_table "comments", force: :cascade do |t| - t.string "text" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "author_id", null: false - t.bigint "post_id", null: false - t.index ["author_id"], name: "index_comments_on_author_id" - t.index ["post_id"], name: "index_comments_on_post_id" + create_table 'comments', force: :cascade do |t| + t.string 'text' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.bigint 'author_id', null: false + t.bigint 'post_id', null: false + t.index ['author_id'], name: 'index_comments_on_author_id' + t.index ['post_id'], name: 'index_comments_on_post_id' end - create_table "likes", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "author_id", null: false - t.bigint "post_id", null: false - t.index ["author_id"], name: "index_likes_on_author_id" - t.index ["post_id"], name: "index_likes_on_post_id" + create_table 'likes', force: :cascade do |t| + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.bigint 'author_id', null: false + t.bigint 'post_id', null: false + t.index ['author_id'], name: 'index_likes_on_author_id' + t.index ['post_id'], name: 'index_likes_on_post_id' end - create_table "posts", force: :cascade do |t| - t.string "title" - t.string "text" - t.integer "comments_counter" - t.integer "likes_counter" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "author_id", null: false - t.index ["author_id"], name: "index_posts_on_author_id" + create_table 'posts', force: :cascade do |t| + t.string 'title' + t.string 'text' + t.integer 'comments_counter' + t.integer 'likes_counter' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.bigint 'author_id', null: false + t.index ['author_id'], name: 'index_posts_on_author_id' end - create_table "users", force: :cascade do |t| - t.string "name" - t.string "photo" - t.string "bio" - t.integer "posts_counter", default: 0 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "role" - t.index ["email"], name: "index_users_on_email", unique: true - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + create_table 'users', force: :cascade do |t| + t.string 'name' + t.string 'photo' + t.string 'bio' + t.integer 'posts_counter', default: 0 + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'email', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.datetime 'remember_created_at' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'role' + t.index ['email'], name: 'index_users_on_email', unique: true + t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true end - add_foreign_key "comments", "posts" - add_foreign_key "comments", "users", column: "author_id" - add_foreign_key "likes", "posts" - add_foreign_key "likes", "users", column: "author_id" - add_foreign_key "posts", "users", column: "author_id" + add_foreign_key 'comments', 'posts' + add_foreign_key 'comments', 'users', column: 'author_id' + add_foreign_key 'likes', 'posts' + add_foreign_key 'likes', 'users', column: 'author_id' + add_foreign_key 'posts', 'users', column: 'author_id' end diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..e80162cb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "blog-app", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/spec/features/post_index_spec.rb b/spec/features/post_index_spec.rb index 95360464..f73b197b 100644 --- a/spec/features/post_index_spec.rb +++ b/spec/features/post_index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'posts_index', type: :feature do diff --git a/spec/features/post_show_spec.rb b/spec/features/post_show_spec.rb index 670a8d7d..e3d74d7f 100644 --- a/spec/features/post_show_spec.rb +++ b/spec/features/post_show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'posts_show', type: :feature do diff --git a/spec/features/user_index_spec.rb b/spec/features/user_index_spec.rb index eed397fa..2fd63633 100644 --- a/spec/features/user_index_spec.rb +++ b/spec/features/user_index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'users_index', type: :feature do diff --git a/spec/features/user_show_spec.rb b/spec/features/user_show_spec.rb index 8efdae0d..6be553e9 100644 --- a/spec/features/user_show_spec.rb +++ b/spec/features/user_show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'users_show', type: :feature do diff --git a/spec/helpers/posts_helper_spec.rb b/spec/helpers/posts_helper_spec.rb index f3d00cbc..a3fc4be5 100644 --- a/spec/helpers/posts_helper_spec.rb +++ b/spec/helpers/posts_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' # Specs in this file have access to a helper object that includes diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index b2e34440..15ca021b 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' # Specs in this file have access to a helper object that includes diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index f9a2ba26..f03deb24 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Like, type: :model do diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index b8d505c9..c93a4571 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Like, type: :model do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index b0f09781..ede4d56a 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Post, type: :model do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 975b39b1..8c0b9ec1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe User, type: :model do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 34fa3751..9a1fe4d2 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' diff --git a/spec/requests/posts_spec.rb b/spec/requests/posts_spec.rb index afa20442..739175a8 100644 --- a/spec/requests/posts_spec.rb +++ b/spec/requests/posts_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Posts', type: %w[request feature] do diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb index 1ca6ccf4..8deb52df 100644 --- a/spec/requests/users_spec.rb +++ b/spec/requests/users_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Users', type: :request do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d0cef333..89f676c7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 23701b43..652febbd 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb index f925925c..4aee9b33 100644 --- a/test/channels/application_cable/connection_test.rb +++ b/test/channels/application_cable/connection_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' module ApplicationCable diff --git a/test/test_helper.rb b/test/test_helper.rb index c5bb3287..a92e6ef1 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' require 'rails/test_help'