+
\ No newline at end of file
diff --git a/Sample_App/app/views/layouts/application.html.erb b/Sample_App/app/views/layouts/application.html.erb
new file mode 100644
index 0000000..8e2a434
--- /dev/null
+++ b/Sample_App/app/views/layouts/application.html.erb
@@ -0,0 +1,23 @@
+
+
+
New user? <%= link_to "Sign up now!", signup_path %>
+
+
\ No newline at end of file
diff --git a/Sample_App/app/views/shared/_error_messages.html.erb b/Sample_App/app/views/shared/_error_messages.html.erb
new file mode 100644
index 0000000..2474cb6
--- /dev/null
+++ b/Sample_App/app/views/shared/_error_messages.html.erb
@@ -0,0 +1,12 @@
+<% if @user.errors.any? %>
+
+
+ The form contains <%= pluralize(@user.errors.count, "error") %>.
+
+
+ <% @user.errors.full_messages.each do |msg| %>
+
<%= msg %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/Sample_App/app/views/static_pages/about.html.erb b/Sample_App/app/views/static_pages/about.html.erb
new file mode 100644
index 0000000..ad0b68d
--- /dev/null
+++ b/Sample_App/app/views/static_pages/about.html.erb
@@ -0,0 +1,21 @@
+<% provide(:title, "About") %>
+
+
+
+ <%= yield(:title) %> | Ruby on Rails Tutorial Sample App
+
+
+
\ No newline at end of file
diff --git a/Sample_App/app/views/users/index.html.erb b/Sample_App/app/views/users/index.html.erb
new file mode 100644
index 0000000..cd5b789
--- /dev/null
+++ b/Sample_App/app/views/users/index.html.erb
@@ -0,0 +1,9 @@
+<% provide(:title, 'All users') %>
+
All users
+<%= will_paginate %>
+
+ <% @users.each do |user| %>
+ <%= render user %>
+ <% end %>
+
+<%= will_paginate %>
\ No newline at end of file
diff --git a/Sample_App/app/views/users/new.html.erb b/Sample_App/app/views/users/new.html.erb
new file mode 100644
index 0000000..b3d68a4
--- /dev/null
+++ b/Sample_App/app/views/users/new.html.erb
@@ -0,0 +1,8 @@
+<% provide(:title, 'Sign up') %>
+<% provide(:button_text, 'Create my account') %>
+
Sign up
+
+
+ <%= render 'form' %>
+
+
\ No newline at end of file
diff --git a/Sample_App/app/views/users/show.html.erb b/Sample_App/app/views/users/show.html.erb
new file mode 100644
index 0000000..65b068d
--- /dev/null
+++ b/Sample_App/app/views/users/show.html.erb
@@ -0,0 +1,11 @@
+<% provide(:title, @user.name) %>
+
+
+
\ No newline at end of file
diff --git a/Sample_App/bin/bundle b/Sample_App/bin/bundle
new file mode 100755
index 0000000..f19acf5
--- /dev/null
+++ b/Sample_App/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/Sample_App/bin/rails b/Sample_App/bin/rails
new file mode 100755
index 0000000..5badb2f
--- /dev/null
+++ b/Sample_App/bin/rails
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/Sample_App/bin/rake b/Sample_App/bin/rake
new file mode 100755
index 0000000..d87d5f5
--- /dev/null
+++ b/Sample_App/bin/rake
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/Sample_App/bin/setup b/Sample_App/bin/setup
new file mode 100755
index 0000000..94fd4d7
--- /dev/null
+++ b/Sample_App/bin/setup
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/Sample_App/bin/spring b/Sample_App/bin/spring
new file mode 100755
index 0000000..d89ee49
--- /dev/null
+++ b/Sample_App/bin/spring
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+# This file loads Spring without using Bundler, in order to be fast.
+# It gets overwritten when you run the `spring binstub` command.
+
+unless defined?(Spring)
+ require 'rubygems'
+ require 'bundler'
+
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
+ spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
+ if spring
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
+ gem 'spring', spring.version
+ require 'spring/binstub'
+ end
+end
diff --git a/Sample_App/bin/update b/Sample_App/bin/update
new file mode 100755
index 0000000..58bfaed
--- /dev/null
+++ b/Sample_App/bin/update
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/Sample_App/bin/yarn b/Sample_App/bin/yarn
new file mode 100755
index 0000000..460dd56
--- /dev/null
+++ b/Sample_App/bin/yarn
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path('..', __dir__)
+Dir.chdir(APP_ROOT) do
+ begin
+ exec "yarnpkg", *ARGV
+ rescue Errno::ENOENT
+ $stderr.puts "Yarn executable was not detected in the system."
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
+ exit 1
+ end
+end
diff --git a/Sample_App/config.ru b/Sample_App/config.ru
new file mode 100644
index 0000000..f7ba0b5
--- /dev/null
+++ b/Sample_App/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/Sample_App/config/application.rb b/Sample_App/config/application.rb
new file mode 100644
index 0000000..e746037
--- /dev/null
+++ b/Sample_App/config/application.rb
@@ -0,0 +1,19 @@
+require_relative 'boot'
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module RailsApp
+ class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.2
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration can go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded after loading
+ # the framework and any gems in your application.
+ end
+end
diff --git a/Sample_App/config/boot.rb b/Sample_App/config/boot.rb
new file mode 100644
index 0000000..b9e460c
--- /dev/null
+++ b/Sample_App/config/boot.rb
@@ -0,0 +1,4 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
diff --git a/Sample_App/config/cable.yml b/Sample_App/config/cable.yml
new file mode 100644
index 0000000..ae650bd
--- /dev/null
+++ b/Sample_App/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: rails_app_production
diff --git a/Sample_App/config/credentials.yml.enc b/Sample_App/config/credentials.yml.enc
new file mode 100644
index 0000000..2a7e0b8
--- /dev/null
+++ b/Sample_App/config/credentials.yml.enc
@@ -0,0 +1 @@
++nUB47iA2I7KA59VqTZ85pCQ9M00VMZQhwcVFrUhzEiJLQW15U7yoGm+vf6QK7Lbs1yuLOVu1zkz6D+UAgcZO0npQCIV+mwkLgmSSWQPbhphAulNsoeJoGupUqt3haRKS64lmj+883sPNKv9eltdS+rhwmA5lhF2kjc2pshMYMh3NPBEp4iuaMZ1iSpcS0B0EAmK0bhXkPPxAxgqy38jntdbPv3kj3TEycU5BCn8Wk3Jwe5eSKiCmDv32azznUspk/mQJ5y02UXxhReNSbkQCUBYoqmM8A0+M40WokR5wWDEQXfjtYn1gXLce564BN95FbQ4MJdkWMvwvGI36s30NMxnS6tKxuFQIr494buZxgdY40HptIxOjAGT25AeNr6RgLEYVoXsYYCLXPPzn7o/RLZfK7c3ORNis3qY--g4IGfZW4wLxV4z9i--Ed1hlCY8KXd9JnrCOHy8kA==
\ No newline at end of file
diff --git a/Sample_App/config/database.yml b/Sample_App/config/database.yml
new file mode 100644
index 0000000..0d02f24
--- /dev/null
+++ b/Sample_App/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+#
+default: &default
+ adapter: sqlite3
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+ timeout: 5000
+
+development:
+ <<: *default
+ database: db/development.sqlite3
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: db/test.sqlite3
+
+production:
+ <<: *default
+ database: db/production.sqlite3
diff --git a/Sample_App/config/environment.rb b/Sample_App/config/environment.rb
new file mode 100644
index 0000000..426333b
--- /dev/null
+++ b/Sample_App/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/Sample_App/config/environments/development.rb b/Sample_App/config/environments/development.rb
new file mode 100644
index 0000000..9526974
--- /dev/null
+++ b/Sample_App/config/environments/development.rb
@@ -0,0 +1,60 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
+ config.assets.debug = true
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end
diff --git a/Sample_App/config/environments/production.rb b/Sample_App/config/environments/production.rb
new file mode 100644
index 0000000..02c9dc1
--- /dev/null
+++ b/Sample_App/config/environments/production.rb
@@ -0,0 +1,94 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
+
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "rails_app_#{Rails.env}"
+
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/Sample_App/config/environments/test.rb b/Sample_App/config/environments/test.rb
new file mode 100644
index 0000000..0a38fd3
--- /dev/null
+++ b/Sample_App/config/environments/test.rb
@@ -0,0 +1,46 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory
+ config.active_storage.service = :test
+
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/Sample_App/config/initializers/application_controller_renderer.rb b/Sample_App/config/initializers/application_controller_renderer.rb
new file mode 100644
index 0000000..89d2efa
--- /dev/null
+++ b/Sample_App/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# ActiveSupport::Reloader.to_prepare do
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
+# end
diff --git a/Sample_App/config/initializers/assets.rb b/Sample_App/config/initializers/assets.rb
new file mode 100644
index 0000000..4b828e8
--- /dev/null
+++ b/Sample_App/config/initializers/assets.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+# Add Yarn node_modules folder to the asset load path.
+Rails.application.config.assets.paths << Rails.root.join('node_modules')
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in the app/assets
+# folder are already added.
+# Rails.application.config.assets.precompile += %w( admin.js admin.css )
diff --git a/Sample_App/config/initializers/backtrace_silencers.rb b/Sample_App/config/initializers/backtrace_silencers.rb
new file mode 100644
index 0000000..59385cd
--- /dev/null
+++ b/Sample_App/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/Sample_App/config/initializers/content_security_policy.rb b/Sample_App/config/initializers/content_security_policy.rb
new file mode 100644
index 0000000..d3bcaa5
--- /dev/null
+++ b/Sample_App/config/initializers/content_security_policy.rb
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide content security policy
+# For further information see the following documentation
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+
+# Rails.application.config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+
+# If you are using UJS then enable automatic nonce generation
+# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
+
+# Report CSP violations to a specified URI
+# For further information see the following documentation:
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
+# Rails.application.config.content_security_policy_report_only = true
diff --git a/Sample_App/config/initializers/cookies_serializer.rb b/Sample_App/config/initializers/cookies_serializer.rb
new file mode 100644
index 0000000..5a6a32d
--- /dev/null
+++ b/Sample_App/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/Sample_App/config/initializers/filter_parameter_logging.rb b/Sample_App/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000..4a994e1
--- /dev/null
+++ b/Sample_App/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/Sample_App/config/initializers/inflections.rb b/Sample_App/config/initializers/inflections.rb
new file mode 100644
index 0000000..ac033bf
--- /dev/null
+++ b/Sample_App/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/Sample_App/config/initializers/mime_types.rb b/Sample_App/config/initializers/mime_types.rb
new file mode 100644
index 0000000..dc18996
--- /dev/null
+++ b/Sample_App/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/Sample_App/config/initializers/wrap_parameters.rb b/Sample_App/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000..bbfc396
--- /dev/null
+++ b/Sample_App/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/Sample_App/config/locales/en.yml b/Sample_App/config/locales/en.yml
new file mode 100644
index 0000000..decc5a8
--- /dev/null
+++ b/Sample_App/config/locales/en.yml
@@ -0,0 +1,33 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+# 'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/Sample_App/config/puma.rb b/Sample_App/config/puma.rb
new file mode 100644
index 0000000..a5eccf8
--- /dev/null
+++ b/Sample_App/config/puma.rb
@@ -0,0 +1,34 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory.
+#
+# preload_app!
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/Sample_App/config/routes.rb b/Sample_App/config/routes.rb
new file mode 100644
index 0000000..2ac94f8
--- /dev/null
+++ b/Sample_App/config/routes.rb
@@ -0,0 +1,15 @@
+Rails.application.routes.draw do
+ root 'static_pages#home'
+
+ get '/login', to: 'sessions#new'
+ post 'login', to: 'sessions#create'
+ delete '/logout', to: 'sessions#destroy'
+
+ get '/help', to: 'static_pages#help'
+ get '/about', to: 'static_pages#about'
+ get '/contact', to: 'static_pages#contact'
+ get '/signup', to: 'users#new'
+ post '/signup', to: 'users#create'
+
+ resources :users
+end
diff --git a/Sample_App/config/spring.rb b/Sample_App/config/spring.rb
new file mode 100644
index 0000000..9fa7863
--- /dev/null
+++ b/Sample_App/config/spring.rb
@@ -0,0 +1,6 @@
+%w[
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+].each { |path| Spring.watch(path) }
diff --git a/Sample_App/config/storage.yml b/Sample_App/config/storage.yml
new file mode 100644
index 0000000..d32f76e
--- /dev/null
+++ b/Sample_App/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket
+
+# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/Sample_App/db/migrate/20191219115633_create_users.rb b/Sample_App/db/migrate/20191219115633_create_users.rb
new file mode 100644
index 0000000..5fd691b
--- /dev/null
+++ b/Sample_App/db/migrate/20191219115633_create_users.rb
@@ -0,0 +1,10 @@
+class CreateUsers < ActiveRecord::Migration[5.2]
+ def change
+ create_table :users do |t|
+ t.string :name
+ t.string :email
+
+ t.timestamps
+ end
+ end
+end
diff --git a/Sample_App/db/migrate/20191219124433_add_index_to_users_email.rb b/Sample_App/db/migrate/20191219124433_add_index_to_users_email.rb
new file mode 100644
index 0000000..6ffaad8
--- /dev/null
+++ b/Sample_App/db/migrate/20191219124433_add_index_to_users_email.rb
@@ -0,0 +1,5 @@
+class AddIndexToUsersEmail < ActiveRecord::Migration[5.2]
+ def change
+ add_index :users, :email, unique: true
+ end
+end
diff --git a/Sample_App/db/migrate/20191219125324_add_password_digest_to_users.rb b/Sample_App/db/migrate/20191219125324_add_password_digest_to_users.rb
new file mode 100644
index 0000000..713dc51
--- /dev/null
+++ b/Sample_App/db/migrate/20191219125324_add_password_digest_to_users.rb
@@ -0,0 +1,5 @@
+class AddPasswordDigestToUsers < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :password_digest, :string
+ end
+end
diff --git a/Sample_App/db/migrate/20191219161154_add_remember_digest_to_users.rb b/Sample_App/db/migrate/20191219161154_add_remember_digest_to_users.rb
new file mode 100644
index 0000000..108729c
--- /dev/null
+++ b/Sample_App/db/migrate/20191219161154_add_remember_digest_to_users.rb
@@ -0,0 +1,5 @@
+class AddRememberDigestToUsers < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :remember_digest, :string
+ end
+end
diff --git a/Sample_App/db/migrate/20191220030555_add_admin_to_users.rb b/Sample_App/db/migrate/20191220030555_add_admin_to_users.rb
new file mode 100644
index 0000000..aa6a7e9
--- /dev/null
+++ b/Sample_App/db/migrate/20191220030555_add_admin_to_users.rb
@@ -0,0 +1,5 @@
+class AddAdminToUsers < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :admin, :boolean, default: false
+ end
+end
diff --git a/Sample_App/db/schema.rb b/Sample_App/db/schema.rb
new file mode 100644
index 0000000..256e250
--- /dev/null
+++ b/Sample_App/db/schema.rb
@@ -0,0 +1,26 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 2019_12_20_030555) do
+
+ create_table "users", force: :cascade do |t|
+ t.string "name"
+ t.string "email"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "password_digest"
+ t.string "remember_digest"
+ t.boolean "admin", default: false
+ t.index ["email"], name: "index_users_on_email", unique: true
+ end
+
+end
diff --git a/Sample_App/db/seeds.rb b/Sample_App/db/seeds.rb
new file mode 100644
index 0000000..3327c29
--- /dev/null
+++ b/Sample_App/db/seeds.rb
@@ -0,0 +1,22 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
+User.create!(name: "Example User",
+ email: "example@railstutorial.org",
+ password: "foobar",
+ password_confirmation: "foobar",
+ admin: true)
+
+99.times do |n|
+ name = Faker::Name.name
+ email = "example-#{n+1}@railstutorial.org"
+ password = "password"
+ User.create!(name: name,
+ email: email,
+ password: password,
+ password_confirmation: password)
+end
\ No newline at end of file
diff --git a/Sample_App/lib/assets/.keep b/Sample_App/lib/assets/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/lib/tasks/.keep b/Sample_App/lib/tasks/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/log/.keep b/Sample_App/log/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/package.json b/Sample_App/package.json
new file mode 100644
index 0000000..74a8e6b
--- /dev/null
+++ b/Sample_App/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "rails_app",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/Sample_App/public/404.html b/Sample_App/public/404.html
new file mode 100644
index 0000000..2be3af2
--- /dev/null
+++ b/Sample_App/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/Sample_App/public/422.html b/Sample_App/public/422.html
new file mode 100644
index 0000000..c08eac0
--- /dev/null
+++ b/Sample_App/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/Sample_App/public/500.html b/Sample_App/public/500.html
new file mode 100644
index 0000000..78a030a
--- /dev/null
+++ b/Sample_App/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/Sample_App/public/apple-touch-icon-precomposed.png b/Sample_App/public/apple-touch-icon-precomposed.png
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/public/apple-touch-icon.png b/Sample_App/public/apple-touch-icon.png
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/public/favicon.ico b/Sample_App/public/favicon.ico
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/public/robots.txt b/Sample_App/public/robots.txt
new file mode 100644
index 0000000..37b576a
--- /dev/null
+++ b/Sample_App/public/robots.txt
@@ -0,0 +1 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/Sample_App/storage/.keep b/Sample_App/storage/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/application_system_test_case.rb b/Sample_App/test/application_system_test_case.rb
new file mode 100644
index 0000000..d19212a
--- /dev/null
+++ b/Sample_App/test/application_system_test_case.rb
@@ -0,0 +1,5 @@
+require "test_helper"
+
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
+end
diff --git a/Sample_App/test/controllers/.keep b/Sample_App/test/controllers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/controllers/sessions_controller_test.rb b/Sample_App/test/controllers/sessions_controller_test.rb
new file mode 100644
index 0000000..4ebb9f0
--- /dev/null
+++ b/Sample_App/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class SessionsControllerTest < ActionDispatch::IntegrationTest
+ test "should get new" do
+ get login_path
+ assert_response :success
+ end
+
+end
diff --git a/Sample_App/test/controllers/static_pages_controller_test.rb b/Sample_App/test/controllers/static_pages_controller_test.rb
new file mode 100644
index 0000000..1ba3ab2
--- /dev/null
+++ b/Sample_App/test/controllers/static_pages_controller_test.rb
@@ -0,0 +1,31 @@
+require 'test_helper'
+
+class StaticPagesControllerTest < ActionDispatch::IntegrationTest
+ def setup
+ @base_title = "Ruby on Rails Tutorial Sample App"
+ end
+
+ test "should get home" do
+ get root_path
+ assert_response :success
+ assert_select "title", "Home | #{@base_title}"
+ end
+
+ test "should get help" do
+ get help_path
+ assert_response :success
+ assert_select "title", "Help | #{@base_title}"
+ end
+
+ test "should get about" do
+ get about_path
+ assert_response :success
+ assert_select "title", "About | #{@base_title}"
+ end
+
+ test "should get contact" do
+ get contact_path
+ assert_response :success
+ assert_select "title", "Contact | #{@base_title}"
+ end
+end
diff --git a/Sample_App/test/controllers/users_controller_test.rb b/Sample_App/test/controllers/users_controller_test.rb
new file mode 100644
index 0000000..7e14730
--- /dev/null
+++ b/Sample_App/test/controllers/users_controller_test.rb
@@ -0,0 +1,61 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionDispatch::IntegrationTest
+ def setup
+ @user = users(:michael)
+ @other_user = users(:archer)
+ end
+
+ test "should get new" do
+ get signup_path
+ assert_response :success
+ end
+
+ test "should redirect edit when not logged in" do
+ get edit_user_path(@user)
+ assert_not flash.empty?
+ assert_redirected_to login_url
+ end
+
+ test "should redirect update when not logged in" do
+ patch user_path(@user), params: { user: { name: @user.name,
+ email: @user.email } }
+ assert_not flash.empty?
+ assert_redirected_to login_url
+ end
+
+ test "should redirect edit when logged in as wrong user" do
+ log_in_as(@other_user)
+ get edit_user_path(@user)
+ assert flash.empty?
+ assert_redirected_to root_url
+ end
+
+ test "should redirect update when logged in as wrong user" do
+ log_in_as(@other_user)
+ patch user_path(@user), params: { user: { name: @user.name,
+ email: @user.email } }
+ assert flash.empty?
+ assert_redirected_to root_url
+ end
+
+ test "should redirect index when not logged in" do
+ get users_path
+ assert_redirected_to login_url
+ end
+
+ test "should redirect destroy when not logged in" do
+ assert_no_difference 'User.count' do
+ delete user_path(@user)
+ end
+ assert_redirected_to login_url
+ end
+
+ test "should redirect destroy when logged in as a non-admin" do
+ log_in_as(@other_user)
+ assert_no_difference 'User.count' do
+ delete user_path(@user)
+ end
+ assert_redirected_to root_url
+ end
+end
diff --git a/Sample_App/test/fixtures/.keep b/Sample_App/test/fixtures/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/fixtures/files/.keep b/Sample_App/test/fixtures/files/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/fixtures/users.yml b/Sample_App/test/fixtures/users.yml
new file mode 100644
index 0000000..09d5428
--- /dev/null
+++ b/Sample_App/test/fixtures/users.yml
@@ -0,0 +1,29 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+michael:
+ name: Michael Example
+ email: michael@example.com
+ password_digest: <%= User.digest('password') %>
+ admin: true
+
+archer:
+ name: Sterling Archer
+ email: duchess@example.gov
+ password_digest: <%= User.digest('password') %>
+
+lana:
+ name: Lana Kane
+ email: hands@example.gov
+ password_digest: <%= User.digest('password') %>
+
+malory:
+ name: Malory Archer
+ email: boss@example.gov
+ password_digest: <%= User.digest('password') %>
+
+<% 30.times do |n| %>
+user_<%= n %>:
+ name: <%= "User #{n}" %>
+ email: <%= "user-#{n}@example.com" %>
+ password_digest: <%= User.digest('password') %>
+<% end %>
diff --git a/Sample_App/test/helpers/.keep b/Sample_App/test/helpers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/helpers/sessions_helper_test.rb b/Sample_App/test/helpers/sessions_helper_test.rb
new file mode 100644
index 0000000..500b3b8
--- /dev/null
+++ b/Sample_App/test/helpers/sessions_helper_test.rb
@@ -0,0 +1,19 @@
+require 'test_helper'
+
+class SessionsHelperTest < ActionView::TestCase
+
+ def setup
+ @user = users(:michael)
+ remember(@user)
+ end
+
+ test "current_user returns right user when session is nil" do
+ assert_equal @user, current_user
+ assert is_logged_in?
+ end
+
+ test "current_user returns nil when remember digest is wrong" do
+ @user.update_attribute(:remember_digest, User.digest(User.new_token))
+ assert_nil current_user
+ end
+end
\ No newline at end of file
diff --git a/Sample_App/test/integration/.keep b/Sample_App/test/integration/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/integration/site_layout_test.rb b/Sample_App/test/integration/site_layout_test.rb
new file mode 100644
index 0000000..a0f0076
--- /dev/null
+++ b/Sample_App/test/integration/site_layout_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class SiteLayoutTest < ActionDispatch::IntegrationTest
+ test "layout links" do
+ get root_path
+ assert_template 'static_pages/home'
+ assert_select "a[href=?]", root_path, count: 2
+ assert_select "a[href=?]", help_path
+ assert_select "a[href=?]", about_path
+ assert_select "a[href=?]", contact_path
+ get contact_path
+ assert_select "title", full_title("Contact")
+ end
+end
diff --git a/Sample_App/test/integration/users_edit_test.rb b/Sample_App/test/integration/users_edit_test.rb
new file mode 100644
index 0000000..19687d4
--- /dev/null
+++ b/Sample_App/test/integration/users_edit_test.rb
@@ -0,0 +1,53 @@
+require 'test_helper'
+
+class UsersEditTest < ActionDispatch::IntegrationTest
+ def setup
+ @user = users(:michael)
+ end
+
+ test "unsuccessful edit" do
+ log_in_as(@user)
+ get edit_user_path(@user)
+ assert_template 'users/edit'
+ patch user_path(@user), params: { user: { name: "",
+ email: "foo@invalid",
+ password: "foo",
+ password_confirmation: "bar" } }
+
+ assert_template 'users/edit'
+ end
+
+ test "successful edit" do
+ log_in_as(@user)
+ get edit_user_path(@user)
+ assert_template 'users/edit'
+ name = "Foo Bar"
+ email = "foo@bar.com"
+ patch user_path(@user), params: { user: { name: name,
+ email: email,
+ password: "",
+ password_confirmation: "" } }
+ assert_not flash.empty?
+ assert_redirected_to @user
+ @user.reload
+ assert_equal name, @user.name
+ assert_equal email, @user.email
+ end
+
+ test "successful edit with friendly forwarding" do
+ get edit_user_path(@user)
+ log_in_as(@user)
+ assert_redirected_to edit_user_url(@user)
+ name = "Foo Bar"
+ email = "foo@bar.com"
+ patch user_path(@user), params: { user: { name: name,
+ email: email,
+ password: "",
+ password_confirmation: "" } }
+ assert_not flash.empty?
+ assert_redirected_to @user
+ @user.reload
+ assert_equal name, @user.name
+ assert_equal email, @user.email
+ end
+end
diff --git a/Sample_App/test/integration/users_index_test.rb b/Sample_App/test/integration/users_index_test.rb
new file mode 100644
index 0000000..edff9cd
--- /dev/null
+++ b/Sample_App/test/integration/users_index_test.rb
@@ -0,0 +1,31 @@
+require 'test_helper'
+
+class UsersIndexTest < ActionDispatch::IntegrationTest
+ def setup
+ @admin = users(:michael)
+ @non_admin = users(:archer)
+ end
+
+ test "index as admin including pagination and delete links" do
+ log_in_as(@admin)
+ get users_path
+ assert_template 'users/index'
+ assert_select 'div.pagination'
+ first_page_of_users = User.paginate(page: 1)
+ first_page_of_users.each do |user|
+ assert_select 'a[href=?]', user_path(user), text: user.name
+ unless user == @admin
+ assert_select 'a[href=?]', user_path(user), text: 'delete'
+ end
+ end
+ assert_difference 'User.count', -1 do
+ delete user_path(@non_admin)
+ end
+ end
+
+ test "index as non-admin" do
+ log_in_as(@non_admin)
+ get users_path
+ assert_select 'a', text: 'delete', count: 0
+ end
+end
diff --git a/Sample_App/test/integration/users_login_test.rb b/Sample_App/test/integration/users_login_test.rb
new file mode 100644
index 0000000..220eda4
--- /dev/null
+++ b/Sample_App/test/integration/users_login_test.rb
@@ -0,0 +1,64 @@
+require 'test_helper'
+
+class UsersLoginTest < ActionDispatch::IntegrationTest
+ def setup
+ @user = users(:michael)
+ end
+
+ test "login with invalid information" do
+ get login_path
+ assert_template 'sessions/new'
+ post login_path, params: { session: { email: "", password: "" } }
+ assert_template 'sessions/new'
+ assert_not flash.empty?
+ get root_path
+ assert flash.empty?
+ end
+
+ test "login with valid information" do
+ get login_path
+ post login_path, params: { session: { email: @user.email,
+ password: 'password' } }
+ assert_redirected_to @user
+ follow_redirect!
+ assert_template 'users/show'
+ assert_select "a[href=?]", login_path, count: 0
+ assert_select "a[href=?]", logout_path
+ assert_select "a[href=?]", user_path(@user)
+ end
+
+ test "login with valid information followed by logout" do
+ get login_path
+ post login_path, params: { session: { email: @user.email,
+ password: 'password' } }
+ assert is_logged_in?
+ assert_redirected_to @user
+ follow_redirect!
+ assert_template 'users/show'
+ assert_select "a[href=?]", login_path, count: 0
+ assert_select "a[href=?]", logout_path
+ assert_select "a[href=?]", user_path(@user)
+ delete logout_path
+ assert_not is_logged_in?
+ assert_redirected_to root_url
+ # Simulate a user clicking logout in a second window.
+ delete logout_path
+ follow_redirect!
+ assert_select "a[href=?]", login_path
+ assert_select "a[href=?]", logout_path, count: 0
+ assert_select "a[href=?]", user_path(@user), count: 0
+ end
+
+ test "login with remembering" do
+ log_in_as(@user, remember_me: '1')
+ assert_not_empty cookies[:remember_token]
+ end
+
+ test "login without remembering" do
+ # Log in to set the cookie.
+ log_in_as(@user, remember_me: '1')
+ # Log in again and verify that the cookie is deleted.
+ log_in_as(@user, remember_me: '0')
+ assert_empty cookies[:remember_token]
+ end
+end
diff --git a/Sample_App/test/integration/users_signup_test.rb b/Sample_App/test/integration/users_signup_test.rb
new file mode 100644
index 0000000..b975745
--- /dev/null
+++ b/Sample_App/test/integration/users_signup_test.rb
@@ -0,0 +1,27 @@
+require 'test_helper'
+
+class UsersSignupTest < ActionDispatch::IntegrationTest
+ test "invalid signup information" do
+ get signup_path
+ assert_no_difference 'User.count' do
+ post users_path, params: { user: { name: "",
+ email: "user@invalid",
+ password: "foo",
+ password_confirmation: "bar" } }
+ end
+ assert_template 'users/new'
+ end
+
+ test "valid signup information" do
+ get signup_path
+ assert_difference 'User.count', 1 do
+ post users_path, params: { user: { name: "Example User",
+ email: "user@example.com",
+ password: "password",
+ password_confirmation: "password" } }
+ end
+ follow_redirect!
+ assert_template 'users/show'
+ assert is_logged_in?
+ end
+end
diff --git a/Sample_App/test/mailers/.keep b/Sample_App/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/models/.keep b/Sample_App/test/models/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/models/user_test.rb b/Sample_App/test/models/user_test.rb
new file mode 100644
index 0000000..19168ad
--- /dev/null
+++ b/Sample_App/test/models/user_test.rb
@@ -0,0 +1,80 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+ def setup
+ @user = User.new(name: "Example user", email: "user@example.com",
+ password: "test123", password_confirmation: "test123")
+ end
+
+ test "should be valid" do
+ assert @user.valid?
+ end
+
+ test "name should be present" do
+ @user.name = " "
+ assert_not @user.valid?
+ end
+
+ test "email should be present" do
+ @user.email = " "
+ assert_not @user.valid?
+ end
+
+ test "name should not be too long" do
+ @user.name = "a" * 51
+ assert_not @user.valid?
+ end
+
+ test "email should not be too long" do
+ @user.email = "a" * 244 + "@example.com"
+ assert_not @user.valid?
+ end
+
+ test "email validation should accept valid addresses" do
+ valid_addresses = %w[user@example.com USER@foo.COM A_US-ER@foo.bar.org
+ first.last@foo.jp alice+bob@baz.cn]
+ valid_addresses.each do |valid_address|
+ @user.email = valid_address
+ assert @user.valid?, "#{valid_address.inspect} should be valid"
+ end
+ end
+
+ test "email validation should reject invalid addresses" do
+ invalid_addresses = %w[user@example,com user_at_foo.org user.name@example.
+ foo@bar_baz.com foo@bar+baz.com]
+ invalid_addresses.each do |invalid_address|
+ @user.email = invalid_address
+ assert_not @user.valid?, "#{invalid_address.inspect} should be invalid"
+ end
+ end
+
+ test "email addresses should be unique" do
+ duplicate_user = @user.dup
+ @user.save
+ assert_not duplicate_user.valid?
+ end
+
+ test "email addresses should be saved as lower-case" do
+ mixed_case_email = "Foo@ExAMPle.CoM"
+ @user.email = mixed_case_email
+ @user.save
+ assert_equal mixed_case_email.downcase, @user.reload.email
+ end
+
+ test "password should be present (nonblank)" do
+ @user.password = @user.password_confirmation = " " * 6
+ assert_not @user.valid?
+ end
+
+ test "password should have a minimum length" do
+ @user.password = @user.password_confirmation = "a" * 5
+ assert_not @user.valid?
+ end
+
+ test "authenticated? should return false for a user with nil digest" do
+ assert_not @user.authenticated?('')
+ end
+end
diff --git a/Sample_App/test/system/.keep b/Sample_App/test/system/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/test/test_helper.rb b/Sample_App/test/test_helper.rb
new file mode 100644
index 0000000..e568227
--- /dev/null
+++ b/Sample_App/test/test_helper.rb
@@ -0,0 +1,33 @@
+ENV['RAILS_ENV'] ||= 'test'
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+require "minitest/reporters"
+Minitest::Reporters.use!
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+ include ApplicationHelper
+
+ def is_logged_in?
+ !session[:user_id].nil?
+ end
+
+ def log_in_as(user)
+ session[:user_id] = user.id
+ end
+
+
+ # Add more helper methods to be used by all tests here...
+end
+
+
+class ActionDispatch::IntegrationTest
+
+ # Log in as a particular user.
+ def log_in_as(user, password: 'password', remember_me: '1')
+ post login_path, params: { session: { email: user.email,
+ password: password,
+ remember_me: remember_me } }
+ end
+end
\ No newline at end of file
diff --git a/Sample_App/tmp/.keep b/Sample_App/tmp/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/Sample_App/vendor/.keep b/Sample_App/vendor/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/sample_app b/sample_app
deleted file mode 160000
index a5b83c0..0000000
--- a/sample_app
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a5b83c0709ff74aa6ffa57624a0c3e4eeb539fa6