100 |
101 |
102 |
103 | ## 🔭 Future Features
104 |
105 | Features will be added to the project.
106 |
107 | - User Login Interface
108 | - User comments and like history
109 | - Report of inividual user
110 |
111 |
122 |
123 |
124 |
125 | ## ⭐️ Show your support
126 |
127 | If you like this project, show your support by giving a star ⭐️, thanks in advance.
128 |
129 |
45 | <%= f.label :current_password %> (we need your current password to confirm your changes)
46 | <%= f.password_field :current_password, autocomplete: "current-password" %>
47 |
48 |
49 |
50 | <%= f.submit "Update" %>
51 |
52 | <% end %>
53 |
54 |
Cancel my account
55 |
56 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %>
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'bundle' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "rubygems"
12 |
13 | m = Module.new do
14 | module_function
15 |
16 | def invoked_as_script?
17 | File.expand_path($0) == File.expand_path(__FILE__)
18 | end
19 |
20 | def env_var_version
21 | ENV["BUNDLER_VERSION"]
22 | end
23 |
24 | def cli_arg_version
25 | return unless invoked_as_script? # don't want to hijack other binstubs
26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27 | bundler_version = nil
28 | update_index = nil
29 | ARGV.each_with_index do |a, i|
30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31 | bundler_version = a
32 | end
33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34 | bundler_version = $1
35 | update_index = i
36 | end
37 | bundler_version
38 | end
39 |
40 | def gemfile
41 | gemfile = ENV["BUNDLE_GEMFILE"]
42 | return gemfile if gemfile && !gemfile.empty?
43 |
44 | File.expand_path("../Gemfile", __dir__)
45 | end
46 |
47 | def lockfile
48 | lockfile =
49 | case File.basename(gemfile)
50 | when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
51 | else "#{gemfile}.lock"
52 | end
53 | File.expand_path(lockfile)
54 | end
55 |
56 | def lockfile_version
57 | return unless File.file?(lockfile)
58 | lockfile_contents = File.read(lockfile)
59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60 | Regexp.last_match(1)
61 | end
62 |
63 | def bundler_requirement
64 | @bundler_requirement ||=
65 | env_var_version ||
66 | cli_arg_version ||
67 | bundler_requirement_for(lockfile_version)
68 | end
69 |
70 | def bundler_requirement_for(version)
71 | return "#{Gem::Requirement.default}.a" unless version
72 |
73 | bundler_gem_version = Gem::Version.new(version)
74 |
75 | bundler_gem_version.approximate_recommendation
76 | end
77 |
78 | def load_bundler!
79 | ENV["BUNDLE_GEMFILE"] ||= gemfile
80 |
81 | activate_bundler
82 | end
83 |
84 | def activate_bundler
85 | gem_error = activation_error_handling do
86 | gem "bundler", bundler_requirement
87 | end
88 | return if gem_error.nil?
89 | require_error = activation_error_handling do
90 | require "bundler/version"
91 | end
92 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
93 | 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}'`"
94 | exit 42
95 | end
96 |
97 | def activation_error_handling
98 | yield
99 | nil
100 | rescue StandardError, LoadError => e
101 | e
102 | end
103 | end
104 |
105 | m.load_bundler!
106 |
107 | if m.invoked_as_script?
108 | load Gem.bin_path("bundler", "bundle")
109 | end
110 |
--------------------------------------------------------------------------------
/bin/bundle.cmd:
--------------------------------------------------------------------------------
1 | @ruby -x "%~f0" %*
2 | @exit /b %ERRORLEVEL%
3 |
4 | #!/usr/bin/env ruby
5 | # frozen_string_literal: true
6 |
7 | #
8 | # This file was generated by Bundler.
9 | #
10 | # The application 'bundle' is installed as part of a gem, and
11 | # this file is here to facilitate running it.
12 | #
13 |
14 | require "rubygems"
15 |
16 | m = Module.new do
17 | module_function
18 |
19 | def invoked_as_script?
20 | File.expand_path($0) == File.expand_path(__FILE__)
21 | end
22 |
23 | def env_var_version
24 | ENV["BUNDLER_VERSION"]
25 | end
26 |
27 | def cli_arg_version
28 | return unless invoked_as_script? # don't want to hijack other binstubs
29 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
30 | bundler_version = nil
31 | update_index = nil
32 | ARGV.each_with_index do |a, i|
33 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
34 | bundler_version = a
35 | end
36 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
37 | bundler_version = $1
38 | update_index = i
39 | end
40 | bundler_version
41 | end
42 |
43 | def gemfile
44 | gemfile = ENV["BUNDLE_GEMFILE"]
45 | return gemfile if gemfile && !gemfile.empty?
46 |
47 | File.expand_path("../Gemfile", __dir__)
48 | end
49 |
50 | def lockfile
51 | lockfile =
52 | case File.basename(gemfile)
53 | when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
54 | else "#{gemfile}.lock"
55 | end
56 | File.expand_path(lockfile)
57 | end
58 |
59 | def lockfile_version
60 | return unless File.file?(lockfile)
61 | lockfile_contents = File.read(lockfile)
62 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
63 | Regexp.last_match(1)
64 | end
65 |
66 | def bundler_requirement
67 | @bundler_requirement ||=
68 | env_var_version ||
69 | cli_arg_version ||
70 | bundler_requirement_for(lockfile_version)
71 | end
72 |
73 | def bundler_requirement_for(version)
74 | return "#{Gem::Requirement.default}.a" unless version
75 |
76 | bundler_gem_version = Gem::Version.new(version)
77 |
78 | bundler_gem_version.approximate_recommendation
79 | end
80 |
81 | def load_bundler!
82 | ENV["BUNDLE_GEMFILE"] ||= gemfile
83 |
84 | activate_bundler
85 | end
86 |
87 | def activate_bundler
88 | gem_error = activation_error_handling do
89 | gem "bundler", bundler_requirement
90 | end
91 | return if gem_error.nil?
92 | require_error = activation_error_handling do
93 | require "bundler/version"
94 | end
95 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
96 | 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}'`"
97 | exit 42
98 | end
99 |
100 | def activation_error_handling
101 | yield
102 | nil
103 | rescue StandardError, LoadError => e
104 | e
105 | end
106 | end
107 |
108 | m.load_bundler!
109 |
110 | if m.invoked_as_script?
111 | load Gem.bin_path("bundler", "bundle")
112 | end
113 |
--------------------------------------------------------------------------------
/bin/importmap:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require_relative "../config/application"
4 | require "importmap/commands"
5 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby.exe
2 | APP_PATH = File.expand_path("../config/application", __dir__)
3 | require_relative "../config/boot"
4 | require "rails/commands"
5 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby.exe
2 | require_relative "../config/boot"
3 | require "rake"
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby.exe
2 | require "fileutils"
3 |
4 | # path to your application root.
5 | APP_ROOT = File.expand_path("..", __dir__)
6 |
7 | def system!(*args)
8 | system(*args) || abort("\n== Command #{args} failed ==")
9 | end
10 |
11 | FileUtils.chdir APP_ROOT do
12 | # This script is a way to set up or update your development environment automatically.
13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14 | # Add necessary setup steps to this file.
15 |
16 | puts "== Installing dependencies =="
17 | system! "gem install bundler --conservative"
18 | system("bundle check") || system!("bundle install")
19 |
20 | # puts "\n== Copying sample files =="
21 | # unless File.exist?("config/database.yml")
22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23 | # end
24 |
25 | puts "\n== Preparing database =="
26 | system! "bin/rails db:prepare"
27 |
28 | puts "\n== Removing old logs and tempfiles =="
29 | system! "bin/rails log:clear tmp:clear"
30 |
31 | puts "\n== Restarting application server =="
32 | system! "bin/rails restart"
33 | end
34 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative 'config/environment'
4 |
5 | run Rails.application
6 | Rails.application.load_server
7 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative "boot"
2 |
3 | require "rails/all"
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module BlogApp
10 | class Application < Rails::Application
11 | # Initialize configuration defaults for originally generated Rails version.
12 | config.load_defaults 7.0
13 |
14 | # Configuration for the application, engines, and railties goes here.
15 | #
16 | # These settings can be overridden in specific environments using the files
17 | # in config/environments, which are processed later.
18 | #
19 | # config.time_zone = "Central Time (US & Canada)"
20 | # config.eager_load_paths << Rails.root.join("extras")
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2 |
3 | require "bundler/setup" # Set up gems listed in the Gemfile.
4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations.
5 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: test
6 |
7 | production:
8 | adapter: redis
9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10 | channel_prefix: blog_app_production
11 |
--------------------------------------------------------------------------------
/config/credentials.yml.enc:
--------------------------------------------------------------------------------
1 | jQb40HF/QZlHrTs1I8Y2nHkSobsSD/juncHWmktz6hzraS1v8MCS3B0pfVI4FyCWMmNJ45iCsj5x6aPHkc1QhRCc7HwLhn7e5stIivQgAn7PxttvIiB6D5++lbdK3BZG5yzwx/MEz9Li/Fcp4pBqyCoLab5rL/6tCz/Vind/nf78cnXz8hsIhlyc6lPSscU2fJQERMT44gHz4yQv7zB3e46aBuCfpat/Euv6aco1MUO3jcxNIhloNCZ76dpcPOEDLx2imOev+bF8yAmOfLzVCoQv58U6YMnFNqjZYOFzeVB1wQTCR0ZspjjcXL5iNwJF9Fo7w+Oot06lLARJ/78o7+xvdmFbGMM0cOUS2DJEhXmUOpOwu2uxtsfQ/dLYxtdxfVO/7h42fdhWGHWJOysEYDqKuQ9m10khIJxE--+/D6vtcF6Ko21YiC--5Kb745rYVjtWaSEY5Zmh0Q==
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | default: &default
2 | adapter: postgresql
3 | encoding: unicode
4 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
5 |
6 | development:
7 | <<: *default
8 | database: blog_app_development
9 | username: postgres
10 | password: postgre1990
11 |
12 | test:
13 | <<: *default
14 | database: blog_app_test
15 | username: postgres
16 | password: postgre1990
17 |
18 | production:
19 | <<: *default
20 | database: blog_app_production
21 | username: blog_app
22 | password: <%= ENV["BLOG_APP_DATABASE_PASSWORD"] %>
23 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative "application"
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # In the development environment your application's code is reloaded any time
7 | # it changes. This slows down response time but is perfect for development
8 | # since you don't have to restart the web server when you make code changes.
9 | config.cache_classes = false
10 |
11 | # Do not eager load code on boot.
12 | config.eager_load = false
13 |
14 | # Show full error reports.
15 | config.consider_all_requests_local = true
16 |
17 | # Enable server timing
18 | config.server_timing = true
19 |
20 | # Enable/disable caching. By default caching is disabled.
21 | # Run rails dev:cache to toggle caching.
22 | if Rails.root.join("tmp/caching-dev.txt").exist?
23 | config.action_controller.perform_caching = true
24 | config.action_controller.enable_fragment_cache_logging = true
25 |
26 | config.cache_store = :memory_store
27 | config.public_file_server.headers = {
28 | "Cache-Control" => "public, max-age=#{2.days.to_i}"
29 | }
30 | else
31 | config.action_controller.perform_caching = false
32 |
33 | config.cache_store = :null_store
34 | end
35 |
36 | # Store uploaded files on the local file system (see config/storage.yml for options).
37 | config.active_storage.service = :local
38 |
39 | # Don't care if the mailer can't send.
40 | config.action_mailer.raise_delivery_errors = false
41 |
42 | config.action_mailer.perform_caching = false
43 |
44 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
45 |
46 | # Print deprecation notices to the Rails logger.
47 | config.active_support.deprecation = :log
48 |
49 | # Raise exceptions for disallowed deprecations.
50 | config.active_support.disallowed_deprecation = :raise
51 |
52 | # Tell Active Support which deprecation messages to disallow.
53 | config.active_support.disallowed_deprecation_warnings = []
54 |
55 | # Raise an error on page load if there are pending migrations.
56 | config.active_record.migration_error = :page_load
57 |
58 | # Highlight code that triggered database queries in logs.
59 | config.active_record.verbose_query_logs = true
60 |
61 | # Suppress logger output for asset requests.
62 | config.assets.quiet = true
63 |
64 | # Raises error for missing translations.
65 | # config.i18n.raise_on_missing_translations = true
66 |
67 | # Annotate rendered view with file names.
68 | # config.action_view.annotate_rendered_view_with_filenames = true
69 |
70 | # Uncomment if you wish to allow Action Cable access from any origin.
71 | # config.action_cable.disable_request_forgery_protection = true
72 | end
73 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # Code is not reloaded between requests.
7 | config.cache_classes = true
8 |
9 | # Eager load code on boot. This eager loads most of Rails and
10 | # your application in memory, allowing both threaded web servers
11 | # and those relying on copy on write to perform better.
12 | # Rake tasks automatically ignore this option for performance.
13 | config.eager_load = true
14 |
15 | # Full error reports are disabled and caching is turned on.
16 | config.consider_all_requests_local = false
17 | config.action_controller.perform_caching = true
18 |
19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21 | # config.require_master_key = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
26 |
27 | # Compress CSS using a preprocessor.
28 | # config.assets.css_compressor = :sass
29 |
30 | # Do not fallback to assets pipeline if a precompiled asset is missed.
31 | config.assets.compile = false
32 |
33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
34 | # config.asset_host = "http://assets.example.com"
35 |
36 | # Specifies the header that your server uses for sending files.
37 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
38 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
39 |
40 | # Store uploaded files on the local file system (see config/storage.yml for options).
41 | config.active_storage.service = :local
42 |
43 | # Mount Action Cable outside main process or domain.
44 | # config.action_cable.mount_path = nil
45 | # config.action_cable.url = "wss://example.com/cable"
46 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
47 |
48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
49 | # config.force_ssl = true
50 |
51 | # Include generic and useful information about system operation, but avoid logging too much
52 | # information to avoid inadvertent exposure of personally identifiable information (PII).
53 | config.log_level = :info
54 |
55 | # Prepend all log lines with the following tags.
56 | config.log_tags = [ :request_id ]
57 |
58 | # Use a different cache store in production.
59 | # config.cache_store = :mem_cache_store
60 |
61 | # Use a real queuing backend for Active Job (and separate queues per environment).
62 | # config.active_job.queue_adapter = :resque
63 | # config.active_job.queue_name_prefix = "blog_app_production"
64 |
65 | config.action_mailer.perform_caching = false
66 |
67 | # Ignore bad email addresses and do not raise email delivery errors.
68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
69 | # config.action_mailer.raise_delivery_errors = false
70 |
71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
72 | # the I18n.default_locale when a translation cannot be found).
73 | config.i18n.fallbacks = true
74 |
75 | # Don't log any deprecations.
76 | config.active_support.report_deprecations = false
77 |
78 | # Use default logging formatter so that PID and timestamp are not suppressed.
79 | config.log_formatter = ::Logger::Formatter.new
80 |
81 | # Use a different logger for distributed setups.
82 | # require "syslog/logger"
83 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
84 |
85 | if ENV["RAILS_LOG_TO_STDOUT"].present?
86 | logger = ActiveSupport::Logger.new(STDOUT)
87 | logger.formatter = config.log_formatter
88 | config.logger = ActiveSupport::TaggedLogging.new(logger)
89 | end
90 |
91 | # Do not dump schema after migrations.
92 | config.active_record.dump_schema_after_migration = false
93 | end
94 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | # The test environment is used exclusively to run your application's
4 | # test suite. You never need to work with it otherwise. Remember that
5 | # your test database is "scratch space" for the test suite and is wiped
6 | # and recreated between test runs. Don't rely on the data there!
7 |
8 | Rails.application.configure do
9 | # Settings specified here will take precedence over those in config/application.rb.
10 |
11 | # Turn false under Spring and add config.action_view.cache_template_loading = true.
12 | config.cache_classes = true
13 |
14 | # Eager loading loads your whole application. When running a single test locally,
15 | # this probably isn't necessary. It's a good idea to do in a continuous integration
16 | # system, or in some way before deploying your code.
17 | config.eager_load = ENV["CI"].present?
18 |
19 | # Configure public file server for tests with Cache-Control for performance.
20 | config.public_file_server.enabled = true
21 | config.public_file_server.headers = {
22 | "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23 | }
24 |
25 | # Show full error reports and disable caching.
26 | config.consider_all_requests_local = true
27 | config.action_controller.perform_caching = false
28 | config.cache_store = :null_store
29 |
30 | # Raise exceptions instead of rendering exception templates.
31 | config.action_dispatch.show_exceptions = false
32 |
33 | # Disable request forgery protection in test environment.
34 | config.action_controller.allow_forgery_protection = false
35 |
36 | # Store uploaded files on the local file system in a temporary directory.
37 | config.active_storage.service = :test
38 |
39 | config.action_mailer.perform_caching = false
40 |
41 | # Tell Action Mailer not to deliver emails to the real world.
42 | # The :test delivery method accumulates sent emails in the
43 | # ActionMailer::Base.deliveries array.
44 | config.action_mailer.delivery_method = :test
45 |
46 | # Print deprecation notices to the stderr.
47 | config.active_support.deprecation = :stderr
48 |
49 | # Raise exceptions for disallowed deprecations.
50 | config.active_support.disallowed_deprecation = :raise
51 |
52 | # Tell Active Support which deprecation messages to disallow.
53 | config.active_support.disallowed_deprecation_warnings = []
54 |
55 | # Raises error for missing translations.
56 | # config.i18n.raise_on_missing_translations = true
57 |
58 | # Annotate rendered view with file names.
59 | # config.action_view.annotate_rendered_view_with_filenames = true
60 | end
61 |
--------------------------------------------------------------------------------
/config/importmap.rb:
--------------------------------------------------------------------------------
1 | # Pin npm packages by running ./bin/importmap
2 |
3 | pin "application", preload: true
4 | pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
5 | pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
6 | pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
7 | pin_all_from "app/javascript/controllers", under: "controllers"
8 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = "1.0"
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in the app/assets
11 | # folder are already added.
12 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
13 |
--------------------------------------------------------------------------------
/config/initializers/content_security_policy.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Define an application-wide content security policy.
4 | # See the Securing Rails Applications Guide for more information:
5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header
6 |
7 | # Rails.application.configure do
8 | # config.content_security_policy do |policy|
9 | # policy.default_src :self, :https
10 | # policy.font_src :self, :https, :data
11 | # policy.img_src :self, :https, :data
12 | # policy.object_src :none
13 | # policy.script_src :self, :https
14 | # policy.style_src :self, :https
15 | # # Specify URI for violation reports
16 | # # policy.report_uri "/csp-violation-report-endpoint"
17 | # end
18 | #
19 | # # Generate session nonces for permitted importmap and inline scripts
20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21 | # config.content_security_policy_nonce_directives = %w(script-src)
22 | #
23 | # # Report violations without enforcing the policy.
24 | # # config.content_security_policy_report_only = true
25 | # end
26 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Assuming you have not yet modified this file, each configuration option below
4 | # is set to its default value. Note that some are commented out while others
5 | # are not: uncommented lines are intended to protect your configuration from
6 | # breaking changes in upgrades (i.e., in the event that future versions of
7 | # Devise change the default values for those options).
8 | #
9 | # Use this hook to configure devise mailer, warden hooks and so forth.
10 | # Many of these configuration options can be set straight in your model.
11 | Devise.setup do |config|
12 | # The secret key used by Devise. Devise uses this key to generate
13 | # random tokens. Changing this key will render invalid all existing
14 | # confirmation, reset password and unlock tokens in the database.
15 | # Devise will use the `secret_key_base` as its `secret_key`
16 | # by default. You can change it below and use your own secret key.
17 | # config.secret_key = 'c1ac2bbb9fe7964d3412ba17b71a05260254e0637395666fe41ab7a9490ff2407cebd65cb5903b13d760669da4200713b979ad47f7d4a02c3f288291839c06a8'
18 |
19 | # ==> Controller configuration
20 | # Configure the parent class to the devise controllers.
21 | # config.parent_controller = 'DeviseController'
22 |
23 | # ==> Mailer Configuration
24 | # Configure the e-mail address which will be shown in Devise::Mailer,
25 | # note that it will be overwritten if you use your own mailer class
26 | # with default "from" parameter.
27 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28 |
29 | # Configure the class responsible to send e-mails.
30 | # config.mailer = 'Devise::Mailer'
31 |
32 | # Configure the parent class responsible to send e-mails.
33 | # config.parent_mailer = 'ActionMailer::Base'
34 |
35 | # ==> ORM configuration
36 | # Load and configure the ORM. Supports :active_record (default) and
37 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
38 | # available as additional gems.
39 | require 'devise/orm/active_record'
40 |
41 | # ==> Configuration for any authentication mechanism
42 | # Configure which keys are used when authenticating a user. The default is
43 | # just :email. You can configure it to use [:username, :subdomain], so for
44 | # authenticating a user, both parameters are required. Remember that those
45 | # parameters are used only when authenticating and not when retrieving from
46 | # session. If you need permissions, you should implement that in a before filter.
47 | # You can also supply a hash where the value is a boolean determining whether
48 | # or not authentication should be aborted when the value is not present.
49 | # config.authentication_keys = [:email]
50 |
51 | # Configure parameters from the request object used for authentication. Each entry
52 | # given should be a request method and it will automatically be passed to the
53 | # find_for_authentication method and considered in your model lookup. For instance,
54 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55 | # The same considerations mentioned for authentication_keys also apply to request_keys.
56 | # config.request_keys = []
57 |
58 | # Configure which authentication keys should be case-insensitive.
59 | # These keys will be downcased upon creating or modifying a user and when used
60 | # to authenticate or find a user. Default is :email.
61 | config.case_insensitive_keys = [:email]
62 |
63 | # Configure which authentication keys should have whitespace stripped.
64 | # These keys will have whitespace before and after removed upon creating or
65 | # modifying a user and when used to authenticate or find a user. Default is :email.
66 | config.strip_whitespace_keys = [:email]
67 |
68 | # Tell if authentication through request.params is enabled. True by default.
69 | # It can be set to an array that will enable params authentication only for the
70 | # given strategies, for example, `config.params_authenticatable = [:database]` will
71 | # enable it only for database (email + password) authentication.
72 | # config.params_authenticatable = true
73 |
74 | # Tell if authentication through HTTP Auth is enabled. False by default.
75 | # It can be set to an array that will enable http authentication only for the
76 | # given strategies, for example, `config.http_authenticatable = [:database]` will
77 | # enable it only for database authentication.
78 | # For API-only applications to support authentication "out-of-the-box", you will likely want to
79 | # enable this with :database unless you are using a custom strategy.
80 | # The supported strategies are:
81 | # :database = Support basic authentication with authentication key + password
82 | # config.http_authenticatable = false
83 |
84 | # If 401 status code should be returned for AJAX requests. True by default.
85 | # config.http_authenticatable_on_xhr = true
86 |
87 | # The realm used in Http Basic Authentication. 'Application' by default.
88 | # config.http_authentication_realm = 'Application'
89 |
90 | # It will change confirmation, password recovery and other workflows
91 | # to behave the same regardless if the e-mail provided was right or wrong.
92 | # Does not affect registerable.
93 | # config.paranoid = true
94 |
95 | # By default Devise will store the user in session. You can skip storage for
96 | # particular strategies by setting this option.
97 | # Notice that if you are skipping storage for all authentication paths, you
98 | # may want to disable generating routes to Devise's sessions controller by
99 | # passing skip: :sessions to `devise_for` in your config/routes.rb
100 | config.skip_session_storage = [:http_auth]
101 |
102 | # By default, Devise cleans up the CSRF token on authentication to
103 | # avoid CSRF token fixation attacks. This means that, when using AJAX
104 | # requests for sign in and sign up, you need to get a new CSRF token
105 | # from the server. You can disable this option at your own risk.
106 | # config.clean_up_csrf_token_on_authentication = true
107 |
108 | # When false, Devise will not attempt to reload routes on eager load.
109 | # This can reduce the time taken to boot the app but if your application
110 | # requires the Devise mappings to be loaded during boot time the application
111 | # won't boot properly.
112 | # config.reload_routes = true
113 |
114 | # ==> Configuration for :database_authenticatable
115 | # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116 | # using other algorithms, it sets how many times you want the password to be hashed.
117 | # The number of stretches used for generating the hashed password are stored
118 | # with the hashed password. This allows you to change the stretches without
119 | # invalidating existing passwords.
120 | #
121 | # Limiting the stretches to just one in testing will increase the performance of
122 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123 | # a value less than 10 in other environments. Note that, for bcrypt (the default
124 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
125 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126 | config.stretches = Rails.env.test? ? 1 : 12
127 |
128 | # Set up a pepper to generate the hashed password.
129 | # config.pepper = '2c0f30f5dfb430e483e9cc486d2070b2503d048172e855cd9618be3165b1c0462ff473ac0c88f6ab35923db96fc701f160f595a224c8294847cab901849d94c2'
130 |
131 | # Send a notification to the original email when the user's email is changed.
132 | # config.send_email_changed_notification = false
133 |
134 | # Send a notification email when the user's password is changed.
135 | # config.send_password_change_notification = false
136 |
137 | # ==> Configuration for :confirmable
138 | # A period that the user is allowed to access the website even without
139 | # confirming their account. For instance, if set to 2.days, the user will be
140 | # able to access the website for two days without confirming their account,
141 | # access will be blocked just in the third day.
142 | # You can also set it to nil, which will allow the user to access the website
143 | # without confirming their account.
144 | # Default is 0.days, meaning the user cannot access the website without
145 | # confirming their account.
146 | # config.allow_unconfirmed_access_for = 2.days
147 |
148 | # A period that the user is allowed to confirm their account before their
149 | # token becomes invalid. For example, if set to 3.days, the user can confirm
150 | # their account within 3 days after the mail was sent, but on the fourth day
151 | # their account can't be confirmed with the token any more.
152 | # Default is nil, meaning there is no restriction on how long a user can take
153 | # before confirming their account.
154 | # config.confirm_within = 3.days
155 |
156 | # If true, requires any email changes to be confirmed (exactly the same way as
157 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
158 | # db field (see migrations). Until confirmed, new email is stored in
159 | # unconfirmed_email column, and copied to email column on successful confirmation.
160 | config.reconfirmable = true
161 |
162 | # Defines which key will be used when confirming an account
163 | # config.confirmation_keys = [:email]
164 |
165 | # ==> Configuration for :rememberable
166 | # The time the user will be remembered without asking for credentials again.
167 | # config.remember_for = 2.weeks
168 |
169 | # Invalidates all the remember me tokens when the user signs out.
170 | config.expire_all_remember_me_on_sign_out = true
171 |
172 | # If true, extends the user's remember period when remembered via cookie.
173 | # config.extend_remember_period = false
174 |
175 | # Options to be passed to the created cookie. For instance, you can set
176 | # secure: true in order to force SSL only cookies.
177 | # config.rememberable_options = {}
178 |
179 | # ==> Configuration for :validatable
180 | # Range for password length.
181 | config.password_length = 6..128
182 |
183 | # Email regex used to validate email formats. It simply asserts that
184 | # one (and only one) @ exists in the given string. This is mainly
185 | # to give user feedback and not to assert the e-mail validity.
186 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187 |
188 | # ==> Configuration for :timeoutable
189 | # The time you want to timeout the user session without activity. After this
190 | # time the user will be asked for credentials again. Default is 30 minutes.
191 | # config.timeout_in = 30.minutes
192 |
193 | # ==> Configuration for :lockable
194 | # Defines which strategy will be used to lock an account.
195 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196 | # :none = No lock strategy. You should handle locking by yourself.
197 | # config.lock_strategy = :failed_attempts
198 |
199 | # Defines which key will be used when locking and unlocking an account
200 | # config.unlock_keys = [:email]
201 |
202 | # Defines which strategy will be used to unlock an account.
203 | # :email = Sends an unlock link to the user email
204 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205 | # :both = Enables both strategies
206 | # :none = No unlock strategy. You should handle unlocking by yourself.
207 | # config.unlock_strategy = :both
208 |
209 | # Number of authentication tries before locking an account if lock_strategy
210 | # is failed attempts.
211 | # config.maximum_attempts = 20
212 |
213 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
214 | # config.unlock_in = 1.hour
215 |
216 | # Warn on the last attempt before the account is locked.
217 | # config.last_attempt_warning = true
218 |
219 | # ==> Configuration for :recoverable
220 | #
221 | # Defines which key will be used when recovering the password for an account
222 | # config.reset_password_keys = [:email]
223 |
224 | # Time interval you can reset your password with a reset password key.
225 | # Don't put a too small interval or your users won't have the time to
226 | # change their passwords.
227 | config.reset_password_within = 6.hours
228 |
229 | # When set to false, does not sign a user in automatically after their password is
230 | # reset. Defaults to true, so a user is signed in automatically after a reset.
231 | # config.sign_in_after_reset_password = true
232 |
233 | # ==> Configuration for :encryptable
234 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
236 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237 | # for default behavior) and :restful_authentication_sha1 (then you should set
238 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239 | #
240 | # Require the `devise-encryptable` gem when using anything other than bcrypt
241 | # config.encryptor = :sha512
242 |
243 | # ==> Scopes configuration
244 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
245 | # "users/sessions/new". It's turned off by default because it's slower if you
246 | # are using only default views.
247 | # config.scoped_views = false
248 |
249 | # Configure the default scope given to Warden. By default it's the first
250 | # devise role declared in your routes (usually :user).
251 | # config.default_scope = :user
252 |
253 | # Set this configuration to false if you want /users/sign_out to sign out
254 | # only the current scope. By default, Devise signs out all scopes.
255 | # config.sign_out_all_scopes = true
256 |
257 | # ==> Navigation configuration
258 | # Lists the formats that should be treated as navigational. Formats like
259 | # :html should redirect to the sign in page when the user does not have
260 | # access, but formats like :xml or :json, should return 401.
261 | #
262 | # If you have any extra navigational formats, like :iphone or :mobile, you
263 | # should add them to the navigational formats lists.
264 | #
265 | # The "*/*" below is required to match Internet Explorer requests.
266 | # config.navigational_formats = ['*/*', :html, :turbo_stream]
267 |
268 | # The default HTTP method used to sign out a resource. Default is :delete.
269 | config.sign_out_via = :delete
270 |
271 | # ==> OmniAuth
272 | # Add a new OmniAuth provider. Check the wiki for more information on setting
273 | # up on your models and hooks.
274 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275 |
276 | # ==> Warden configuration
277 | # If you want to use other strategies, that are not supported by Devise, or
278 | # change the failure app, you can configure them inside the config.warden block.
279 | #
280 | # config.warden do |manager|
281 | # manager.intercept_401 = false
282 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
283 | # end
284 |
285 | # ==> Mountable engine configurations
286 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
287 | # is mountable, there are some extra configurations to be taken into account.
288 | # The following options are available, assuming the engine is mounted as:
289 | #
290 | # mount MyEngine, at: '/my_engine'
291 | #
292 | # The router that invoked `devise_for`, in the example above, would be:
293 | # config.router_name = :my_engine
294 | #
295 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
296 | # so you need to do it manually. For the users scope, it would be:
297 | # config.omniauth_path_prefix = '/my_engine/users/auth'
298 |
299 | # ==> Hotwire/Turbo configuration
300 | # When using Devise with Hotwire/Turbo, the http status for error responses
301 | # and some redirects must match the following. The default in Devise for existing
302 | # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
303 | # these new defaults that match Hotwire/Turbo behavior.
304 | # Note: These might become the new default in future versions of Devise.
305 | config.responder.error_status = :unprocessable_entity
306 | config.responder.redirect_status = :see_other
307 |
308 | # ==> Configuration for :registerable
309 |
310 | # When set to false, does not sign a user in automatically after their password is
311 | # changed. Defaults to true, so a user is signed in automatically after changing a password.
312 | # config.sign_in_after_change_password = true
313 | end
314 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5 | # notations and behaviors.
6 | Rails.application.config.filter_parameters += [
7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8 | ]
9 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, "\\1en"
8 | # inflect.singular /^(ox)en/i, "\\1"
9 | # inflect.irregular "person", "people"
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym "RESTful"
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/permissions_policy.rb:
--------------------------------------------------------------------------------
1 | # Define an application-wide HTTP permissions policy. For further
2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy
3 | #
4 | # Rails.application.config.permissions_policy do |f|
5 | # f.camera :none
6 | # f.gyroscope :none
7 | # f.microphone :none
8 | # f.usb :none
9 | # f.fullscreen :self
10 | # f.payment :self, "https://secure.example.com"
11 | # end
12 |
--------------------------------------------------------------------------------
/config/initializers/rswag_api.rb:
--------------------------------------------------------------------------------
1 | Rswag::Api.configure do |c|
2 |
3 | # Specify a root folder where Swagger JSON files are located
4 | # This is used by the Swagger middleware to serve requests for API descriptions
5 | # NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure
6 | # that it's configured to generate files in the same folder
7 | c.swagger_root = Rails.root.to_s + '/swagger'
8 |
9 | # Inject a lambda function to alter the returned Swagger prior to serialization
10 | # The function will have access to the rack env for the current request
11 | # For example, you could leverage this to dynamically assign the "host" property
12 | #
13 | #c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
14 | end
15 |
--------------------------------------------------------------------------------
/config/initializers/rswag_ui.rb:
--------------------------------------------------------------------------------
1 | Rswag::Ui.configure do |c|
2 |
3 | # List the Swagger endpoints that you want to be documented through the
4 | # swagger-ui. The first parameter is the path (absolute or relative to the UI
5 | # host) to the corresponding endpoint and the second is a title that will be
6 | # displayed in the document selector.
7 | # NOTE: If you're using rspec-api to expose Swagger files
8 | # (under swagger_root) as JSON or YAML endpoints, then the list below should
9 | # correspond to the relative paths for those endpoints.
10 |
11 | c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'API V1 Docs'
12 |
13 | # Add Basic Auth in case your API is private
14 | # c.basic_auth_enabled = true
15 | # c.basic_auth_credentials 'username', 'password'
16 | end
17 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your email address has been successfully confirmed."
7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9 | failure:
10 | already_authenticated: "You are already signed in."
11 | inactive: "Your account is not activated yet."
12 | invalid: "Invalid %{authentication_keys} or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account is locked."
15 | not_found_in_database: "Invalid %{authentication_keys} or password."
16 | timeout: "Your session expired. Please sign in again to continue."
17 | unauthenticated: "You need to sign in or sign up before continuing."
18 | unconfirmed: "You have to confirm your email address before continuing."
19 | mailer:
20 | confirmation_instructions:
21 | subject: "Confirmation instructions"
22 | reset_password_instructions:
23 | subject: "Reset password instructions"
24 | unlock_instructions:
25 | subject: "Unlock instructions"
26 | email_changed:
27 | subject: "Email Changed"
28 | password_change:
29 | subject: "Password Changed"
30 | omniauth_callbacks:
31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32 | success: "Successfully authenticated from %{kind} account."
33 | passwords:
34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37 | updated: "Your password has been changed successfully. You are now signed in."
38 | updated_not_active: "Your password has been changed successfully."
39 | registrations:
40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41 | signed_up: "Welcome! You have signed up successfully."
42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46 | updated: "Your account has been updated successfully."
47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
48 | sessions:
49 | signed_in: "Signed in successfully."
50 | signed_out: "Signed out successfully."
51 | already_signed_out: "Signed out successfully."
52 | unlocks:
53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56 | errors:
57 | messages:
58 | already_confirmed: "was already confirmed, please try signing in"
59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60 | expired: "has expired, please request a new one"
61 | not_found: "not found"
62 | not_locked: "was not locked"
63 | not_saved:
64 | one: "1 error prohibited this %{resource} from being saved:"
65 | other: "%{count} errors prohibited this %{resource} from being saved:"
66 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t "hello"
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t("hello") %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # "true": "foo"
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9 | threads min_threads_count, max_threads_count
10 |
11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
12 | # terminating a worker in development environments.
13 | #
14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15 |
16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17 | #
18 | port ENV.fetch("PORT") { 3000 }
19 |
20 | # Specifies the `environment` that Puma will run in.
21 | #
22 | environment ENV.fetch("RAILS_ENV") { "development" }
23 |
24 | # Specifies the `pidfile` that Puma will use.
25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26 |
27 | # Specifies the number of `workers` to boot in clustered mode.
28 | # Workers are forked web server processes. If using threads and workers together
29 | # the concurrency of the application would be max `threads` * `workers`.
30 | # Workers do not work on JRuby or Windows (both of which do not support
31 | # processes).
32 | #
33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34 |
35 | # Use the `preload_app!` method when specifying a `workers` number.
36 | # This directive tells Puma to first boot the application and load code
37 | # before forking the application. This takes advantage of Copy On Write
38 | # process behavior so workers use less memory.
39 | #
40 | # preload_app!
41 |
42 | # Allow puma to be restarted by `bin/rails restart` command.
43 | plugin :tmp_restart
44 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | mount Rswag::Ui::Engine => '/api-docs'
3 | mount Rswag::Api::Engine => '/api-docs'
4 | get '/sign_out_user', to: 'users#sign_out_user', as: 'sign_out_user'
5 | devise_for :users
6 | resources :users, only: [:index, :show] do
7 | resources :posts, only: [:index, :show, :new, :create, :destroy] do
8 | resources :comments, only: [:new, :create, :destroy]
9 | resources :likes, only: [:new, :create]
10 | end
11 | end
12 | root "users#index"
13 |
14 | namespace :api, default: {format: :json} do
15 | namespace :v1 do
16 | resources :users do
17 | resources :posts, only: [:index] do
18 | resources :comments, only: [:index, :create]
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/config/storage.yml:
--------------------------------------------------------------------------------
1 | test:
2 | service: Disk
3 | root: <%= Rails.root.join("tmp/storage") %>
4 |
5 | local:
6 | service: Disk
7 | root: <%= Rails.root.join("storage") %>
8 |
9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10 | # amazon:
11 | # service: S3
12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14 | # region: us-east-1
15 | # bucket: your_own_bucket-<%= Rails.env %>
16 |
17 | # Remember not to checkin your GCS keyfile to a repository
18 | # google:
19 | # service: GCS
20 | # project: your_project
21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22 | # bucket: your_own_bucket-<%= Rails.env %>
23 |
24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25 | # microsoft:
26 | # service: AzureStorage
27 | # storage_account_name: your_account_name
28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29 | # container: your_container_name-<%= Rails.env %>
30 |
31 | # mirror:
32 | # service: Mirror
33 | # primary: local
34 | # mirrors: [ amazon, google, microsoft ]
35 |
--------------------------------------------------------------------------------
/db/migrate/20231004120326_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :users do |t|
4 | t.string :name
5 | t.string :photo
6 | t.string :bio
7 | t.integer :post_counter
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20231004120403_create_posts.rb:
--------------------------------------------------------------------------------
1 | class CreatePosts < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :posts do |t|
4 | t.references :author, foreign_key: { to_table: :users }
5 | t.string :title
6 | t.string :text
7 | t.integer :comments_counter
8 | t.integer :likes_counter
9 |
10 | t.timestamps
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20231004120444_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :comments do |t|
4 | t.references :user, null: false, foreign_key: true
5 | t.references :post, null: false, foreign_key: true
6 | t.string :text
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20231004120510_create_likes.rb:
--------------------------------------------------------------------------------
1 | class CreateLikes < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :likes do |t|
4 | t.references :user, null: false, foreign_key: true
5 | t.references :post, null: false, foreign_key: true
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20231018201646_add_devise_to_users.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddDeviseToUsers < ActiveRecord::Migration[7.0]
4 | def self.up
5 | change_table :users do |t|
6 | ## Database authenticatable
7 | t.string :email, null: false, default: ""
8 | t.string :encrypted_password, null: false, default: ""
9 |
10 | ## Recoverable
11 | t.string :reset_password_token
12 | t.datetime :reset_password_sent_at
13 |
14 | ## Rememberable
15 | t.datetime :remember_created_at
16 |
17 | ## Trackable
18 | # t.integer :sign_in_count, default: 0, null: false
19 | # t.datetime :current_sign_in_at
20 | # t.datetime :last_sign_in_at
21 | # t.string :current_sign_in_ip
22 | # t.string :last_sign_in_ip
23 |
24 | # Confirmable
25 | t.string :confirmation_token
26 | t.datetime :confirmed_at
27 | t.datetime :confirmation_sent_at
28 | t.string :unconfirmed_email # Only if using reconfirmable
29 |
30 | ## Lockable
31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32 | # t.string :unlock_token # Only if unlock strategy is :email or :both
33 | # t.datetime :locked_at
34 |
35 |
36 | # Uncomment below if timestamps were not included in your original model.
37 | # t.timestamps null: false
38 | end
39 |
40 | add_index :users, :email, unique: true
41 | add_index :users, :reset_password_token, unique: true
42 | # add_index :users, :confirmation_token, unique: true
43 | # add_index :users, :unlock_token, unique: true
44 | end
45 |
46 | def self.down
47 | # By default, we don't want to make any assumption about how to roll back a migration when your
48 | # model already existed. Please edit below which fields you would like to remove in this migration.
49 | raise ActiveRecord::IrreversibleMigration
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/db/migrate/20231020201337_add_role_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddRoleToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :role, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # This file is the source Rails uses to define your schema when running `bin/rails
6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7 | # be faster and is potentially less error prone than running all of your
8 | # migrations from scratch. Old migrations may fail to apply correctly if those
9 | # migrations use external dependencies or application code.
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema[7.0].define(version: 2023_10_20_201337) do
14 | # These are extensions that must be enabled in order to support this database
15 | enable_extension "plpgsql"
16 |
17 | create_table "comments", force: :cascade do |t|
18 | t.bigint "user_id", null: false
19 | t.bigint "post_id", null: false
20 | t.string "text"
21 | t.datetime "created_at", null: false
22 | t.datetime "updated_at", null: false
23 | t.index ["post_id"], name: "index_comments_on_post_id"
24 | t.index ["user_id"], name: "index_comments_on_user_id"
25 | end
26 |
27 | create_table "likes", force: :cascade do |t|
28 | t.bigint "user_id", null: false
29 | t.bigint "post_id", null: false
30 | t.datetime "created_at", null: false
31 | t.datetime "updated_at", null: false
32 | t.index ["post_id"], name: "index_likes_on_post_id"
33 | t.index ["user_id"], name: "index_likes_on_user_id"
34 | end
35 |
36 | create_table "posts", force: :cascade do |t|
37 | t.bigint "author_id"
38 | t.string "title"
39 | t.string "text"
40 | t.integer "comments_counter"
41 | t.integer "likes_counter"
42 | t.datetime "created_at", null: false
43 | t.datetime "updated_at", null: false
44 | t.index ["author_id"], name: "index_posts_on_author_id"
45 | end
46 |
47 | create_table "users", force: :cascade do |t|
48 | t.string "name"
49 | t.string "photo"
50 | t.string "bio"
51 | t.integer "post_counter"
52 | t.datetime "created_at", null: false
53 | t.datetime "updated_at", null: false
54 | t.string "email", default: "", null: false
55 | t.string "encrypted_password", default: "", null: false
56 | t.string "reset_password_token"
57 | t.datetime "reset_password_sent_at"
58 | t.datetime "remember_created_at"
59 | t.string "confirmation_token"
60 | t.datetime "confirmed_at"
61 | t.datetime "confirmation_sent_at"
62 | t.string "unconfirmed_email"
63 | t.string "role"
64 | t.index ["email"], name: "index_users_on_email", unique: true
65 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
66 | end
67 |
68 | add_foreign_key "comments", "posts"
69 | add_foreign_key "comments", "users"
70 | add_foreign_key "likes", "posts"
71 | add_foreign_key "likes", "users"
72 | add_foreign_key "posts", "users", column: "author_id"
73 | end
74 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7 | # Character.create(name: "Luke", movie: movies.first)
8 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/lib/tasks/.keep
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/log/.keep
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/public/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/public/favicon.ico
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 |
--------------------------------------------------------------------------------
/spec/features/post_index_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.feature 'PostIndices', type: :feature do
4 | before :each do
5 | @user = User.create(name: 'Bala', bio: 'Doctor from Turkey',
6 | photo: 'https://img.freepik.com/kitten.jpg', post_counter: 2)
7 | @post1 = Post.create(author_id: @user.id, title: 'Post #1',
8 | text: 'First', comments_counter: 1, likes_counter: 0)
9 | @post2 = Post.create(author_id: @user.id, title: 'Post #2',
10 | text: 'Second', comments_counter: 1, likes_counter: 0)
11 | @comment1 = Comment.create(user_id: @user.id, post_id: @post1.id,
12 | text: 'First comment')
13 | @comment2 = Comment.create(user_id: @user.id, post_id: @post2.id,
14 | text: 'Second comment')
15 | end
16 |
17 | it 'Shows the content of the post#index page' do
18 | visit user_posts_path(@user)
19 | # I can see the user's profile picture
20 | expect(page).to have_css("img[src='#{@user.photo}']")
21 | # I can see the user's username
22 | expect(page).to have_content(@user.name)
23 | # I can see the number of posts the user has written
24 | expect(page).to have_content("Number of posts: #{@user.post_counter}")
25 | # I can see a post's title
26 | expect(page).to have_content(@post1.title)
27 | # I can see some of the post's body
28 | expect(page).to have_content(@post1.text)
29 | expect(page).to have_content(@post2.text)
30 | # I can see the first comments on a post
31 | expect(page).to have_content(@comment1.text)
32 | expect(page).to have_content(@comment2.text)
33 | # I can see how many comments a post has
34 | expect(page).to have_content("Comments: #{@post1.comments_counter}")
35 | expect(page).to have_content("Comments: #{@post2.comments_counter}")
36 | # I can see how many likes a post has
37 | expect(page).to have_content("Like: #{@post1.likes_counter}")
38 | expect(page).to have_content("Like: #{@post2.likes_counter}")
39 | # I can see a section for pagination if there are more posts than fit on the view
40 | expect(page).to have_content('Pagination')
41 | # When I click on a post, it redirects me to that post's show page
42 | click_link @post1.title
43 | expect(page).to have_current_path(user_post_path(@user, @post1))
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/spec/features/post_show_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.feature 'PostShows', type: :feature do
4 | before :each do
5 | @user = User.create(name: 'Marial', bio: 'Engineer from US',
6 | photo: 'https://adorable-kitten.jpg',
7 | post_counter: 2)
8 |
9 | @post = Post.create(author_id: @user.id, title: 'Post #1',
10 | text: 'First', comments_counter: 3, likes_counter: 0)
11 |
12 | @comment1 = Comment.create(user_id: @user.id, post_id: @post.id, text: 'First comment')
13 | @comment2 = Comment.create(user_id: @user.id, post_id: @post.id, text: 'Second comment')
14 | @comment3 = Comment.create(user_id: @user.id, post_id: @post.id, text: 'Third comment')
15 | end
16 |
17 | it 'Shows the content of the post#show page' do
18 | visit user_post_path(@user, @post)
19 | # I can see the post's title
20 | expect(page).to have_content(@post.title)
21 | # I can see who wrote the post
22 | expect(page).to have_content(@user.name)
23 | # I can see how many comments it has
24 | expect(page).to have_content("Comments: #{@post.comments_counter}")
25 | # I can see how many likes it has
26 | expect(page).to have_content("Like: #{@post.likes_counter}")
27 | # I can see the post body
28 | expect(page).to have_content(@post.text)
29 | within('.list-of-comments') do
30 | # I can see the username of each commentor
31 | expect(page).to have_content(@user.name)
32 | # I can see the comment each commentor left
33 | expect(page).to have_content(@comment1.text)
34 | expect(page).to have_content(@comment2.text)
35 | expect(page).to have_content(@comment3.text)
36 | end
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/spec/features/user_index_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.feature 'UserIndices', type: :feature do
4 | before :each do
5 | @user1 = User.create(
6 | name: 'Mac',
7 | bio: 'Software developer from US',
8 | photo: 'https://img.freepik.com/free-photo/view-adorable-kitten_23-2150758084.jpg',
9 | post_counter: 0
10 | )
11 |
12 | @user2 = User.create(
13 | name: 'Barbie',
14 | bio: 'Software developer from India',
15 | photo: 'https://www.shutterstock.com/image-photo/british-shorthair-kitten.jpg',
16 | post_counter: 1
17 | )
18 | end
19 |
20 | it 'Display the content of the user#index page' do
21 | visit root_path
22 |
23 | # I can see the username of all other users
24 | expect(page).to have_content(@user1.name)
25 | expect(page).to have_content(@user2.name)
26 | # I can see the profile picture for each user
27 | expect(page).to have_css("img[src='#{@user1.photo}']")
28 | expect(page).to have_css("img[src='#{@user2.photo}']")
29 | # I can see the number of posts each user has written
30 | expect(page).to have_content("Number of posts: #{@user1.post_counter}")
31 | expect(page).to have_content("Number of posts: #{@user2.post_counter}")
32 | # When I click on a user, I am redirected to that user's show page
33 | click_link @user1.name
34 | expect(page).to have_current_path(user_path(@user1))
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/spec/features/user_show_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.feature 'UserShows', type: :feature do
4 | before :each do
5 | @user = User.create(
6 | name: 'Rob',
7 | bio: 'Software Engineer from India',
8 | photo: 'https://adorable-kitten.jpg',
9 | post_counter: 3
10 | )
11 |
12 | @post1 = Post.create(author_id: @user.id, title: 'First Post', text: 'First', comments_counter: 2, likes_counter: 1)
13 |
14 | @post2 = Post.create(author_id: @user.id, title: 'Second Post', text: 'Second', comments_counter: 0,
15 | likes_counter: 2)
16 |
17 | @post3 = Post.create(author_id: @user.id, title: 'Third Post', text: 'Third', comments_counter: 2, likes_counter: 3)
18 | end
19 |
20 | it 'Display the content of user#show page' do
21 | visit user_path(@user)
22 | # I can see the user's profile picture
23 | expect(page).to have_css("img[src='#{@user.photo}']")
24 | # I can see the user's username
25 | expect(page).to have_content(@user.name)
26 | # I can see the number of posts the user has written
27 | expect(page).to have_content("Number of posts: #{@user.post_counter}")
28 | # I can see the user's bio
29 | expect(page).to have_content(@user.bio)
30 | # I can see the user's first 3 posts
31 | expect(page).to have_content(@post3.title)
32 | expect(page).to have_content(@post2.title)
33 | expect(page).to have_content(@post1.title)
34 | # I can see a button that lets me view all of a user's posts
35 | expect(page).to have_content('See all posts')
36 | # When I click a user's post, it redirects me to that post's show page
37 | click_link @post3.title
38 | expect(page).to have_current_path(user_post_path(@user, @post3))
39 | # When I click to see all posts, it redirects me to the user's post's index page
40 | visit user_path(@user)
41 | click_link 'See all posts'
42 | expect(page).to have_current_path(user_posts_path(@user))
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/spec/helpers/api/v1/comments_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | # Specs in this file have access to a helper object that includes
4 | # the Api::V1::CommentsHelper. For example:
5 | #
6 | # describe Api::V1::CommentsHelper do
7 | # describe "string concat" do
8 | # it "concats two strings with spaces" do
9 | # expect(helper.concat_strings("this","that")).to eq("this that")
10 | # end
11 | # end
12 | # end
13 | RSpec.describe Api::V1::CommentsHelper, type: :helper do
14 | pending "add some examples to (or delete) #{__FILE__}"
15 | end
16 |
--------------------------------------------------------------------------------
/spec/helpers/api/v1/posts_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | # Specs in this file have access to a helper object that includes
4 | # the Api::V1::PostsHelper. For example:
5 | #
6 | # describe Api::V1::PostsHelper do
7 | # describe "string concat" do
8 | # it "concats two strings with spaces" do
9 | # expect(helper.concat_strings("this","that")).to eq("this that")
10 | # end
11 | # end
12 | # end
13 | RSpec.describe Api::V1::PostsHelper, type: :helper do
14 | pending "add some examples to (or delete) #{__FILE__}"
15 | end
16 |
--------------------------------------------------------------------------------
/spec/models/comment_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Comment, type: :model do
4 | describe 'Method of Comment model' do
5 | it 'Should update the comments_counter of a post' do
6 | user = User.create(name: 'Tom', photo: 'https://unsplash.com/photos/F_-0BxGuVvo',
7 | bio: 'Teacher from Mexico.')
8 | post = Post.create(author: user, title: 'Hello', text: 'This is my first post')
9 | comment = Comment.create(post:, user:, text: 'Hi Tom!')
10 |
11 | comment.update_comment_counter_post
12 | expect(post.reload.comments_counter).to eq(1)
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/models/like_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Like, type: :model do
4 | describe 'Like Method' do
5 | it ' Should update likes_counter for a post' do
6 | user = User.create(name: 'Tom', photo: 'https://unsplash.com/photos/F_-0BxGuVvo',
7 | bio: 'Teacher from Mexico.')
8 | post = Post.create(author: user, title: 'Hello', text: 'This is my first post')
9 | like = Like.create(user:, post:)
10 | like.update_like_counter_post
11 | expect(post.reload.likes_counter).to eq(1)
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/models/post_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Post, type: :model do
4 | user = User.create(name: 'Harry')
5 | post = Post.new(title: 'Hi', text: 'My first post', comments_counter: 5, likes_counter: 2, author: user)
6 |
7 | describe 'Post Model' do
8 | context 'Checking the post title' do
9 | it 'Should not allow empty title' do
10 | post.title = nil
11 | expect(post).to_not be_valid
12 | end
13 |
14 | it 'Should not allow a title not more than 250 chars' do
15 | post.title = 'Hello' * 50
16 | expect(post).to be_valid
17 | end
18 | end
19 |
20 | context 'For checking the comments_counter' do
21 | it 'Should not allow non integer value for comments_counter' do
22 | post.comments_counter = 'Anything'
23 | expect(post).to_not be_valid
24 | end
25 |
26 | it 'Should allow integer value for comments_counter' do
27 | post.comments_counter = 4
28 | expect(post).to be_valid
29 | end
30 | end
31 |
32 | context 'For checking the likes_counter' do
33 | it 'Should not allow non integer value for likes_counter' do
34 | post.likes_counter = 'Anything'
35 | expect(post).to_not be_valid
36 | end
37 |
38 | it 'Should allow integer value for likes_counter' do
39 | post.likes_counter = 4
40 | expect(post).to be_valid
41 | end
42 |
43 | it 'Should not allow negative integer value for likes_counter' do
44 | post.likes_counter = -4
45 | expect(post).to_not be_valid
46 | end
47 | end
48 |
49 | context 'Methods of post.rb' do
50 | it 'Should update post_counter when a new post is created' do
51 | user = User.create(name: 'Chandan')
52 | post = Post.create(title: 'Hello World', author: user)
53 |
54 | post.update_posts_counter_user
55 |
56 | expect(user.post_counter).to eq(1)
57 | end
58 |
59 | it 'Should show the 5 recent comments of a post' do
60 | user = User.create(name: 'Tom', photo: 'https://unsplash.com/photos/F_-0BxGuVvo',
61 | bio: 'Teacher from Mexico.')
62 | post = Post.create(author: user, title: 'Hello', text: 'This is my first post')
63 | comment1 = Comment.create(post:, user:, text: 'Hi There!', created_at: 6.hours.ago)
64 | comment2 = Comment.create(post:, user:, text: 'Hello There!', created_at: 5.hours.ago)
65 | comment3 = Comment.create(post:, user:, text: 'This is Chandan!', created_at: 4.hours.ago)
66 | comment4 = Comment.create(post:, user:, text: 'Coding is challanging!',
67 | created_at: 3.hours.ago)
68 | comment5 = Comment.create(post:, user:, text: 'But practice!', created_at: 2.hours.ago)
69 | comment6 = Comment.create(post:, user:, text: 'Bye!', created_at: 1.hours.ago)
70 | expect(post.five_recent_comments_post).to eq([comment6, comment5, comment4, comment3, comment2])
71 | expect(post.five_recent_comments_post).to_not include(comment1)
72 | end
73 | end
74 |
75 | context 'Custom Method: #set_counters_to_zero' do
76 | it 'should set comments_counter to 0 when comments_counter is nil' do
77 | post = Post.new(title: 'My name is Chandan')
78 | post.set_counters_to_zero
79 | expect(post.comments_counter).to eq(0)
80 | end
81 |
82 | it 'should set likes_counter to 0 when likes_counter is nil' do
83 | post = Post.new(title: 'I am from India')
84 | post.set_counters_to_zero
85 | expect(post.likes_counter).to eq(0)
86 | end
87 |
88 | it 'should not change comments_counter if it is already set' do
89 | post = Post.new(title: 'I like to code!', comments_counter: 3)
90 | post.set_counters_to_zero
91 | expect(post.comments_counter).to eq(3)
92 | end
93 |
94 | it 'should not change likes_counter if it is already set' do
95 | post = Post.new(title: 'That is all', likes_counter: 40)
96 | post.set_counters_to_zero
97 | expect(post.likes_counter).to eq(40)
98 | end
99 | end
100 | end
101 | end
102 |
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe User, type: :model do
4 | user = User.new(name: 'Alice', photo: 'https://unsplash.com/photos/ABC123',
5 | bio: 'Software Engineer from California.', post_counter: 10)
6 |
7 | describe 'User model' do
8 | context 'Validations for user' do
9 | it 'Should not allow an empty name for User' do
10 | user.name = nil
11 | expect(user).to_not be_valid
12 | end
13 |
14 | it 'Should return the existing name is valid' do
15 | user.name = 'Tom'
16 | expect(user).to be_valid
17 | end
18 |
19 | it 'Should not have a post_counter non-integer' do
20 | user.post_counter = 'Anything'
21 | expect(user).to_not be_valid
22 | end
23 |
24 | it 'Should allow post_counter to be an integer' do
25 | user.post_counter = 45
26 | expect(user).to be_valid
27 | user.post_counter = 0
28 | expect(user).to be_valid
29 | end
30 |
31 | it 'Should not allow integer to be zero' do
32 | user.post_counter = -3
33 | expect(user).to_not be_valid
34 | end
35 | end
36 |
37 | context 'Custom Method: #set_post_counter_zero' do
38 | it 'should set post_counter to 0 when post_counter is nil' do
39 | user = User.new(name: 'Chandan')
40 | user.set_post_counter_zero
41 | expect(user.post_counter).to eq(0)
42 | end
43 | it 'should not change post_counter if it is already set' do
44 | user = User.new(name: 'Benyamin', post_counter: 3)
45 | user.set_post_counter_zero
46 | expect(user.post_counter).to eq(3)
47 | end
48 | end
49 |
50 | context 'User Method #three_recent_posts' do
51 | it 'return the three_recent_posts for a user' do
52 | first_user = User.create(name: 'Lilly', photo: 'https://unsplash.com/photos/F_-0BxGuVvo',
53 | bio: 'Teacher from Poland.')
54 |
55 | post1 = Post.create(author: first_user, title: 'First title', text: 'First Post', created_at: 4.hours.ago)
56 | post2 = Post.create(author: first_user, title: 'Second title', text: 'Second Post', created_at: 3.hours.ago)
57 | post3 = Post.create(author: first_user, title: 'Third title', text: 'Third Post', created_at: 2.hours.ago)
58 | post4 = Post.create(author: first_user, title: 'Fourth title', text: 'Fourth Post', created_at: 1.hours.ago)
59 |
60 | recent_posts = first_user.three_recent_posts
61 |
62 | expect(recent_posts).to eq([post4, post3, post2])
63 | expect(recent_posts).to_not include(post1)
64 | end
65 | end
66 | end
67 | end
68 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to spec/ when you run 'rails generate rspec:install'
2 | require 'spec_helper'
3 | ENV['RAILS_ENV'] ||= 'test'
4 | require_relative '../config/environment'
5 | # Prevent database truncation if the environment is production
6 | abort('The Rails environment is running in production mode!') if Rails.env.production?
7 | require 'rspec/rails'
8 | # Add additional requires below this line. Rails is not loaded until this point!
9 |
10 | # Requires supporting ruby files with custom matchers and macros, etc, in
11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12 | # run as spec files by default. This means that files in spec/support that end
13 | # in _spec.rb will both be required and run as specs, causing the specs to be
14 | # run twice. It is recommended that you do not name files matching this glob to
15 | # end with _spec.rb. You can configure this pattern with the --pattern
16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17 | #
18 | # The following line is provided for convenience purposes. It has the downside
19 | # of increasing the boot-up time by auto-requiring all files in the support
20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
21 | # require only the support files necessary.
22 | #
23 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
24 |
25 | # Checks for pending migrations and applies them before tests are run.
26 | # If you are not using ActiveRecord, you can remove these lines.
27 | begin
28 | ActiveRecord::Migration.maintain_test_schema!
29 | rescue ActiveRecord::PendingMigrationError => e
30 | abort e.to_s.strip
31 | end
32 | RSpec.configure do |config|
33 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
34 | config.fixture_path = "#{Rails.root}/spec/fixtures"
35 |
36 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
37 | # examples within a transaction, remove the following line or assign false
38 | # instead of true.
39 | config.use_transactional_fixtures = true
40 |
41 | # You can uncomment this line to turn off ActiveRecord support entirely.
42 | # config.use_active_record = false
43 |
44 | # RSpec Rails can automatically mix in different behaviours to your tests
45 | # based on their file location, for example enabling you to call `get` and
46 | # `post` in specs under `spec/controllers`.
47 | #
48 | # You can disable this behaviour by removing the line below, and instead
49 | # explicitly tag your specs with their type, e.g.:
50 | #
51 | # RSpec.describe UsersController, type: :controller do
52 | # # ...
53 | # end
54 | #
55 | # The different available types are documented in the features, such as in
56 | # https://rspec.info/features/6-0/rspec-rails
57 | config.infer_spec_type_from_file_location!
58 |
59 | # Filter lines from Rails gems in backtraces.
60 | config.filter_rails_from_backtrace!
61 | # arbitrary gems may also be filtered via:
62 | # config.filter_gems_from_backtrace("gem name")
63 | end
64 |
--------------------------------------------------------------------------------
/spec/requests/api/v1/comments_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe 'Api::V1::Comments', type: :request do
4 | describe 'GET /index' do
5 | pending "add some examples (or delete) #{__FILE__}"
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/requests/api/v1/posts_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe 'Api::V1::Posts', type: :request do
4 | describe 'GET /index' do
5 | pending "add some examples (or delete) #{__FILE__}"
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/requests/posts_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe 'Posts', type: :request do
4 | describe 'GET /posts' do
5 | context 'Get #index' do
6 | # before(:each) do
7 | # get '/users/7/posts'
8 | # end
9 | user = User.create(name: 'Still Rollin', photo: 'https://unsplash.com/photos/F_-0BxGuVvo',
10 | bio: 'Singer from India', post_counter: 3)
11 | # Post.create(title: 'Hello World', author: user)
12 |
13 | it 'returns a 200 status code' do
14 | get user_posts_path(user)
15 | expect(response).to have_http_status(:success)
16 | end
17 |
18 | it 'open the index template' do
19 | get user_posts_path(user)
20 | expect(response).to render_template(:index)
21 | end
22 |
23 | it 'shows that template includes correct placeholder text' do
24 | get user_posts_path(user)
25 | expect(response.body).to include('Show all posts for a specific user')
26 | end
27 | end
28 |
29 | context 'Get #show' do
30 | # before(:each) do
31 | # get '/users/7/posts/8'
32 | # end
33 | user = User.create(name: 'Still Rollin', photo: 'https://unsplash.com/photos/F_-0BxGuVvo',
34 | bio: 'Singer from India', post_counter: 3)
35 | post = Post.create(title: 'Hello World', author: user)
36 |
37 | it 'returns a 200 status code' do
38 | get user_post_path(user, post)
39 | expect(response).to have_http_status(:success)
40 | end
41 |
42 | it 'open the show template' do
43 | get user_post_path(user, post)
44 | expect(response).to render_template(:show)
45 | end
46 |
47 | it 'shows that template includes correct placeholder text' do
48 | get user_post_path(user, post)
49 | expect(response.body).to include('Specific post for a specific user')
50 | end
51 | end
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/spec/requests/users_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe 'Users', type: :request do
4 | describe 'GET /users' do
5 | context 'Get #index' do
6 | before(:each) do
7 | get '/users'
8 | end
9 | it 'returns a 200 status code' do
10 | expect(response).to have_http_status(:success)
11 | end
12 |
13 | it 'open the index template' do
14 | expect(response).to render_template(:index)
15 | end
16 |
17 | it 'shows that template includes correct placeholder text' do
18 | expect(response.body).to include('List of all users')
19 | end
20 | end
21 |
22 | context 'Get #show' do
23 | before(:each) do
24 | get '/users/7'
25 | end
26 | it 'returns a 200 status code' do
27 | expect(response).to have_http_status(:success)
28 | end
29 |
30 | it 'open the show template' do
31 | expect(response).to render_template(:show)
32 | end
33 |
34 | it 'shows that template includes correct placeholder text' do
35 | expect(response.body).to include('Show a specific user')
36 | end
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3 | # The generated `.rspec` file contains `--require spec_helper` which will cause
4 | # this file to always be loaded, without a need to explicitly require it in any
5 | # files.
6 | #
7 | # Given that it is always loaded, you are encouraged to keep this file as
8 | # light-weight as possible. Requiring heavyweight dependencies from this file
9 | # will add to the boot time of your test suite on EVERY test run, even for an
10 | # individual file that may not need all of that loaded. Instead, consider making
11 | # a separate helper file that requires the additional dependencies and performs
12 | # the additional setup, and require it from the spec files that actually need
13 | # it.
14 | #
15 | # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16 | RSpec.configure do |config|
17 | # rspec-expectations config goes here. You can use an alternate
18 | # assertion/expectation library such as wrong or the stdlib/minitest
19 | # assertions if you prefer.
20 | config.expect_with :rspec do |expectations|
21 | # This option will default to `true` in RSpec 4. It makes the `description`
22 | # and `failure_message` of custom matchers include text for helper methods
23 | # defined using `chain`, e.g.:
24 | # be_bigger_than(2).and_smaller_than(4).description
25 | # # => "be bigger than 2 and smaller than 4"
26 | # ...rather than:
27 | # # => "be bigger than 2"
28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29 | end
30 |
31 | # rspec-mocks config goes here. You can use an alternate test double
32 | # library (such as bogus or mocha) by changing the `mock_with` option here.
33 | config.mock_with :rspec do |mocks|
34 | # Prevents you from mocking or stubbing a method that does not exist on
35 | # a real object. This is generally recommended, and will default to
36 | # `true` in RSpec 4.
37 | mocks.verify_partial_doubles = true
38 | end
39 |
40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41 | # have no way to turn it off -- the option exists only for backwards
42 | # compatibility in RSpec 3). It causes shared context metadata to be
43 | # inherited by the metadata hash of host groups and examples, rather than
44 | # triggering implicit auto-inclusion in groups with matching metadata.
45 | config.shared_context_metadata_behavior = :apply_to_host_groups
46 |
47 | # The settings below are suggested to provide a good initial experience
48 | # with RSpec, but feel free to customize to your heart's content.
49 | # # This allows you to limit a spec run to individual examples or groups
50 | # # you care about by tagging them with `:focus` metadata. When nothing
51 | # # is tagged with `:focus`, all examples get run. RSpec also provides
52 | # # aliases for `it`, `describe`, and `context` that include `:focus`
53 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
54 | # config.filter_run_when_matching :focus
55 | #
56 | # # Allows RSpec to persist some state between runs in order to support
57 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
58 | # # you configure your source control system to ignore this file.
59 | # config.example_status_persistence_file_path = "spec/examples.txt"
60 | #
61 | # # Limits the available syntax to the non-monkey patched syntax that is
62 | # # recommended. For more details, see:
63 | # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
64 | # config.disable_monkey_patching!
65 | #
66 | # # This setting enables warnings. It's recommended, but in some cases may
67 | # # be too noisy due to issues in dependencies.
68 | # config.warnings = true
69 | #
70 | # # Many RSpec users commonly either run the entire suite or an individual
71 | # # file, and it's useful to allow more verbose output when running an
72 | # # individual spec file.
73 | # if config.files_to_run.one?
74 | # # Use the documentation formatter for detailed output,
75 | # # unless a formatter has already been configured
76 | # # (e.g. via a command-line flag).
77 | # config.default_formatter = "doc"
78 | # end
79 | #
80 | # # Print the 10 slowest examples and example groups at the
81 | # # end of the spec run, to help surface which specs are running
82 | # # particularly slow.
83 | # config.profile_examples = 10
84 | #
85 | # # Run specs in random order to surface order dependencies. If you find an
86 | # # order dependency and want to debug it, you can fix the order by providing
87 | # # the seed, which is printed after each run.
88 | # # --seed 1234
89 | # config.order = :random
90 | #
91 | # # Seed global randomization in this process using the `--seed` CLI option.
92 | # # Setting this allows you to use `--seed` to deterministically reproduce
93 | # # test failures related to randomization by passing the same `--seed` value
94 | # # as the one that triggered the failure.
95 | # Kernel.srand config.seed
96 | end
97 |
--------------------------------------------------------------------------------
/storage/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/storage/.keep
--------------------------------------------------------------------------------
/swagger/v1/swagger.yaml:
--------------------------------------------------------------------------------
1 | openapi: 3.0.3
2 | info:
3 | title: Blog App Api
4 | version: v1
5 | paths:
6 | "/api/v1/posts":
7 | get:
8 | summary: Lists all posts for a user
9 | tags:
10 | - Posts
11 | parameters:
12 | - name: author_id
13 | in: query
14 | description: User ID
15 | schema:
16 | type: integer
17 | responses:
18 | '200':
19 | description: posts listed
20 | '401':
21 | description: unauthorized
22 | "/api/v1/posts/{post_id}/comments":
23 | get:
24 | summary: Lists all comments for a post
25 | tags:
26 | - Comments
27 | parameters:
28 | - name: post_id
29 | in: path
30 | description: Post ID
31 | required: true
32 | schema:
33 | type: integer
34 | responses:
35 | '200':
36 | description: comments listed
37 | '401':
38 | description: unauthorized
39 | post:
40 | summary: Adds a comment to a post
41 | tags:
42 | - Comments
43 | parameters:
44 | - name: post_id
45 | in: path
46 | description: Post ID
47 | required: true
48 | schema:
49 | type: integer
50 | responses:
51 | '201':
52 | description: comment created
53 | '422':
54 | description: invalid request
55 | '401':
56 | description: unauthorized
57 | requestBody:
58 | content:
59 | application/json:
60 | schema:
61 | type: object
62 | properties:
63 | text:
64 | type: string
65 | required:
66 | - text
67 | servers:
68 | - url: https://{127.0.0.1:3000/}
69 | variables:
70 | defaultHost:
71 | default: 127.0.0.1:3000/
--------------------------------------------------------------------------------
/test/application_system_test_case.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5 | end
6 |
--------------------------------------------------------------------------------
/test/channels/application_cable/connection_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
4 | # test "connects with cookies" do
5 | # cookies.signed[:user_id] = 42
6 | #
7 | # connect
8 | #
9 | # assert_equal connection.user_id, "42"
10 | # end
11 | end
12 |
--------------------------------------------------------------------------------
/test/controllers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/controllers/.keep
--------------------------------------------------------------------------------
/test/fixtures/comments.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 |
3 | one:
4 | user: one
5 | post: one
6 | text: MyString
7 |
8 | two:
9 | user: two
10 | post: two
11 | text: MyString
12 |
--------------------------------------------------------------------------------
/test/fixtures/files/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/fixtures/files/.keep
--------------------------------------------------------------------------------
/test/fixtures/likes.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 |
3 | one:
4 | user: one
5 | post: one
6 |
7 | two:
8 | user: two
9 | post: two
10 |
--------------------------------------------------------------------------------
/test/fixtures/posts.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 |
3 | one:
4 | author: one
5 | title: MyString
6 | text: MyString
7 | comments_counter: 1
8 | likes_counter: 1
9 |
10 | two:
11 | author: two
12 | title: MyString
13 | text: MyString
14 | comments_counter: 1
15 | likes_counter: 1
16 |
--------------------------------------------------------------------------------
/test/fixtures/users.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 |
3 | one:
4 | name: MyString
5 | photo: MyString
6 | bio: MyString
7 | post_counter: 1
8 |
9 | two:
10 | name: MyString
11 | photo: MyString
12 | bio: MyString
13 | post_counter: 1
14 |
--------------------------------------------------------------------------------
/test/helpers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/helpers/.keep
--------------------------------------------------------------------------------
/test/integration/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/integration/.keep
--------------------------------------------------------------------------------
/test/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/mailers/.keep
--------------------------------------------------------------------------------
/test/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/models/.keep
--------------------------------------------------------------------------------
/test/models/comment_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CommentTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/models/like_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class LikeTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/models/post_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class PostTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/models/user_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UserTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/system/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/test/system/.keep
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV['RAILS_ENV'] ||= 'test'
2 | require_relative '../config/environment'
3 | require 'rails/test_help'
4 |
5 | class ActiveSupport::TestCase
6 | # Run tests in parallel with specified workers
7 | parallelize(workers: :number_of_processors, with: :threads)
8 |
9 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
10 | fixtures :all
11 |
12 | # Add more helper methods to be used by all tests here...
13 | end
14 |
--------------------------------------------------------------------------------
/tmp/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/tmp/.keep
--------------------------------------------------------------------------------
/tmp/pids/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/tmp/pids/.keep
--------------------------------------------------------------------------------
/tmp/storage/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/tmp/storage/.keep
--------------------------------------------------------------------------------
/vendor/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/vendor/.keep
--------------------------------------------------------------------------------
/vendor/javascript/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chandan-devs-tech/blog-app/15837cbfa0b3a557f0b163bbe06aa3e85ac182c4/vendor/javascript/.keep
--------------------------------------------------------------------------------
<%= comment.user.name %>: <%= comment.text %>
11 | <%end%> 12 |