- <%= book.authors %>
+
+ Title: <%= book.title %>
-
- <%= book.price_with_currency %>
+
+ Price: <%= book.price %>
-
- <%= book.quantity %>
+
+ Authors: <%= book.authors %>
-
- <% if can_book_be_added?(book) %>
- <%= link_to 'Add', "book/#{book.id}/add_to_cart", method: :post, class: "btn" %>
- <% end %>
-
-
- <% if current_user&.admin? %>
-
- <%= book.published ? 'published' : 'unpublished' %>
-
-
- <%= link_to 'Edit', edit_book_path(book), class: "btn" %>
-
- <% end %>
<% end %>
diff --git a/app/views/books/shopping_cart.erb b/app/views/books/shopping_cart.erb
deleted file mode 100644
index dc6121d..0000000
--- a/app/views/books/shopping_cart.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
Title
- Authors
- Price
-
- <% @books.each do |book| %>
-
-
- <%= book.title %>
-
-
-
- <%= book.authors %>
-
-
-
- <%= book.price_with_currency %>
-
-
- <% end %>
-
-
Summary
-
<%= cart_summary %>
-
-
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 904da48..7ca2457 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -2,53 +2,15 @@
Book store
-
+
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
- <%= javascript_include_tag 'rails-ujs' %>
-
-
-
-
- <%= link_to 'Home', '/welcome', method: :get%>
-
-
-
- <%= link_to 'Books', '/books', method: :get%>
-
- <% if current_user&.admin? %>
-
- <%= link_to 'Authors', '/authors', method: :get%>
-
-
- <%= link_to 'Users', '/users', method: :get%>
-
- <% end %>
- <% if logged_in? %>
-
- <%= link_to 'Shopping cart', '/shopping_cart', method: :get%>
-
- <% end %>
-
-
- <% flash.each do |type, notice| %>
-
- <% if notice.is_a? String %>
- <%= notice %>
- <% else %>
- <% notice.each do |msg| %>
-
<%= msg %>
- <% end %>
- <% end %>
-
- <% end %>
-
<%= yield %>
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
deleted file mode 100644
index 9d3fca7..0000000
--- a/app/views/sessions/new.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
Login
- <%= form_tag '/login' do %>
- <%= label_tag :email%>
- <%= text_field_tag :email %>
- <%= label_tag :password%>
- <%= password_field_tag :password%>
- <%= submit_tag "Login", class: 'btn' %>
- <%end%>
- <%= link_to "Password recovery", '/password_recovery_request', method: :get %>
-
diff --git a/app/views/sessions/welcome.html.erb b/app/views/sessions/welcome.html.erb
deleted file mode 100644
index f2a1bcd..0000000
--- a/app/views/sessions/welcome.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
Welcome
-
- <% if logged_in? %>
-
You are logged in, <%= current_user.email %>
- <%= link_to 'Logout', '/logout', method: :get, class: 'btn' %>
- <% else %>
-
You are not logged in
- <%= link_to 'Login', '/login', method: :get, class: 'btn' %>
- <%= link_to 'Sign Up', '/users/new', method: :get, class: 'btn' %>
- <% end %>
-
-
diff --git a/app/views/user_mailer/password_recovery.html.erb b/app/views/user_mailer/password_recovery.html.erb
deleted file mode 100644
index b89c984..0000000
--- a/app/views/user_mailer/password_recovery.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-Please click the link to recover your password: <%= @url %>
\ No newline at end of file
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
deleted file mode 100644
index bc5ecb1..0000000
--- a/app/views/users/index.html.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-
- <% @users.each do |user| %>
-
-
- <%= user.email %>
-
-
- <%= user.role %>
-
-
- <%= user.status %>
-
-
- <%= link_to 'Delete', user, method: :delete, class: "btn" %>
-
-
- <%= link_to 'Block', "/user/#{user.id}/block", method: :post, class: "btn" %>
-
-
- <% end %>
-
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
deleted file mode 100644
index a4ce410..0000000
--- a/app/views/users/new.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
Sign Up
- <%= form_for @user do |f|%>
- <%= f.label :email%>
- <%= f.text_field :email%>
- <%= f.label :password%>
- <%= f.password_field :password%>
- <%= f.submit 'Sign up', class: 'btn' %>
- <%end%>
-
diff --git a/app/views/users/password_recovery_request_form.erb b/app/views/users/password_recovery_request_form.erb
deleted file mode 100644
index b267001..0000000
--- a/app/views/users/password_recovery_request_form.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
Password recovery
- Provide an email to password recovery
- <%= form_with url: "/password_recovery_request", method: :post do |f| %>
- <%= f.label :email%>
- <%= f.text_field :email %>
- <%= f.submit 'Send email', class: 'btn' %>
- <% end %>
-
diff --git a/app/views/users/recover_password_form.html.erb b/app/views/users/recover_password_form.html.erb
deleted file mode 100644
index 29e7b58..0000000
--- a/app/views/users/recover_password_form.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
Provide new password
-
- <%= form_with url: '/recover_password', method: :post do |f| %>
- <%= f.label :password%>
- <%= f.password_field :password %>
- <%= f.label :password_confirmation%>
- <%= f.password_field :password_confirmation %>
- <%= f.hidden_field :recovery_password, :value => @recovery_password %>
- <%= f.hidden_field :user_id, :value => @user_id %>
- <%= f.submit 'Change password', class: 'btn' %>
- <% end %>
-
diff --git a/bin/bundle b/bin/bundle
index 73ec947..a71368e 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -8,46 +8,46 @@
# this file is here to facilitate running it.
#
-require 'rubygems'
+require "rubygems"
m = Module.new do
module_function
def invoked_as_script?
- File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
+ File.expand_path($0) == File.expand_path(__FILE__)
end
def env_var_version
- ENV['BUNDLER_VERSION']
+ ENV["BUNDLER_VERSION"]
end
def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
- return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
-
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
- bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ bundler_version = a
+ end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
-
- bundler_version = Regexp.last_match(1)
+ bundler_version = $1
update_index = i
end
bundler_version
end
def gemfile
- gemfile = ENV['BUNDLE_GEMFILE']
+ gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?
- File.expand_path('../Gemfile', __dir__)
+ File.expand_path("../../Gemfile", __FILE__)
end
def lockfile
lockfile =
case File.basename(gemfile)
- when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
@@ -55,17 +55,15 @@ m = Module.new do
def lockfile_version
return unless File.file?(lockfile)
-
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
-
Regexp.last_match(1)
end
def bundler_version
@bundler_version ||=
env_var_version || cli_arg_version ||
- lockfile_version
+ lockfile_version
end
def bundler_requirement
@@ -75,32 +73,28 @@ m = Module.new do
requirement = bundler_gem_version.approximate_recommendation
- return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.7.0')
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
- requirement += '.a' if bundler_gem_version.prerelease?
+ requirement += ".a" if bundler_gem_version.prerelease?
requirement
end
def load_bundler!
- ENV['BUNDLE_GEMFILE'] ||= gemfile
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
activate_bundler
end
def activate_bundler
gem_error = activation_error_handling do
- gem 'bundler', bundler_requirement
+ gem "bundler", bundler_requirement
end
return if gem_error.nil?
-
require_error = activation_error_handling do
- require 'bundler/version'
+ require "bundler/version"
end
- if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
- return
- end
-
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end
@@ -115,4 +109,6 @@ end
m.load_bundler!
-load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?
+if m.invoked_as_script?
+ load Gem.bin_path("bundler", "bundle")
+end
diff --git a/bin/rails b/bin/rails
index 33ffd90..21d3e02 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,7 +1,5 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-load File.expand_path('spring', __dir__)
+load File.expand_path("spring", __dir__)
APP_PATH = File.expand_path('../config/application', __dir__)
-require_relative '../config/boot'
-require 'rails/commands'
+require_relative "../config/boot"
+require "rails/commands"
diff --git a/bin/rake b/bin/rake
index 05ee931..7327f47 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,7 +1,5 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-load File.expand_path('spring', __dir__)
-require_relative '../config/boot'
-require 'rake'
+load File.expand_path("spring", __dir__)
+require_relative "../config/boot"
+require "rake"
Rake.application.run
diff --git a/bin/setup b/bin/setup
index 0e38d30..90700ac 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,7 +1,5 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-require 'fileutils'
+require "fileutils"
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
diff --git a/bin/spring b/bin/spring
index e52a4f8..b4147e8 100755
--- a/bin/spring
+++ b/bin/spring
@@ -1,15 +1,13 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-if !defined?(Spring) && [nil, 'development', 'test'].include?(ENV['RAILS_ENV'])
- gem 'bundler'
- require 'bundler'
+if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
+ gem "bundler"
+ require "bundler"
# Load Spring without loading other gems in the Gemfile, for speed.
- Bundler.locked_gems&.specs&.find { |spec| spec.name == 'spring' }&.tap do |spring|
+ Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring|
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
- gem 'spring', spring.version
- require 'spring/binstub'
+ gem "spring", spring.version
+ require "spring/binstub"
rescue Gem::LoadError
# Ignore when Spring is not installed.
end
diff --git a/bin/webpack b/bin/webpack
index 62114ba..1031168 100755
--- a/bin/webpack
+++ b/bin/webpack
@@ -1,19 +1,18 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
-ENV['NODE_ENV'] ||= 'development'
+ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
+ENV["NODE_ENV"] ||= "development"
-require 'pathname'
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
- Pathname.new(__FILE__).realpath)
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
-require 'bundler/setup'
+require "bundler/setup"
-require 'webpacker'
-require 'webpacker/webpack_runner'
+require "webpacker"
+require "webpacker/webpack_runner"
-APP_ROOT = File.expand_path('..', __dir__)
+APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::WebpackRunner.run(ARGV)
end
diff --git a/bin/webpack-dev-server b/bin/webpack-dev-server
index e4f41cc..dd96627 100755
--- a/bin/webpack-dev-server
+++ b/bin/webpack-dev-server
@@ -1,19 +1,18 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
-ENV['NODE_ENV'] ||= 'development'
+ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
+ENV["NODE_ENV"] ||= "development"
-require 'pathname'
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
- Pathname.new(__FILE__).realpath)
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
-require 'bundler/setup'
+require "bundler/setup"
-require 'webpacker'
-require 'webpacker/dev_server_runner'
+require "webpacker"
+require "webpacker/dev_server_runner"
-APP_ROOT = File.expand_path('..', __dir__)
+APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::DevServerRunner.run(ARGV)
end
diff --git a/bin/yarn b/bin/yarn
index 9da8e5c..9fab2c3 100755
--- a/bin/yarn
+++ b/bin/yarn
@@ -1,19 +1,17 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
- yarn = ENV['PATH'].split(File::PATH_SEPARATOR)
- .reject { |dir| File.expand_path(dir) == __dir__ }
- .product(['yarn', 'yarn.cmd', 'yarn.ps1'])
- .map { |dir, file| File.expand_path(file, dir) }
- .find { |file| File.executable?(file) }
+ yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
+ select { |dir| File.expand_path(dir) != __dir__ }.
+ product(["yarn", "yarn.cmd", "yarn.ps1"]).
+ map { |dir, file| File.expand_path(file, dir) }.
+ find { |file| File.executable?(file) }
if yarn
exec yarn, *ARGV
else
- warn 'Yarn executable was not detected in the system.'
- warn 'Download Yarn at https://yarnpkg.com/en/docs/install'
+ $stderr.puts "Yarn executable was not detected in the system."
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
diff --git a/config.ru b/config.ru
index 6dc8321..4a3c09a 100644
--- a/config.ru
+++ b/config.ru
@@ -1,8 +1,6 @@
-# frozen_string_literal: true
-
# This file is used by Rack-based servers to start the application.
-require_relative 'config/environment'
+require_relative "config/environment"
run Rails.application
Rails.application.load_server
diff --git a/config/application.rb b/config/application.rb
index a55fbe9..1dba805 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,14 +1,11 @@
-# frozen_string_literal: true
+require_relative "boot"
-require_relative 'boot'
-
-require 'rails/all'
+require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
-# App
module App
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
diff --git a/config/boot.rb b/config/boot.rb
index c04863f..3cda23b 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,6 +1,4 @@
-# frozen_string_literal: true
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
-require 'bundler/setup' # Set up gems listed in the Gemfile.
-require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
+require "bundler/setup" # Set up gems listed in the Gemfile.
+require "bootsnap/setup" # Speed up boot time by caching expensive operations.
diff --git a/config/environment.rb b/config/environment.rb
index d5abe55..cac5315 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,7 +1,5 @@
-# frozen_string_literal: true
-
# Load the Rails application.
-require_relative 'application'
+require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 7f56706..47ba8c6 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,6 +1,4 @@
-# frozen_string_literal: true
-
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@@ -58,8 +56,7 @@ Rails.application.configure do
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
- config.assets.debug = false
- config.assets.check_precompiled_asset = false
+ config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true
@@ -76,4 +73,6 @@ Rails.application.configure do
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
+ #
+ config.web_console.permissions = '192.168.0.0/16'
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index bceeda0..36dd980 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,6 +1,4 @@
-# frozen_string_literal: true
-
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@@ -55,7 +53,7 @@ Rails.application.configure do
config.log_level = :info
# Prepend all log lines with the following tags.
- config.log_tags = [:request_id]
+ config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
@@ -90,8 +88,8 @@ Rails.application.configure do
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
- if ENV['RAILS_LOG_TO_STDOUT'].present?
- logger = ActiveSupport::Logger.new($stdout)
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 74b1be2..93ed4f1 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,6 +1,4 @@
-# frozen_string_literal: true
-
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
index f4556db..89d2efa 100644
--- a/config/initializers/application_controller_renderer.rb
+++ b/config/initializers/application_controller_renderer.rb
@@ -1,4 +1,3 @@
-# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index a9b0d0f..4b828e8 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -1,5 +1,3 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
index d43cc1d..33699c3 100644
--- a/config/initializers/backtrace_silencers.rb
+++ b/config/initializers/backtrace_silencers.rb
@@ -1,5 +1,3 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -7,4 +5,4 @@
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
-Rails.backtrace_cleaner.remove_silencers! if ENV['BACKTRACE']
+Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index f3bcce5..35d0f26 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -1,4 +1,3 @@
-# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
index ee8dff9..5a6a32d 100644
--- a/config/initializers/cookies_serializer.rb
+++ b/config/initializers/cookies_serializer.rb
@@ -1,5 +1,3 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index 3babc73..4b34a03 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -1,8 +1,6 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
-Rails.application.config.filter_parameters += %i[
- passw secret token _key crypt salt certificate otp ssn
+Rails.application.config.filter_parameters += [
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index aa7435f..ac033bf 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -1,4 +1,3 @@
-# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index 6e1d16f..dc18996 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -1,4 +1,3 @@
-# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb
index 50bcf4e..00f64d7 100644
--- a/config/initializers/permissions_policy.rb
+++ b/config/initializers/permissions_policy.rb
@@ -1,4 +1,3 @@
-# frozen_string_literal: true
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index 2f3c0db..bbfc396 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -1,5 +1,3 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
diff --git a/config/puma.rb b/config/puma.rb
index 8ae6a78..d9b3e83 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,30 +1,28 @@
-# frozen_string_literal: true
-
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
-max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
-min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
-worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
+worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
-port ENV.fetch('PORT', 3000)
+port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
-environment ENV.fetch('RAILS_ENV', 'development')
+environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
-pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
diff --git a/config/routes.rb b/config/routes.rb
index dfe1a61..af3f220 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,19 +1,3 @@
-# frozen_string_literal: true
-
Rails.application.routes.draw do
- resources :users
- get 'login', to: 'sessions#new'
- get 'logout', to: 'sessions#delete'
- post 'login', to: 'sessions#create'
- get 'welcome', to: 'sessions#welcome'
- get 'password_recovery_request', to: 'users#password_recovery_request_form'
- post 'password_recovery_request', to: 'users#password_recovery_request'
- get 'recover_password/:id/:recovery_password', to: 'users#recover_password_form'
- post 'recover_password', to: 'users#recover_password'
- post 'user/:id/block', to: 'users#block'
- post 'book/:id/add_to_cart', to: 'books#add_to_cart'
- get 'shopping_cart', to: 'books#shopping_cart'
-
resources :books
- resources :authors
end
diff --git a/config/spring.rb b/config/spring.rb
index 93cd0ff..db5bf13 100644
--- a/config/spring.rb
+++ b/config/spring.rb
@@ -1,8 +1,6 @@
-# frozen_string_literal: true
-
Spring.watch(
- '.ruby-version',
- '.rbenv-vars',
- 'tmp/restart.txt',
- 'tmp/caching-dev.txt'
+ ".ruby-version",
+ ".rbenv-vars",
+ "tmp/restart.txt",
+ "tmp/caching-dev.txt"
)
diff --git a/db/migrate/20210319142051_create_authors.rb b/db/migrate/20210319142051_create_authors.rb
index 100b87c..1265628 100644
--- a/db/migrate/20210319142051_create_authors.rb
+++ b/db/migrate/20210319142051_create_authors.rb
@@ -1,6 +1,3 @@
-# frozen_string_literal: true
-
-# Create authors
class CreateAuthors < ActiveRecord::Migration[6.1]
def change
create_table :authors do |t|
@@ -10,6 +7,6 @@ class CreateAuthors < ActiveRecord::Migration[6.1]
t.timestamps
end
- add_index :authors, %i[first_name last_name]
+ add_index :authors, [ :first_name, :last_name ]
end
end
diff --git a/db/migrate/20210319142054_create_books.rb b/db/migrate/20210319142054_create_books.rb
index f87d7cc..868e375 100644
--- a/db/migrate/20210319142054_create_books.rb
+++ b/db/migrate/20210319142054_create_books.rb
@@ -1,6 +1,3 @@
-# frozen_string_literal: true
-
-# Create books
class CreateBooks < ActiveRecord::Migration[6.1]
def change
create_table :books do |t|
diff --git a/db/migrate/20210319142059_create_authors_books.rb b/db/migrate/20210319142059_create_authors_books.rb
index d0fe027..f26bea6 100644
--- a/db/migrate/20210319142059_create_authors_books.rb
+++ b/db/migrate/20210319142059_create_authors_books.rb
@@ -1,6 +1,3 @@
-# frozen_string_literal: true
-
-# Create association table between authors and books
class CreateAuthorsBooks < ActiveRecord::Migration[6.1]
def change
create_table :authors_books do |t|
diff --git a/db/migrate/20210320130542_create_users.rb b/db/migrate/20210320130542_create_users.rb
deleted file mode 100644
index d264856..0000000
--- a/db/migrate/20210320130542_create_users.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-# Create users
-class CreateUsers < ActiveRecord::Migration[6.1]
- def change
- create_table :users do |t|
- t.string :username
- t.string :password_digest
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20210320212922_change_username_to_email.rb b/db/migrate/20210320212922_change_username_to_email.rb
deleted file mode 100644
index 3f6cd5e..0000000
--- a/db/migrate/20210320212922_change_username_to_email.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeUsernameToEmail < ActiveRecord::Migration[6.1]
- def change
- rename_column :users, :username, :email
- end
-end
diff --git a/db/migrate/20210320233401_add_password_recovery_code_to_users.rb b/db/migrate/20210320233401_add_password_recovery_code_to_users.rb
deleted file mode 100644
index a0afccc..0000000
--- a/db/migrate/20210320233401_add_password_recovery_code_to_users.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddPasswordRecoveryCodeToUsers < ActiveRecord::Migration[6.1]
- def change
- add_column :users, :password_recovery_code, :string
- end
-end
diff --git a/db/migrate/20210321093857_change_password_recovery_code_to_recovery_password_digest.rb b/db/migrate/20210321093857_change_password_recovery_code_to_recovery_password_digest.rb
deleted file mode 100644
index a88ab42..0000000
--- a/db/migrate/20210321093857_change_password_recovery_code_to_recovery_password_digest.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class ChangePasswordRecoveryCodeToRecoveryPasswordDigest < ActiveRecord::Migration[6.1]
- def change
- rename_column :users, :password_recovery_code, :recovery_password_digest
- end
-end
diff --git a/db/migrate/20210321135711_add_role_to_users.rb b/db/migrate/20210321135711_add_role_to_users.rb
deleted file mode 100644
index c6d293e..0000000
--- a/db/migrate/20210321135711_add_role_to_users.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddRoleToUsers < ActiveRecord::Migration[6.1]
- def change
- add_column :users, :role, :integer
- end
-end
diff --git a/db/migrate/20210321213901_add_status_to_users.rb b/db/migrate/20210321213901_add_status_to_users.rb
deleted file mode 100644
index 09e39e2..0000000
--- a/db/migrate/20210321213901_add_status_to_users.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddStatusToUsers < ActiveRecord::Migration[6.1]
- def change
- add_column :users, :status, :integer
- end
-end
diff --git a/db/migrate/20210321225317_create_audit_records.rb b/db/migrate/20210321225317_create_audit_records.rb
deleted file mode 100644
index 3efe7bd..0000000
--- a/db/migrate/20210321225317_create_audit_records.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class CreateAuditRecords < ActiveRecord::Migration[6.1]
- def change
- create_table :audit_records do |t|
- t.string :model
- t.string :action
- t.string :params
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20210321235625_add_quantity_to_books.rb b/db/migrate/20210321235625_add_quantity_to_books.rb
deleted file mode 100644
index 2cd1cb3..0000000
--- a/db/migrate/20210321235625_add_quantity_to_books.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddQuantityToBooks < ActiveRecord::Migration[6.1]
- def change
- add_column :books, :quantity, :integer
- end
-end
diff --git a/db/migrate/20210322002803_create_books_users.rb b/db/migrate/20210322002803_create_books_users.rb
deleted file mode 100644
index b870a0a..0000000
--- a/db/migrate/20210322002803_create_books_users.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-class CreateBooksUsers < ActiveRecord::Migration[6.1]
- def change
- create_table :books_users do |t|
- t.belongs_to :book
- t.belongs_to :user
-
- t.timestamps
- end
- end
-end
diff --git a/db/schema.rb b/db/schema.rb
index ed53db2..f539461 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,5 +1,3 @@
-# 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.
@@ -12,58 +10,32 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20_210_322_002_803) do
- create_table 'audit_records', force: :cascade do |t|
- t.string 'model'
- t.string 'action'
- t.string 'params'
- t.datetime 'created_at', precision: 6, null: false
- t.datetime 'updated_at', precision: 6, null: false
+ActiveRecord::Schema.define(version: 2021_03_19_142059) do
+
+ create_table "authors", force: :cascade do |t|
+ t.string "first_name"
+ t.string "last_name"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["first_name", "last_name"], name: "index_authors_on_first_name_and_last_name"
end
- create_table 'authors', force: :cascade do |t|
- t.string 'first_name'
- t.string 'last_name'
- t.datetime 'created_at', precision: 6, null: false
- t.datetime 'updated_at', precision: 6, null: false
- t.index %w[first_name last_name], name: 'index_authors_on_first_name_and_last_name'
+ create_table "authors_books", force: :cascade do |t|
+ t.integer "book_id"
+ t.integer "author_id"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["author_id"], name: "index_authors_books_on_author_id"
+ t.index ["book_id"], name: "index_authors_books_on_book_id"
end
- create_table 'authors_books', force: :cascade do |t|
- t.integer 'book_id'
- t.integer 'author_id'
- t.datetime 'created_at', precision: 6, null: false
- t.datetime 'updated_at', precision: 6, null: false
- t.index ['author_id'], name: 'index_authors_books_on_author_id'
- t.index ['book_id'], name: 'index_authors_books_on_book_id'
+ create_table "books", force: :cascade do |t|
+ t.string "title"
+ t.decimal "price", precision: 10, scale: 2
+ t.boolean "published"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["published"], name: "index_books_on_published"
end
- create_table 'books', force: :cascade do |t|
- t.string 'title'
- t.decimal 'price', precision: 10, scale: 2
- t.boolean 'published'
- t.datetime 'created_at', precision: 6, null: false
- t.datetime 'updated_at', precision: 6, null: false
- t.integer 'quantity'
- t.index ['published'], name: 'index_books_on_published'
- end
-
- create_table 'books_users', force: :cascade do |t|
- t.integer 'book_id'
- t.integer 'user_id'
- t.datetime 'created_at', precision: 6, null: false
- t.datetime 'updated_at', precision: 6, null: false
- t.index ['book_id'], name: 'index_books_users_on_book_id'
- t.index ['user_id'], name: 'index_books_users_on_user_id'
- end
-
- create_table 'users', force: :cascade do |t|
- t.string 'email'
- t.string 'password_digest'
- t.datetime 'created_at', precision: 6, null: false
- t.datetime 'updated_at', precision: 6, null: false
- t.string 'recovery_password_digest'
- t.integer 'role'
- t.integer 'status'
- end
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 92b4b80..1f3af18 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,74 +1,51 @@
-# frozen_string_literal: true
-
books = Book.create([
- {
- title: 'Journey to the Center of the Earth',
- price: 10_900,
- published: true,
- quantity: 100
- },
- {
- title: 'From the Earth to the Moon',
- price: 6300,
- published: false,
- quantity: 0
- },
- {
- title: 'Imaginary trip',
- price: 3600,
- published: true,
- quantity: 1
- },
- {
- title: 'Winnie the Pooh',
- price: 3700,
- published: true,
- quantity: 5
- }
- ])
+ {
+ title: 'Journey to the Center of the Earth',
+ price: 10900,
+ published: true
+ },
+ {
+ title: 'From the Earth to the Moon',
+ price: 6300,
+ published: false
+ },
+ {
+ title: 'Imaginary trip',
+ price: 3600,
+ published: true
+ },
+])
authors = Author.create([
- {
- first_name: 'Jules',
- last_name: 'Verne'
- },
- {
- first_name: 'Dick',
- last_name: 'Pick'
- },
- {
- first_name: 'Rick',
- last_name: 'Pickle'
- },
- {
- first_name: 'Alan',
- last_name: 'Milne'
- }
- ])
+ {
+ first_name: 'Jules',
+ last_name: 'Verne'
+ },
+ {
+ first_name: 'Dick',
+ last_name: 'Pick',
+ },
+ {
+ first_name: 'Rick',
+ last_name: 'Pickle'
+ },
+])
-books.first.authors << authors.first
-books.second.authors << authors.first
-books.third.authors << authors.second
-books.third.authors << authors.third
-books.fourth.authors << authors.fourth
-
-User.create([
- {
- email: 'abc@o2.pl',
- password: 'aaaaaaaa',
- role: :admin,
- status: :ready
- },
- {
- email: 'abcd@o2.pl',
- password: 'aaaaaaaa',
- role: :customer,
- status: :ready
- },
- {
- email: 'abcde@o2.pl',
- password: 'aaaaaaaa',
- role: :customer,
- status: :ready
- }
- ])
+BookAuthor.create([
+ {
+ book: books.first,
+ author: authors.first
+ },
+ {
+ book: books[1],
+ author: authors.first
+ },
+ {
+ book: books[2],
+ author: authors[1]
+ },
+ {
+ book: books[2],
+ author: authors[2]
+ },
+])
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index a1a87c7..fd0dbeb 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,7 +12,7 @@ services:
env_file:
- docker/.env
webpack_dev_server:
- image: bookstore_bookstore
+ image: bookstore-bookstore
volumes:
- ./:/app:delegated
- bundle_volume:/usr/local/bundle
diff --git a/docker/webpack_entrypoint.sh b/docker/webpack_entrypoint.sh
index 5fc4448..3d0dc53 100755
--- a/docker/webpack_entrypoint.sh
+++ b/docker/webpack_entrypoint.sh
@@ -1,3 +1,4 @@
#!/bin/bash
+yarn install
exec "$@"
diff --git a/public/404.html b/public/404.html
index 3e2d224..2be3af2 100644
--- a/public/404.html
+++ b/public/404.html
@@ -58,7 +58,7 @@
-
The page you were looking for doesn't exist.
+
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
diff --git a/public/422.html b/public/422.html
index badeeb8..c08eac0 100644
--- a/public/422.html
+++ b/public/422.html
@@ -58,7 +58,7 @@
-
The change you wanted was rejected.
+
The change you wanted was rejected.
Maybe you tried to change something you didn't have access to.
If you are the application owner check the logs for more information.
diff --git a/public/500.html b/public/500.html
index 1fd70e3..78a030a 100644
--- a/public/500.html
+++ b/public/500.html
@@ -58,7 +58,7 @@
-
We're sorry, but something went wrong.
+ We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
deleted file mode 100644
index 7b028e7..0000000
--- a/spec/controllers/application_controller_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-RSpec.describe ApplicationController do
- describe 'current_user' do
- before(:all) do
- User.create(email: 'test2@example.com', password: 'abcde')
- end
- context 'when a user is logged in' do
- it 'returns the user' do
- # TODO
- # expect(current_user.email).to eql('test2@example.com')
- end
- end
- end
- describe 'logged_in?' do
- # TODO
- end
-end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
deleted file mode 100644
index e34a98d..0000000
--- a/spec/controllers/sessions_controller_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-RSpec.describe SessionsController do
- describe 'get new' do
- subject { get 'new' }
- it 'renders the sessions/new template' do
- expect(subject).to render_template('sessions/new')
- end
- end
- describe 'get create' do
- # TODO: test session status
- subject { get 'create' }
- it 'redirects to /welcome' do
- expect(subject).to redirect_to('/welcome')
- end
- end
- describe 'get delete' do
- # TODO: test session status
- subject { get 'delete' }
- it 'redirects to /welcome' do
- expect(subject).to redirect_to('/welcome')
- end
- end
- describe 'get welcome' do
- subject { get 'welcome' }
- it 'renders the sessions/welcome template' do
- expect(subject).to render_template('sessions/welcome')
- end
- end
-end
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
deleted file mode 100644
index 8595b6c..0000000
--- a/spec/controllers/users_controller_spec.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-RSpec.describe UsersController do
- before(:all) do # TODO: turn it into cleanup after each test
- User.destroy_all
- end
- let(:user1) do
- User.create(
- email: 'test1@example.com',
- password: 'abcdefgh',
- recovery_password: 'recovery password',
- role: :admin
- )
- end
- describe 'get index' do
- subject { get :index }
- it 'renders the users/index template' do
- expect(subject).to render_template('users/index')
- end
- end
- describe 'get new' do
- subject { get :new }
- it 'renders the users/new template' do
- expect(subject).to render_template('users/new')
- end
- end
- describe 'get create' do
- subject do
- get :create, params: { user: { email: 'test2@example.com', password: 'abcdefgh' } }
- end
- it 'creates a user' do
- subject
- expect(User.where(email: 'test2@example.com').size).to eql(1)
- end
- it 'redirects to /welcome' do
- subject
- expect(subject).to redirect_to('/welcome')
- end
- end
- describe 'get password_recovery_request_form' do
- subject { get :password_recovery_request_form }
- it 'renders the users/password_recovery_request_form template' do
- expect(subject).to render_template('users/password_recovery_request_form')
- end
- end
- describe 'post password_recovery_request' do
- subject do
- get :password_recovery_request, params: { email: user1.email }
- end
- it 'sends the proper recovery email' do
- srand(10)
- subject
- email_text = ActionMailer::Base.deliveries.last.body.raw_source
- expect(email_text).to match("recover_password/#{user1.id}/jeravuxl")
- end
- it 'sends a recovery email to the proper email' do
- subject
- expect(ActionMailer::Base.deliveries.last.to).to eql([user1.email])
- end
- it 'flashes a notice' do
- subject
- expect(subject.request.flash[:notice]).to match("Recovery email sent to #{user1.email}")
- end
- end
- describe 'get recover_password_form' do
- subject do
- get :recover_password_form, params: { id: user1.id, recovery_password: 'recovery password' }
- end
- it 'renders proper form' do
- subject
- expect(subject).to render_template('users/recover_password_form')
- end
- end
- describe 'post recover_password' do
- context 'when passwords match and recovery password is proper' do
- subject do
- post :recover_password, params: {
- user_id: user1.id,
- recovery_password: 'recovery password',
- password: 'new password',
- password_confirmation: 'new password'
- }
- end
- it 'flashes a notice about success' do
- subject
- expect(subject.request.flash[:notice]).to match('Password changed')
- end
- end
- context 'when recovery password is inproper' do
- subject do
- post :recover_password, params: {
- user_id: user1.id,
- recovery_password: 'improper recovery password',
- password: 'new password',
- password_confirmation: 'new password'
- }
- end
- it 'flashes a notice about failure' do
- subject
- expect(subject.request.flash[:notice]).to match('Recovery link expired or invalid')
- end
- end
- context 'when passwords match and recovery password is improper' do
- subject do
- post :recover_password, params: {
- user_id: user1.id,
- recovery_password: 'recovery password',
- password: 'new password',
- password_confirmation: 'bad password'
- }
- end
- it 'flashes a notice about failure' do
- subject
- expect(subject.request.flash[:notice]).to match('Passwords don\'t match')
- end
- end
- end
- describe 'delete destroy' do
- context 'when admin is logged in' do
- it 'deletes the user' do
- # TODO
- end
- end
- end
-end
diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb
deleted file mode 100644
index b8ce9ed..0000000
--- a/spec/mailers/previews/user_mailer_preview.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-# Preview all emails at http://localhost:3000/rails/mailers/user
-class UserMailerPreview < ActionMailer::Preview
-end
diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb
deleted file mode 100644
index ca6cf07..0000000
--- a/spec/mailers/user_mailer_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-RSpec.describe UserMailer, type: :mailer do
- # TODO
-end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
deleted file mode 100644
index edf8b47..0000000
--- a/spec/rails_helper.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: true
-
-# This file is copied to spec/ when you run 'rails generate rspec:install'
-require 'spec_helper'
-ENV['RAILS_ENV'] ||= 'test'
-require File.expand_path('../config/environment', __dir__)
-# Prevent database truncation if the environment is production
-abort('The Rails environment is running in production mode!') if Rails.env.production?
-require 'rspec/rails'
-# Add additional requires below this line. Rails is not loaded until this point!
-
-# Requires supporting ruby files with custom matchers and macros, etc, in
-# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
-# run as spec files by default. This means that files in spec/support that end
-# in _spec.rb will both be required and run as specs, causing the specs to be
-# run twice. It is recommended that you do not name files matching this glob to
-# end with _spec.rb. You can configure this pattern with the --pattern
-# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
-#
-# The following line is provided for convenience purposes. It has the downside
-# of increasing the boot-up time by auto-requiring all files in the support
-# directory. Alternatively, in the individual `*_spec.rb` files, manually
-# require only the support files necessary.
-#
-# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
-
-# Checks for pending migrations and applies them before tests are run.
-# If you are not using ActiveRecord, you can remove these lines.
-begin
- ActiveRecord::Migration.maintain_test_schema!
-rescue ActiveRecord::PendingMigrationError => e
- puts e.to_s.strip
- exit 1
-end
-RSpec.configure do |config|
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = true
-
- # You can uncomment this line to turn off ActiveRecord support entirely.
- # config.use_active_record = false
-
- # RSpec Rails can automatically mix in different behaviours to your tests
- # based on their file location, for example enabling you to call `get` and
- # `post` in specs under `spec/controllers`.
- #
- # You can disable this behaviour by removing the line below, and instead
- # explicitly tag your specs with their type, e.g.:
- #
- # RSpec.describe UsersController, type: :controller do
- # # ...
- # end
- #
- # The different available types are documented in the features, such as in
- # https://relishapp.com/rspec/rspec-rails/docs
- config.infer_spec_type_from_file_location!
-
- # Filter lines from Rails gems in backtraces.
- config.filter_rails_from_backtrace!
- # arbitrary gems may also be filtered via:
- # config.filter_gems_from_backtrace("gem name")
-end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
deleted file mode 100644
index 01f7c97..0000000
--- a/spec/spec_helper.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-# 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
-# this file to always be loaded, without a need to explicitly require it in any
-# files.
-#
-# Given that it is always loaded, you are encouraged to keep this file as
-# light-weight as possible. Requiring heavyweight dependencies from this file
-# will add to the boot time of your test suite on EVERY test run, even for an
-# individual file that may not need all of that loaded. Instead, consider making
-# a separate helper file that requires the additional dependencies and performs
-# the additional setup, and require it from the spec files that actually need
-# it.
-#
-# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
-RSpec.configure do |config|
- # rspec-expectations config goes here. You can use an alternate
- # assertion/expectation library such as wrong or the stdlib/minitest
- # assertions if you prefer.
- config.expect_with :rspec do |expectations|
- # This option will default to `true` in RSpec 4. It makes the `description`
- # and `failure_message` of custom matchers include text for helper methods
- # defined using `chain`, e.g.:
- # be_bigger_than(2).and_smaller_than(4).description
- # # => "be bigger than 2 and smaller than 4"
- # ...rather than:
- # # => "be bigger than 2"
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
- end
-
- # rspec-mocks config goes here. You can use an alternate test double
- # library (such as bogus or mocha) by changing the `mock_with` option here.
- config.mock_with :rspec do |mocks|
- # Prevents you from mocking or stubbing a method that does not exist on
- # a real object. This is generally recommended, and will default to
- # `true` in RSpec 4.
- mocks.verify_partial_doubles = true
- end
-
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
- # have no way to turn it off -- the option exists only for backwards
- # compatibility in RSpec 3). It causes shared context metadata to be
- # inherited by the metadata hash of host groups and examples, rather than
- # 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.
- # # This allows you to limit a spec run to individual examples or groups
- # # you care about by tagging them with `:focus` metadata. When nothing
- # # is tagged with `:focus`, all examples get run. RSpec also provides
- # # aliases for `it`, `describe`, and `context` that include `:focus`
- # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
- # config.filter_run_when_matching :focus
- #
- # # 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"
- #
- # # Limits the available syntax to the non-monkey patched syntax that is
- # # recommended. For more details, see:
- # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
- # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
- # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
- # config.disable_monkey_patching!
- #
- # # Many RSpec users commonly either run the entire suite or an individual
- # # file, and it's useful to allow more verbose output when running an
- # # individual spec file.
- # if config.files_to_run.one?
- # # Use the documentation formatter for detailed output,
- # # unless a formatter has already been configured
- # # (e.g. via a command-line flag).
- # config.default_formatter = "doc"
- # end
- #
- # # 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
- #
- # # 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
- # # the seed, which is printed after each run.
- # # --seed 1234
- # config.order = :random
- #
- # # Seed global randomization in this process using the `--seed` CLI option.
- # # Setting this allows you to use `--seed` to deterministically reproduce
- # # test failures related to randomization by passing the same `--seed` value
- # # as the one that triggered the failure.
- # Kernel.srand config.seed
-end
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
new file mode 100644
index 0000000..d19212a
--- /dev/null
+++ b/test/application_system_test_case.rb
@@ -0,0 +1,5 @@
+require "test_helper"
+
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
+end
diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb
new file mode 100644
index 0000000..800405f
--- /dev/null
+++ b/test/channels/application_cable/connection_test.rb
@@ -0,0 +1,11 @@
+require "test_helper"
+
+class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
+ # test "connects with cookies" do
+ # cookies.signed[:user_id] = 42
+ #
+ # connect
+ #
+ # assert_equal connection.user_id, "42"
+ # end
+end
diff --git a/test/controllers/.keep b/test/controllers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/controllers/books_controller_test.rb b/test/controllers/books_controller_test.rb
new file mode 100644
index 0000000..3927d43
--- /dev/null
+++ b/test/controllers/books_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class BooksControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/fixtures/authors.yml b/test/fixtures/authors.yml
new file mode 100644
index 0000000..5181636
--- /dev/null
+++ b/test/fixtures/authors.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/book_authors.yml b/test/fixtures/book_authors.yml
new file mode 100644
index 0000000..5181636
--- /dev/null
+++ b/test/fixtures/book_authors.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/books.yml b/test/fixtures/books.yml
new file mode 100644
index 0000000..5181636
--- /dev/null
+++ b/test/fixtures/books.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/integration/.keep b/test/integration/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/mailers/.keep b/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/models/.keep b/test/models/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/models/author_test.rb b/test/models/author_test.rb
new file mode 100644
index 0000000..b2d7df1
--- /dev/null
+++ b/test/models/author_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class AuthorTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/book_author_test.rb b/test/models/book_author_test.rb
new file mode 100644
index 0000000..b308c05
--- /dev/null
+++ b/test/models/book_author_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class BookAuthorTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/book_test.rb b/test/models/book_test.rb
new file mode 100644
index 0000000..69ab9de
--- /dev/null
+++ b/test/models/book_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class BookTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/system/.keep b/test/system/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..47b598d
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV['RAILS_ENV'] ||= 'test'
+require_relative "../config/environment"
+require "rails/test_help"
+
+class ActiveSupport::TestCase
+ # Run tests in parallel with specified workers
+ parallelize(workers: :number_of_processors)
+
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end