Skip to content

Commit 42663c7

Browse files
committed
Add test coverage
1 parent 0ed3d69 commit 42663c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+8249
-14
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
/spec/reports/
88
/tmp/
99

10+
/spec/dummy/db/*.sqlite3
11+
/spec/dummy/db/*.sqlite3-journal
12+
/spec/dummy/db/log/*.log
13+
/spec/dummy/tmp/
14+
/spec/dummy/.sass-cache
15+
1016
# rspec failure tracking
1117
.rspec_status

.rspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
--format documentation
22
--color
3-
--require spec_helper
3+
--require rails_helper

inertia_rails.gemspec

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ Gem::Specification.new do |spec|
2727

2828
spec.add_development_dependency "bundler", "~> 2.0"
2929
spec.add_development_dependency "rake", "~> 10.0"
30-
spec.add_development_dependency "rspec", "~> 3.0"
30+
spec.add_development_dependency "rspec-rails", "~> 3.0"
31+
spec.add_development_dependency "rails"
32+
spec.add_development_dependency "rails-controller-testing"
33+
spec.add_development_dependency "sqlite3"
3134
end

spec/dummy/.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.3

spec/dummy/Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require_relative 'config/application'
5+
6+
Rails.application.load_tasks
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//= link_tree ../images
2+
//= link_directory ../stylesheets .css

spec/dummy/app/assets/images/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
9+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10+
* files in this directory. Styles in this file should be added after the last require_* statement.
11+
* It is generally better to create a new file per style scope.
12+
*
13+
*= require_tree .
14+
*= require_self
15+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Channel < ActionCable::Channel::Base
3+
end
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Connection < ActionCable::Connection::Base
3+
end
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::Base
2+
end

spec/dummy/app/controllers/concerns/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class InertiaRenderTestController < ApplicationController
2+
3+
def props
4+
render inertia: 'TestComponent', props: {
5+
name: 'Brandon',
6+
sport: -> { 'hockey' }
7+
}
8+
end
9+
10+
def view_data
11+
render inertia: 'TestComponent', view_data: {
12+
name: 'Brian',
13+
sport: 'basketball',
14+
}
15+
end
16+
17+
def component
18+
render inertia: 'TestComponent'
19+
end
20+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class InertiaShareTestController < ApplicationController
2+
inertia_share name: 'Brandon'
3+
inertia_share sport: -> { 'hockey' }
4+
inertia_share do
5+
{
6+
position: 'center',
7+
number: 29,
8+
}
9+
end
10+
11+
def share
12+
render inertia: 'ShareTestComponent'
13+
end
14+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class InertiaTestController < ApplicationController
2+
def empty_test
3+
render inertia: 'EmptyTestComponent'
4+
end
5+
6+
def redirect_test
7+
redirect_to :empty_test
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
9+
//
10+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11+
// about supported directives.
12+
//
13+
//= require rails-ujs
14+
//= require activestorage
15+
//= require_tree .
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ApplicationJob < ActiveJob::Base
2+
# Automatically retry jobs that encountered a deadlock
3+
# retry_on ActiveRecord::Deadlocked
4+
5+
# Most jobs are safe to ignore if the underlying records are no longer available
6+
# discard_on ActiveJob::DeserializationError
7+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ApplicationMailer < ActionMailer::Base
2+
default from: '[email protected]'
3+
layout 'mailer'
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationRecord < ActiveRecord::Base
2+
self.abstract_class = true
3+
end

spec/dummy/app/models/concerns/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%= yield %>
2+
<%= local_assigns.except(:page).to_json.html_safe %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<style>
6+
/* Email styles need to be inline */
7+
</style>
8+
</head>
9+
10+
<body>
11+
<%= yield %>
12+
</body>
13+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= yield %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Testing Layout for configuration_spec</h1>
2+
<%= yield %>

spec/dummy/bin/rails

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
APP_PATH = File.expand_path('../config/application', __dir__)
3+
require_relative '../config/boot'
4+
require 'rails/commands'

spec/dummy/bin/rake

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
require_relative '../config/boot'
3+
require 'rake'
4+
Rake.application.run

spec/dummy/bin/setup

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
require 'fileutils'
3+
4+
# path to your application root.
5+
APP_ROOT = File.expand_path('..', __dir__)
6+
7+
def system!(*args)
8+
system(*args) || abort("\n== Command #{args} failed ==")
9+
end
10+
11+
FileUtils.chdir APP_ROOT do
12+
# This script is a way to setup or update your development environment automatically.
13+
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14+
# Add necessary setup steps to this file.
15+
16+
puts '== Installing dependencies =='
17+
system! 'gem install bundler --conservative'
18+
system('bundle check') || system!('bundle install')
19+
20+
# puts "\n== Copying sample files =="
21+
# unless File.exist?('config/database.yml')
22+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
23+
# end
24+
25+
puts "\n== Preparing database =="
26+
system! 'bin/rails db:prepare'
27+
28+
puts "\n== Removing old logs and tempfiles =="
29+
system! 'bin/rails log:clear tmp:clear'
30+
31+
puts "\n== Restarting application server =="
32+
system! 'bin/rails restart'
33+
end

spec/dummy/config.ru

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is used by Rack-based servers to start the application.
2+
3+
require_relative 'config/environment'
4+
5+
run Rails.application

spec/dummy/config/application.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require_relative 'boot'
2+
3+
require 'rails/all'
4+
5+
Bundler.require(*Rails.groups)
6+
require "inertia_rails"
7+
8+
module Dummy
9+
class Application < Rails::Application
10+
# Initialize configuration defaults for originally generated Rails version.
11+
config.load_defaults 6.0
12+
13+
# Settings in config/environments/* take precedence over those specified here.
14+
# Application configuration can go into files in config/initializers
15+
# -- all .rb files in that directory are automatically loaded after loading
16+
# the framework and any gems in your application.
17+
end
18+
end
19+

spec/dummy/config/boot.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Set up gems listed in the Gemfile.
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3+
4+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)

spec/dummy/config/cable.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
development:
2+
adapter: async
3+
4+
test:
5+
adapter: test
6+
7+
production:
8+
adapter: redis
9+
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10+
channel_prefix: dummy_production

spec/dummy/config/database.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SQLite. Versions 3.8.0 and up are supported.
2+
# gem install sqlite3
3+
#
4+
# Ensure the SQLite 3 gem is defined in your Gemfile
5+
# gem 'sqlite3'
6+
#
7+
default: &default
8+
adapter: sqlite3
9+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10+
timeout: 5000
11+
12+
development:
13+
<<: *default
14+
database: db/development.sqlite3
15+
16+
# Warning: The database defined as "test" will be erased and
17+
# re-generated from your development database when you run "rake".
18+
# Do not set this db to the same as development or production.
19+
test:
20+
<<: *default
21+
database: db/test.sqlite3
22+
23+
production:
24+
<<: *default
25+
database: db/production.sqlite3

spec/dummy/config/environment.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Load the Rails application.
2+
require_relative 'application'
3+
4+
# Initialize the Rails application.
5+
Rails.application.initialize!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
9+
# Do not eager load code on boot.
10+
config.eager_load = false
11+
12+
# Show full error reports.
13+
config.consider_all_requests_local = true
14+
15+
# Enable/disable caching. By default caching is disabled.
16+
# Run rails dev:cache to toggle caching.
17+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
18+
config.action_controller.perform_caching = true
19+
config.action_controller.enable_fragment_cache_logging = true
20+
21+
config.cache_store = :memory_store
22+
config.public_file_server.headers = {
23+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
24+
}
25+
else
26+
config.action_controller.perform_caching = false
27+
28+
config.cache_store = :null_store
29+
end
30+
31+
# Store uploaded files on the local file system (see config/storage.yml for options).
32+
config.active_storage.service = :local
33+
34+
# Don't care if the mailer can't send.
35+
config.action_mailer.raise_delivery_errors = false
36+
37+
config.action_mailer.perform_caching = false
38+
39+
# Print deprecation notices to the Rails logger.
40+
config.active_support.deprecation = :log
41+
42+
# Raise an error on page load if there are pending migrations.
43+
config.active_record.migration_error = :page_load
44+
45+
# Highlight code that triggered database queries in logs.
46+
config.active_record.verbose_query_logs = true
47+
48+
# Debug mode disables concatenation and preprocessing of assets.
49+
# This option may cause significant delays in view rendering with a large
50+
# number of complex assets.
51+
config.assets.debug = true
52+
53+
# Suppress logger output for asset requests.
54+
config.assets.quiet = true
55+
56+
# Raises error for missing translations.
57+
# config.action_view.raise_on_missing_translations = true
58+
59+
# Use an evented file watcher to asynchronously detect changes in source code,
60+
# routes, locales, etc. This feature depends on the listen gem.
61+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
62+
end

0 commit comments

Comments
 (0)