-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dummy Rails app test suite and add Github CI workflow
- Loading branch information
1 parent
5d383d8
commit eb9e3ac
Showing
40 changed files
with
367 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: ['master'] | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
RAILS_ENV: test | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
### TEST RUBY VERSIONS | ||
- ruby: "2.5" | ||
- ruby: "2.6" | ||
- ruby: "2.7" | ||
- ruby: "3.0" | ||
- ruby: "3.1" | ||
- ruby: "3.2" | ||
### TEST RAILS VERSIONS | ||
- ruby: "2.6" | ||
env: | ||
RAILS_VERSION: "5.2" | ||
- ruby: "2.6" | ||
env: | ||
RAILS_VERSION: "6.0" | ||
- ruby: "2.6" | ||
env: | ||
RAILS_VERSION: "6.1" | ||
- ruby: "3.2" | ||
env: | ||
RAILS_VERSION: "7.0" | ||
- ruby: "3.2" | ||
env: | ||
RAILS_VERSION: "7.1" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "${{ matrix.ruby }}" | ||
bundler-cache: false ### not compatible with ENV style gemfile | ||
|
||
- name: Run test | ||
run: | | ||
bundle install | ||
bundle exec rake test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env rake | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
|
||
Dummy::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//= link_tree ../images | ||
//= link_directory ../javascripts .js | ||
//= link_directory ../stylesheets .css .scss |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* | ||
*= require_self | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ApplicationCable | ||
class Channel < ActionCable::Channel::Base | ||
end | ||
|
||
class Connection < ActionCable::Connection::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ApplicationJob < ActiveJob::Base | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationRecord < ActiveRecord::Base | ||
self.abstract_class = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Comment < ApplicationRecord | ||
belongs_to :post | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Post < ApplicationRecord | ||
has_many :comments | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Dummy App</title> | ||
<%= stylesheet_link_tag "application" %> | ||
<%= javascript_include_tag "application" %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
<body> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file is used by Rack-based servers to start the application. | ||
|
||
require ::File.expand_path('../config/environment', __FILE__) | ||
run Dummy::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require File.expand_path('../boot', __FILE__) | ||
|
||
require 'rails/all' | ||
|
||
Bundler.require | ||
|
||
module Dummy | ||
class Application < Rails::Application | ||
config.load_defaults Rails::VERSION::STRING.to_f | ||
|
||
# Settings in config/environments/* take precedence over those specified here. | ||
# Application configuration should go into files in config/initializers | ||
# -- all .rb files in that directory are automatically loaded. | ||
|
||
# Custom directories with classes and modules you want to be autoloadable. | ||
# config.autoload_paths += %W(#{config.root}/extras) | ||
|
||
# Only load the plugins named here, in the order given (default is alphabetical). | ||
# :all can be used as a placeholder for all plugins not explicitly named. | ||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ] | ||
|
||
# Activate observers that should always be running. | ||
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer | ||
|
||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | ||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. | ||
# config.time_zone = 'Central Time (US & Canada)' | ||
|
||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. | ||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] | ||
# config.i18n.default_locale = :de | ||
|
||
# Configure the default encoding used in templates for Ruby 1.9. | ||
config.encoding = "utf-8" | ||
|
||
# Configure sensitive parameters which will be filtered from the log file. | ||
config.filter_parameters += [:password] | ||
|
||
config.generators.test_framework = false | ||
config.generators.helper = false | ||
config.generators.stylesheets = false | ||
config.generators.javascripts = false | ||
|
||
config.after_initialize do | ||
ActiveRecord::Migration.migrate(Rails.root.join("db/migrate/*").to_s) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'rubygems' | ||
gemfile = File.expand_path('../../../../Gemfile', __FILE__) | ||
|
||
if File.exist?(gemfile) | ||
ENV['BUNDLE_GEMFILE'] = gemfile | ||
require 'bundler' | ||
Bundler.setup | ||
end | ||
|
||
$:.unshift File.expand_path('../../../../lib', __FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
development: | ||
adapter: litecable | ||
|
||
test: | ||
adapter: test | ||
#adapter: litecable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
development: | ||
adapter: litedb | ||
database: db/development/database.sqlite3.db | ||
|
||
test: | ||
adapter: litedb | ||
database: db/test/database.sqlite3.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Load the rails application | ||
require File.expand_path('../application', __FILE__) | ||
|
||
# Initialize the rails application | ||
Dummy::Application.initialize! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Dummy::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 | ||
|
||
# Configure static asset server for tests with Cache-Control for performance | ||
config.serve_static_assets = true | ||
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } | ||
|
||
# Log error messages when you accidentally call methods on nil | ||
config.whiny_nils = true | ||
|
||
# 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 | ||
|
||
# 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 | ||
|
||
# Use SQL instead of Active Record's schema dumper when creating the test database. | ||
# This is necessary if your schema can't be completely dumped by the schema dumper, | ||
# like if you have constraints or database-specific column types | ||
# config.active_record.schema_format = :sql | ||
|
||
# Print deprecation notices to the stderr | ||
config.active_support.deprecation = :stderr | ||
|
||
config.eager_load = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
# Add new inflection rules using the following format | ||
# (all these examples are active by default): | ||
# ActiveSupport::Inflector.inflections do |inflect| | ||
# inflect.plural /^(ox)$/i, '\1en' | ||
# inflect.singular /^(ox)en/i, '\1' | ||
# inflect.irregular 'person', 'people' | ||
# inflect.uncountable %w( fish sheep ) | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 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 | ||
# Mime::Type.register_alias "text/html", :iphone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
# Your secret key for verifying the integrity of signed cookies. | ||
# If you change this key, all old signed cookies will become invalid! | ||
# Make sure the secret is at least 30 characters and all random, | ||
# no regular words or you'll be exposed to dictionary attacks. | ||
|
||
gem_version = ActiveRecord.gem_version | ||
if gem_version <= Gem::Version.new("5.1") | ||
Dummy::Application.config.secret_token = '4f337f0063fbb4a724dd8da15419679300da990ae4f6c94d36c714a3cd07e9653fc42d902cf33a9b9449a28e7eb2673f928172d65a090fa3c9156d6beea8d16c' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session' | ||
|
||
# Use the database for sessions instead of the cookie-based default, | ||
# which shouldn't be used to store highly confidential information | ||
# (create the session table with "rails generate session_migration") | ||
# Dummy::Application.config.session_store :active_record_store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
# Disable root element in JSON by default. | ||
ActiveSupport.on_load(:active_record) do | ||
self.include_root_in_json = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Sample localization file for English. Add more files in this directory for other locales. | ||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. | ||
|
||
en: | ||
hello: "Hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Dummy::Application.routes.draw do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
# Your secret key is used for verifying the integrity of signed cookies. | ||
# If you change this key, all old signed cookies will become invalid! | ||
|
||
# Make sure the secret is at least 30 characters and all random, | ||
# no regular words or you'll be exposed to dictionary attacks. | ||
# You can use `rake secret` to generate a secure secret key. | ||
|
||
# Make sure the secrets in this file are kept private | ||
# if you're sharing your code publicly. | ||
|
||
development: | ||
secret_key_base: d28054e102cd55dcd684cee239d31ddf1e1acd83bd879dd5f671e989f5c9d94ec1ede00e7fcf9b6bde4cd115f93c54e3ba6c5dc05d233292542f27a79706fcb4 | ||
|
||
test: | ||
secret_key_base: 378b4f2309d4898f5170b41624e19bf60ce8a154ad87c100e8846bddcf4c28b72b533f2e73738ef8f6eabb7a773a0a0e7c32c0649916c5f280eb7ac621fc318c | ||
|
||
# Do not keep production secrets in the repository, | ||
# instead read values from the environment. | ||
production: | ||
secret_key_base: 5e73c057b92f67f980fbea4c1c2c495b25def0048f8c1c040fed9c08f49cd50a2ebf872dd87857afc0861479e9382fceb7d9837a0bce546c2f7594e2f4da45e3 |
16 changes: 16 additions & 0 deletions
16
test/dummy_app/db/migrate/20231102155312_setup_test_tables.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class SetupTestTables < ActiveRecord::Migration::Current | ||
|
||
def change | ||
create_table :posts do |t| | ||
t.text :title, :content | ||
t.timestamps | ||
end | ||
|
||
create_table :comments do |t| | ||
t.string :content | ||
t.references :post | ||
t.timestamps | ||
end | ||
end | ||
|
||
end |
Empty file.
Empty file.
Oops, something went wrong.