2 | <%= render partial: 'form', locals: { user: @user } %>
3 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # puts "\n== Copying sample files =="
22 | # unless File.exist?('config/database.yml')
23 | # cp 'config/database.yml.sample', 'config/database.yml'
24 | # end
25 |
26 | puts "\n== Preparing database =="
27 | system! 'bin/rails db:setup'
28 |
29 | puts "\n== Removing old logs and tempfiles =="
30 | system! 'bin/rails log:clear tmp:clear'
31 |
32 | puts "\n== Restarting application server =="
33 | system! 'bin/rails restart'
34 | end
35 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 App
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 | config.i18n.default_locale = :ja
15 | config.time_zone = 'Tokyo'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # MySQL. Versions 5.0 and up are supported.
2 | #
3 | # Install the MySQL driver
4 | # gem install mysql2
5 | #
6 | # Ensure the MySQL gem is defined in your Gemfile
7 | # gem 'mysql2'
8 | #
9 | # And be sure to use new-style password hashing:
10 | # http://dev.mysql.com/doc/refman/5.7/en/old-client.html
11 | #
12 | default: &default
13 | adapter: mysql2
14 | encoding: utf8
15 | pool: 5
16 | username: root
17 | password: password
18 | host: db
19 |
20 | development:
21 | <<: *default
22 | database: app_development
23 |
24 | # Warning: The database defined as "test" will be erased and
25 | # re-generated from your development database when you run "rake".
26 | # Do not set this db to the same as development or production.
27 | test:
28 | <<: *default
29 | database: app_test
30 |
31 | # As with config/secrets.yml, you never want to store sensitive information,
32 | # like your database password, in your source code. If your source code is
33 | # ever seen by anyone, they now have access to your database.
34 | #
35 | # Instead, provide the password as a unix environment variable when you boot
36 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
37 | # for a full rundown on how to provide these environment variables in a
38 | # production deployment.
39 | #
40 | # On Heroku and other platform providers, you may have a full connection URL
41 | # available as an environment variable. For example:
42 | #
43 | # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
44 | #
45 | # You can use this database configuration with:
46 | #
47 | # production:
48 | # url: <%= ENV['DATABASE_URL'] %>
49 | #
50 | production:
51 | <<: *default
52 | database: app_production
53 | username: app
54 | password: <%= ENV['APP_DATABASE_PASSWORD'] %>
55 |
--------------------------------------------------------------------------------
/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 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 | config.reload_classes_only_on_change = false
9 |
10 | # Do not eager load code on boot.
11 | config.eager_load = false
12 |
13 | # Show full error reports.
14 | config.consider_all_requests_local = true
15 |
16 | # Enable/disable caching. By default caching is disabled.
17 | if Rails.root.join('tmp/caching-dev.txt').exist?
18 | config.action_controller.perform_caching = true
19 |
20 | config.cache_store = :memory_store
21 | config.public_file_server.headers = {
22 | 'Cache-Control' => 'public, max-age=172800'
23 | }
24 | else
25 | config.action_controller.perform_caching = false
26 |
27 | config.cache_store = :null_store
28 | end
29 |
30 | # Don't care if the mailer can't send.
31 | config.action_mailer.raise_delivery_errors = false
32 |
33 | config.action_mailer.perform_caching = false
34 |
35 | # Print deprecation notices to the Rails logger.
36 | config.active_support.deprecation = :log
37 |
38 | # Raise an error on page load if there are pending migrations.
39 | config.active_record.migration_error = :page_load
40 |
41 | # Debug mode disables concatenation and preprocessing of assets.
42 | # This option may cause significant delays in view rendering with a large
43 | # number of complex assets.
44 | config.assets.debug = true
45 |
46 | # Suppress logger output for asset requests.
47 | config.assets.quiet = true
48 |
49 | # Raises error for missing translations
50 | # config.action_view.raise_on_missing_translations = true
51 |
52 | # Use an evented file watcher to asynchronously detect changes in source code,
53 | # routes, locales, etc. This feature depends on the listen gem.
54 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
55 | end
56 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Disable serving static files from the `/public` folder by default since
18 | # Apache or NGINX already handles this.
19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20 |
21 | # Compress JavaScripts and CSS.
22 | config.assets.js_compressor = :uglifier
23 | # config.assets.css_compressor = :sass
24 |
25 | # Do not fallback to assets pipeline if a precompiled asset is missed.
26 | config.assets.compile = false
27 |
28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29 |
30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31 | # config.action_controller.asset_host = 'http://assets.example.com'
32 |
33 | # Specifies the header that your server uses for sending files.
34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36 |
37 | # Mount Action Cable outside main process or domain
38 | # config.action_cable.mount_path = nil
39 | # config.action_cable.url = 'wss://example.com/cable'
40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41 |
42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43 | # config.force_ssl = true
44 |
45 | # Use the lowest log level to ensure availability of diagnostic information
46 | # when problems arise.
47 | config.log_level = :debug
48 |
49 | # Prepend all log lines with the following tags.
50 | config.log_tags = [ :request_id ]
51 |
52 | # Use a different cache store in production.
53 | # config.cache_store = :mem_cache_store
54 |
55 | # Use a real queuing backend for Active Job (and separate queues per environment)
56 | # config.active_job.queue_adapter = :resque
57 | # config.active_job.queue_name_prefix = "app_#{Rails.env}"
58 | config.action_mailer.perform_caching = false
59 |
60 | # Ignore bad email addresses and do not raise email delivery errors.
61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62 | # config.action_mailer.raise_delivery_errors = false
63 |
64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65 | # the I18n.default_locale when a translation cannot be found).
66 | config.i18n.fallbacks = true
67 |
68 | # Send deprecation notices to registered listeners.
69 | config.active_support.deprecation = :notify
70 |
71 | # Use default logging formatter so that PID and timestamp are not suppressed.
72 | config.log_formatter = ::Logger::Formatter.new
73 |
74 | # Use a different logger for distributed setups.
75 | # require 'syslog/logger'
76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
77 |
78 | if ENV["RAILS_LOG_TO_STDOUT"].present?
79 | logger = ActiveSupport::Logger.new(STDOUT)
80 | logger.formatter = config.log_formatter
81 | config.logger = ActiveSupport::TaggedLogging.new(logger)
82 | end
83 |
84 | # Do not dump schema after migrations.
85 | config.active_record.dump_schema_after_migration = false
86 | end
87 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => 'public, max-age=3600'
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ApplicationController.renderer.defaults.merge!(
4 | # http_host: 'example.org',
5 | # https: false
6 | # )
7 |
--------------------------------------------------------------------------------
/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 app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/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/kaminari_config.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | Kaminari.configure do |config|
3 | config.default_per_page = 10
4 | # config.max_per_page = nil
5 | # config.window = 4
6 | # config.outer_window = 0
7 | # config.left = 0
8 | # config.right = 0
9 | # config.page_method_name = :page
10 | # config.param_name = :page
11 | # config.params_on_first_page = false
12 | end
13 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/new_framework_defaults.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 5.0 upgrade.
4 | #
5 | # Read the Rails 5.0 release notes for more info on each option.
6 |
7 | # Enable per-form CSRF tokens. Previous versions had false.
8 | Rails.application.config.action_controller.per_form_csrf_tokens = true
9 |
10 | # Enable origin-checking CSRF mitigation. Previous versions had false.
11 | Rails.application.config.action_controller.forgery_protection_origin_check = true
12 |
13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
14 | # Previous versions had false.
15 | ActiveSupport.to_time_preserves_timezone = true
16 |
17 | # Require `belongs_to` associations by default. Previous versions had false.
18 | Rails.application.config.active_record.belongs_to_required_by_default = true
19 |
20 | # Do not halt callback chains when a callback returns false. Previous versions had true.
21 | # ActiveSupport.halt_callback_chains_on_return_false = false
22 |
23 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
24 | Rails.application.config.ssl_options = { hsts: { subdomains: true } }
25 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_app_session'
4 |
--------------------------------------------------------------------------------
/config/initializers/time_formats.rb:
--------------------------------------------------------------------------------
1 | Time::DATE_FORMATS[:datetime_jp] = '%Y年%m月%d日 %H時%M分'
2 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/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 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/config/locales/ja.yml:
--------------------------------------------------------------------------------
1 | ja:
2 | activerecord:
3 | attributes:
4 | user:
5 | name: ユーザー名
6 | password: パスワード
7 | password_confirmation: パスワード(確認)
8 | board:
9 | name: 名前
10 | title: タイトル
11 | body: 本文
12 | comment:
13 | name: 名前
14 | comment: コメント
15 | views:
16 | pagination:
17 | first: 最初
18 | last: 最後
19 | previous: 前
20 | next: 次
21 | truncate: ...
22 |
--------------------------------------------------------------------------------
/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 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory. If you use this option
30 | # you need to make sure to reconnect any threads in the `on_worker_boot`
31 | # block.
32 | #
33 | # preload_app!
34 |
35 | # The code in the `on_worker_boot` will be called if you are using
36 | # clustered mode by specifying a number of `workers`. After each worker
37 | # process is booted this block will be run, if you are using `preload_app!`
38 | # option you will want to use this block to reconnect to any threads
39 | # or connections that may have been created at application boot, Ruby
40 | # cannot share connections between processes.
41 | #
42 | # on_worker_boot do
43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44 | # end
45 |
46 | # Allow puma to be restarted by `rails restart` command.
47 | plugin :tmp_restart
48 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | get 'mypage', to: 'users#me'
3 | post 'login', to: 'sessions#create'
4 | delete 'logout', to: 'sessions#destroy'
5 |
6 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
7 | root 'home#index'
8 | resources :users, only: %i[new create]
9 | resources :boards
10 | resources :comments, only: %i[create destroy]
11 | end
12 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 63aa879c0cc7b86fb5fe9103d0f9a643f3ca076468e2213bdf66d15484bab740475e8efedc57fd43d1756cf00a0fbfd4a3c8cea57bda044661a4fc923b6cfe7f
15 |
16 | test:
17 | secret_key_base: 6d0e1610ceab665b1957160c967684bde46e8fc8d511b705a80eed016b7fa5354398f3f0a095a10516f70adeac425f6e1a0cfc8a4288fe1a0020815c5ad03c12
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w(
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | ).each { |path| Spring.watch(path) }
7 |
--------------------------------------------------------------------------------
/db/migrate/20180217122153_create_boards.rb:
--------------------------------------------------------------------------------
1 | class CreateBoards < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :boards do |t|
4 | t.string :name
5 | t.string :title
6 | t.text :body
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20180315233935_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :comments do |t|
4 | t.references :board, foreign_key: true
5 | t.string :name, null: false
6 | t.text :comment, null: false
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20180324120737_create_tags.rb:
--------------------------------------------------------------------------------
1 | class CreateTags < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :tags do |t|
4 | t.string :name, null: false
5 |
6 | t.timestamps
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20180324120941_create_board_tag_relations.rb:
--------------------------------------------------------------------------------
1 | class CreateBoardTagRelations < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :board_tag_relations do |t|
4 | t.references :board, foreign_key: true
5 | t.references :tag, foreign_key: true
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20180506115954_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :users do |t|
4 | t.string :name, null: false
5 | t.string :password_digest, null: false
6 |
7 | t.timestamps
8 | end
9 | add_index :users, :name, unique: true
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20181128051946_add_birthday_to_user.rb:
--------------------------------------------------------------------------------
1 | class AddBirthdayToUser < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :users, :birthday, :date
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 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 2018_11_28_051946) do
14 |
15 | create_table "board_tag_relations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
16 | t.integer "board_id"
17 | t.integer "tag_id"
18 | t.datetime "created_at", null: false
19 | t.datetime "updated_at", null: false
20 | t.index ["board_id"], name: "index_board_tag_relations_on_board_id"
21 | t.index ["tag_id"], name: "index_board_tag_relations_on_tag_id"
22 | end
23 |
24 | create_table "boards", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
25 | t.string "name"
26 | t.string "title"
27 | t.text "body"
28 | t.datetime "created_at", null: false
29 | t.datetime "updated_at", null: false
30 | end
31 |
32 | create_table "comments", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
33 | t.integer "board_id"
34 | t.string "name", null: false
35 | t.text "comment", null: false
36 | t.datetime "created_at", null: false
37 | t.datetime "updated_at", null: false
38 | t.index ["board_id"], name: "index_comments_on_board_id"
39 | end
40 |
41 | create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
42 | t.string "name", null: false
43 | t.datetime "created_at", null: false
44 | t.datetime "updated_at", null: false
45 | end
46 |
47 | create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
48 | t.string "name", null: false
49 | t.string "password_digest", null: false
50 | t.datetime "created_at", null: false
51 | t.datetime "updated_at", null: false
52 | t.date "birthday"
53 | t.index ["name"], name: "index_users_on_name", unique: true
54 | end
55 |
56 | add_foreign_key "board_tag_relations", "boards"
57 | add_foreign_key "board_tag_relations", "tags"
58 | add_foreign_key "comments", "boards"
59 | end
60 |
--------------------------------------------------------------------------------
/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 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 |
9 | if Rails.env == 'development'
10 | (1..50).each do |i|
11 | Board.create(name: "ユーザー#{i}", title: "タイトル#{i}", body: "本文#{i}")
12 | end
13 |
14 | Tag.create([
15 | { name: 'Ruby' },
16 | { name: 'Ruby on Rails4' },
17 | { name: 'Ruby on Rails5' },
18 | { name: 'Python2' },
19 | { name: 'Python3' },
20 | { name: 'Django2' }
21 | ])
22 | end
23 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | web:
4 | build: .
5 | command: bundle exec rails s -p 3000 -b '0.0.0.0'
6 | volumes:
7 | - .:/app
8 | ports:
9 | - 3000:3000
10 | depends_on:
11 | - db
12 | tty: true
13 | stdin_open: true
14 | db:
15 | image: mysql:5.7
16 | volumes:
17 | - db-volume:/var/lib/mysql
18 | environment:
19 | MYSQL_ROOT_PASSWORD: password
20 | volumes:
21 | db-volume:
22 |
23 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/lib/tasks/.keep
--------------------------------------------------------------------------------
/lib/tasks/auto_annotate_models.rake:
--------------------------------------------------------------------------------
1 | # NOTE: only doing this in development as some production environments (Heroku)
2 | # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3 | # NOTE: to have a dev-mode tool do its thing in production.
4 | if Rails.env.development?
5 | require 'annotate'
6 | task :set_annotation_options do
7 | # You can override any of these by setting an environment variable of the
8 | # same name.
9 | Annotate.set_defaults(
10 | 'routes' => 'false',
11 | 'position_in_routes' => 'before',
12 | 'position_in_class' => 'before',
13 | 'position_in_test' => 'before',
14 | 'position_in_fixture' => 'before',
15 | 'position_in_factory' => 'before',
16 | 'position_in_serializer' => 'before',
17 | 'show_foreign_keys' => 'true',
18 | 'show_complete_foreign_keys' => 'false',
19 | 'show_indexes' => 'true',
20 | 'simple_indexes' => 'false',
21 | 'model_dir' => 'app/models',
22 | 'root_dir' => '',
23 | 'include_version' => 'false',
24 | 'require' => '',
25 | 'exclude_tests' => 'false',
26 | 'exclude_fixtures' => 'false',
27 | 'exclude_factories' => 'false',
28 | 'exclude_serializers' => 'false',
29 | 'exclude_scaffolds' => 'true',
30 | 'exclude_controllers' => 'true',
31 | 'exclude_helpers' => 'true',
32 | 'exclude_sti_subclasses' => 'false',
33 | 'ignore_model_sub_dir' => 'false',
34 | 'ignore_columns' => nil,
35 | 'ignore_routes' => nil,
36 | 'ignore_unknown_models' => 'false',
37 | 'hide_limit_column_types' => 'integer,boolean',
38 | 'hide_default_column_types' => 'json,jsonb,hstore',
39 | 'skip_on_db_migrate' => 'false',
40 | 'format_bare' => 'true',
41 | 'format_rdoc' => 'false',
42 | 'format_markdown' => 'false',
43 | 'sort' => 'false',
44 | 'force' => 'false',
45 | 'trace' => 'false',
46 | 'wrapper_open' => nil,
47 | 'wrapper_close' => nil,
48 | 'with_comment' => true
49 | )
50 | end
51 |
52 | Annotate.load_tasks
53 | end
54 |
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/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/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/public/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/public/favicon.ico
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/spec/controllers/users_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe UsersController, type: :controller do
4 | describe 'GET #new' do
5 | before { get :new }
6 |
7 | it 'レスポンスコードが200であること' do
8 | expect(response).to have_http_status(:ok)
9 | end
10 |
11 | it 'newテンプレートをレンダリングすること' do
12 | expect(response).to render_template :new
13 | end
14 |
15 | it '新しいuserオブジェクトがビューに渡されること' do
16 | expect(assigns(:user)).to be_a_new User
17 | end
18 | end
19 |
20 | describe 'POST #create' do
21 | before do
22 | @referer = 'http://localhost'
23 | @request.env['HTTP_REFERER'] = @referer
24 | end
25 |
26 | context '正しいユーザー情報が渡って来た場合' do
27 | let(:params) do
28 | { user: {
29 | name: 'user',
30 | password: 'password',
31 | password_confirmation: 'password',
32 | }
33 | }
34 | end
35 |
36 | it 'ユーザーが一人増えていること' do
37 | expect { post :create, params: params }.to change(User, :count).by(1)
38 | end
39 |
40 | it 'マイページにリダイレクトされること' do
41 | expect(post :create, params: params).to redirect_to(mypage_path)
42 | end
43 | end
44 |
45 | context 'パラメータに正しいユーザー名、確認パスワードが含まれていない場合' do
46 | before do
47 | post(:create, params: {
48 | user: {
49 | name: 'ユーザー1',
50 | password: 'password',
51 | password_confirmation: 'invalid_password'
52 | }
53 | })
54 | end
55 |
56 | it 'リファラーにリダイレクトされること' do
57 | expect(response).to redirect_to(@referer)
58 | end
59 |
60 | it 'ユーザー名のエラーメッセージが含まれていること' do
61 | expect(flash[:error_messages]).to include 'ユーザー名は小文字英数字で入力してください'
62 | end
63 |
64 | it 'パスワード確認のエラーメッセージが含まれていること' do
65 | expect(flash[:error_messages]).to include 'パスワード(確認)とパスワードの入力が一致しません'
66 | end
67 | end
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: users
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255) not null
7 | # password_digest :string(255) not null
8 | # created_at :datetime not null
9 | # updated_at :datetime not null
10 | # birthday :date
11 | #
12 | # Indexes
13 | #
14 | # index_users_on_name (name) UNIQUE
15 | #
16 |
17 | require 'rails_helper'
18 |
19 | RSpec.describe User, type: :model do
20 | describe '#age' do
21 | before do
22 | allow(Time.zone).to receive(:now).and_return(Time.zone.parse('2018/04/01'))
23 | end
24 |
25 | context '20年前の生年月日の場合' do
26 | let(:user) { User.new(birthday: Time.zone.now - 20.years) }
27 |
28 | it '年齢が20歳であること' do
29 | expect(user.age).to eq 20
30 | end
31 | end
32 |
33 | context '10年前に生まれた場合でちょうど誕生日の場合' do
34 | let(:user) { User.new(birthday: Time.zone.parse('2008/04/01')) }
35 |
36 | it '年齢が10歳であること' do
37 | expect(user.age).to eq 10
38 | end
39 | end
40 |
41 | context '10年前に生まれた場合で誕生日が来ていない場合' do
42 | let(:user) { User.new(birthday: Time.zone.parse('2008/04/02')) }
43 |
44 | it '年齢が9歳であること' do
45 | expect(user.age).to eq 9
46 | end
47 | end
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/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 File.expand_path('../../config/environment', __FILE__)
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')].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 | puts e.to_s.strip
31 | exit 1
32 | end
33 | RSpec.configure do |config|
34 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
36 |
37 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
38 | # examples within a transaction, remove the following line or assign false
39 | # instead of true.
40 | config.use_transactional_fixtures = true
41 |
42 | # RSpec Rails can automatically mix in different behaviours to your tests
43 | # based on their file location, for example enabling you to call `get` and
44 | # `post` in specs under `spec/controllers`.
45 | #
46 | # You can disable this behaviour by removing the line below, and instead
47 | # explicitly tag your specs with their type, e.g.:
48 | #
49 | # RSpec.describe UsersController, :type => :controller do
50 | # # ...
51 | # end
52 | #
53 | # The different available types are documented in the features, such as in
54 | # https://relishapp.com/rspec/rspec-rails/docs
55 | config.infer_spec_type_from_file_location!
56 |
57 | # Filter lines from Rails gems in backtraces.
58 | config.filter_rails_from_backtrace!
59 | # arbitrary gems may also be filtered via:
60 | # config.filter_gems_from_backtrace("gem name")
61 | end
62 |
--------------------------------------------------------------------------------
/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 http://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 | =begin
50 | # This allows you to limit a spec run to individual examples or groups
51 | # you care about by tagging them with `:focus` metadata. When nothing
52 | # is tagged with `:focus`, all examples get run. RSpec also provides
53 | # aliases for `it`, `describe`, and `context` that include `:focus`
54 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55 | config.filter_run_when_matching :focus
56 |
57 | # Allows RSpec to persist some state between runs in order to support
58 | # the `--only-failures` and `--next-failure` CLI options. We recommend
59 | # you configure your source control system to ignore this file.
60 | config.example_status_persistence_file_path = "spec/examples.txt"
61 |
62 | # Limits the available syntax to the non-monkey patched syntax that is
63 | # recommended. For more details, see:
64 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67 | config.disable_monkey_patching!
68 |
69 | # Many RSpec users commonly either run the entire suite or an individual
70 | # file, and it's useful to allow more verbose output when running an
71 | # individual spec file.
72 | if config.files_to_run.one?
73 | # Use the documentation formatter for detailed output,
74 | # unless a formatter has already been configured
75 | # (e.g. via a command-line flag).
76 | config.default_formatter = "doc"
77 | end
78 |
79 | # Print the 10 slowest examples and example groups at the
80 | # end of the spec run, to help surface which specs are running
81 | # particularly slow.
82 | config.profile_examples = 10
83 |
84 | # Run specs in random order to surface order dependencies. If you find an
85 | # order dependency and want to debug it, you can fix the order by providing
86 | # the seed, which is printed after each run.
87 | # --seed 1234
88 | config.order = :random
89 |
90 | # Seed global randomization in this process using the `--seed` CLI option.
91 | # Setting this allows you to use `--seed` to deterministically reproduce
92 | # test failures related to randomization by passing the same `--seed` value
93 | # as the one that triggered the failure.
94 | Kernel.srand config.seed
95 | =end
96 | end
97 |
--------------------------------------------------------------------------------
/test/controllers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/controllers/.keep
--------------------------------------------------------------------------------
/test/controllers/comments_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CommentsControllerTest < ActionDispatch::IntegrationTest
4 | test "should get create" do
5 | get comments_create_url
6 | assert_response :success
7 | end
8 |
9 | test "should get destroy" do
10 | get comments_destroy_url
11 | assert_response :success
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/controllers/home_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class HomeControllerTest < ActionDispatch::IntegrationTest
4 | test "should get index" do
5 | get home_index_url
6 | assert_response :success
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/test/controllers/sessions_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class SessionsControllerTest < ActionDispatch::IntegrationTest
4 | test "should get create" do
5 | get sessions_create_url
6 | assert_response :success
7 | end
8 |
9 | test "should get destroy" do
10 | get sessions_destroy_url
11 | assert_response :success
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/controllers/users_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UsersControllerTest < ActionDispatch::IntegrationTest
4 | test "should get new" do
5 | get users_new_url
6 | assert_response :success
7 | end
8 |
9 | test "should get create" do
10 | get users_create_url
11 | assert_response :success
12 | end
13 |
14 | test "should get me" do
15 | get users_me_url
16 | assert_response :success
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/test/fixtures/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/fixtures/.keep
--------------------------------------------------------------------------------
/test/fixtures/board_tag_relations.yml:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: board_tag_relations
4 | #
5 | # id :integer not null, primary key
6 | # board_id :integer
7 | # tag_id :integer
8 | # created_at :datetime not null
9 | # updated_at :datetime not null
10 | #
11 | # Indexes
12 | #
13 | # index_board_tag_relations_on_board_id (board_id)
14 | # index_board_tag_relations_on_tag_id (tag_id)
15 | #
16 | # Foreign Keys
17 | #
18 | # fk_rails_... (board_id => boards.id)
19 | # fk_rails_... (tag_id => tags.id)
20 | #
21 |
22 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
23 |
24 | one:
25 | board: one
26 | tag: one
27 |
28 | two:
29 | board: two
30 | tag: two
31 |
--------------------------------------------------------------------------------
/test/fixtures/boards.yml:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: boards
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255)
7 | # title :string(255)
8 | # body :text(65535)
9 | # created_at :datetime not null
10 | # updated_at :datetime not null
11 | #
12 |
13 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
14 |
15 | one:
16 | name: MyString
17 | title: MyString
18 | body: MyText
19 |
20 | two:
21 | name: MyString
22 | title: MyString
23 | body: MyText
24 |
--------------------------------------------------------------------------------
/test/fixtures/comments.yml:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: comments
4 | #
5 | # id :integer not null, primary key
6 | # board_id :integer
7 | # name :string(255) not null
8 | # comment :text(65535) not null
9 | # created_at :datetime not null
10 | # updated_at :datetime not null
11 | #
12 | # Indexes
13 | #
14 | # index_comments_on_board_id (board_id)
15 | #
16 | # Foreign Keys
17 | #
18 | # fk_rails_... (board_id => boards.id)
19 | #
20 |
21 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
22 |
23 | one:
24 | board: one
25 | name: MyString
26 | comment: MyText
27 |
28 | two:
29 | board: two
30 | name: MyString
31 | comment: MyText
32 |
--------------------------------------------------------------------------------
/test/fixtures/files/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/fixtures/files/.keep
--------------------------------------------------------------------------------
/test/fixtures/tags.yml:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: tags
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255) not null
7 | # created_at :datetime not null
8 | # updated_at :datetime not null
9 | #
10 |
11 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
12 |
13 | one:
14 | name: MyString
15 |
16 | two:
17 | name: MyString
18 |
--------------------------------------------------------------------------------
/test/fixtures/users.yml:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: users
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255) not null
7 | # password_digest :string(255) not null
8 | # created_at :datetime not null
9 | # updated_at :datetime not null
10 | # birthday :date
11 | #
12 | # Indexes
13 | #
14 | # index_users_on_name (name) UNIQUE
15 | #
16 |
17 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
18 |
19 | one:
20 | name: MyString
21 | password_digest: MyString
22 |
23 | two:
24 | name: MyString
25 | password_digest: MyString
26 |
--------------------------------------------------------------------------------
/test/helpers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/helpers/.keep
--------------------------------------------------------------------------------
/test/integration/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/integration/.keep
--------------------------------------------------------------------------------
/test/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/mailers/.keep
--------------------------------------------------------------------------------
/test/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/models/.keep
--------------------------------------------------------------------------------
/test/models/board_tag_relation_test.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: board_tag_relations
4 | #
5 | # id :integer not null, primary key
6 | # board_id :integer
7 | # tag_id :integer
8 | # created_at :datetime not null
9 | # updated_at :datetime not null
10 | #
11 | # Indexes
12 | #
13 | # index_board_tag_relations_on_board_id (board_id)
14 | # index_board_tag_relations_on_tag_id (tag_id)
15 | #
16 | # Foreign Keys
17 | #
18 | # fk_rails_... (board_id => boards.id)
19 | # fk_rails_... (tag_id => tags.id)
20 | #
21 |
22 | require 'test_helper'
23 |
24 | class BoardTagRelationTest < ActiveSupport::TestCase
25 | # test "the truth" do
26 | # assert true
27 | # end
28 | end
29 |
--------------------------------------------------------------------------------
/test/models/board_test.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: boards
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255)
7 | # title :string(255)
8 | # body :text(65535)
9 | # created_at :datetime not null
10 | # updated_at :datetime not null
11 | #
12 |
13 | require 'test_helper'
14 |
15 | class BoardTest < ActiveSupport::TestCase
16 | # test "the truth" do
17 | # assert true
18 | # end
19 | end
20 |
--------------------------------------------------------------------------------
/test/models/comment_test.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: comments
4 | #
5 | # id :integer not null, primary key
6 | # board_id :integer
7 | # name :string(255) not null
8 | # comment :text(65535) not null
9 | # created_at :datetime not null
10 | # updated_at :datetime not null
11 | #
12 | # Indexes
13 | #
14 | # index_comments_on_board_id (board_id)
15 | #
16 | # Foreign Keys
17 | #
18 | # fk_rails_... (board_id => boards.id)
19 | #
20 |
21 | require 'test_helper'
22 |
23 | class CommentTest < ActiveSupport::TestCase
24 | # test "the truth" do
25 | # assert true
26 | # end
27 | end
28 |
--------------------------------------------------------------------------------
/test/models/tag_test.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: tags
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255) not null
7 | # created_at :datetime not null
8 | # updated_at :datetime not null
9 | #
10 |
11 | require 'test_helper'
12 |
13 | class TagTest < ActiveSupport::TestCase
14 | # test "the truth" do
15 | # assert true
16 | # end
17 | end
18 |
--------------------------------------------------------------------------------
/test/models/user_test.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: users
4 | #
5 | # id :integer not null, primary key
6 | # name :string(255) not null
7 | # password_digest :string(255) not null
8 | # created_at :datetime not null
9 | # updated_at :datetime not null
10 | # birthday :date
11 | #
12 | # Indexes
13 | #
14 | # index_users_on_name (name) UNIQUE
15 | #
16 |
17 | require 'test_helper'
18 |
19 | class UserTest < ActiveSupport::TestCase
20 | # test "the truth" do
21 | # assert true
22 | # end
23 | end
24 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV['RAILS_ENV'] ||= 'test'
2 | require File.expand_path('../../config/environment', __FILE__)
3 | require 'rails/test_help'
4 |
5 | class ActiveSupport::TestCase
6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7 | fixtures :all
8 |
9 | # Add more helper methods to be used by all tests here...
10 | end
11 |
--------------------------------------------------------------------------------
/tmp/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/tmp/.keep
--------------------------------------------------------------------------------
/vendor/assets/javascripts/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/vendor/assets/javascripts/.keep
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/vendor/assets/stylesheets/.keep
--------------------------------------------------------------------------------