Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/integration tests #751

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/integrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Integration tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
name: Integration tests
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ['2.5', '2.6', '2.7', '3.0']
fixture: [ '{rails6}', '{rails7}' ]
experimental: [false]

include:
- ruby-version: 'head'
fixture: '{rails6}'
experimental: true
- ruby-version: 'head'
fixture: '{rails7}'
experimental: true

exclude:
- ruby-version: '2.5'
fixture: '{rails7}'
- ruby-version: '2.6'
fixture: '{rails7}'

env:
FIXTURE: ${{ matrix.fixture }}

continue-on-error: ${{ matrix.experimental }}

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
run: bundle exec rake test:clean test:setup test:fixtures
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end
# rake test:setup
# rake test:full

fixture_list = "{padrino_test,sinatra_test,rails2,rails3,rails3_2,rails4,rails5,rails5_api}"
fixture_list = ENV['FIXTURE'] || "{padrino_test,sinatra_test,rails2,rails3,rails3_2,rails4,rails5,rails5_api,rails6,rails7}"

desc "Clean up the fixtures being tested by cleaning and installing dependencies"
task "test:clean" do
Expand Down Expand Up @@ -52,7 +52,7 @@ task "test:fixtures" do
Dir[File.dirname(__FILE__) + "/fixtures/#{fixture_list}"].each do |fixture|
puts "\n*** Running tests for #{File.basename(fixture)}... ***\n"
Bundler.with_clean_env {
Dir.chdir(fixture) { puts `bundle check; bundle exec rake test:rabl` }
Dir.chdir(fixture) { sh 'bundle check; bundle exec rake test:rabl' }
}
end
end
Expand Down
3 changes: 2 additions & 1 deletion fixtures/rails3_2/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem 'rails', '~> 3.2.9.rc3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'sqlite3', '~> 1.3.6'
gem 'rabl', :path => File.expand_path(File.dirname(__FILE__) + "/../../")
gem 'riot', :group => "test"

Expand Down Expand Up @@ -38,3 +38,4 @@ gem 'jquery-rails'
# To use debugger
# gem 'debugger'

gem 'test-unit'
4 changes: 2 additions & 2 deletions fixtures/rails4/Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.8'
gem 'rails', '~> 4.2.8'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'sqlite3', '~> 1.3.6'
gem 'rabl', :path => File.expand_path(File.dirname(__FILE__) + "/../../")
gem 'riot', :group => "test"
gem 'pry-rails', :group => "test"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/rails5/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'sqlite3', '~> 1.3.6'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
Expand Down
2 changes: 1 addition & 1 deletion fixtures/rails5_api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'sqlite3', '~> 1.3.6'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
Expand Down
35 changes: 35 additions & 0 deletions fixtures/rails7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore uploaded files in development.
/storage/*
!/storage/.keep

/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
66 changes: 66 additions & 0 deletions fixtures/rails7/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.0.rc1"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails", ">= 3.4.1"

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder", "~> 2.11"

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", ">= 1.4.4", require: false

# Use Sass to process CSS
# gem "sassc-rails", "~> 2.1"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
# See https://edgeguides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", ">= 1.0.0", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console", ">= 4.1.0"

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler", ">= 2.3.3"

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara", ">= 3.26"
gem "selenium-webdriver", ">= 4.0.0"
gem "webdrivers"
end

gem 'rabl', path: '../..'
gem 'riot', group: 'test'
gem 'rr', '1.1.2', group: 'test'
gem 'responders', '~> 3.0'
13 changes: 13 additions & 0 deletions fixtures/rails7/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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_relative "config/application"
require 'rake/testtask'

Rails.application.load_tasks

Rake::TestTask.new("test:rabl") do |test|
test.pattern = "test/functional/**/*_test.rb"
test.verbose = true
test.warning = false
end
2 changes: 2 additions & 0 deletions fixtures/rails7/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
Empty file.
15 changes: 15 additions & 0 deletions fixtures/rails7/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
4 changes: 4 additions & 0 deletions fixtures/rails7/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
4 changes: 4 additions & 0 deletions fixtures/rails7/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
2 changes: 2 additions & 0 deletions fixtures/rails7/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end
Empty file.
17 changes: 17 additions & 0 deletions fixtures/rails7/app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class PostsController < ApplicationController

respond_to :json, :xml, :html, :rabl_test_v1

def index
@posts = Post.order('id ASC').load
end

def show
@post = Post.find(params[:id])
end

def renderer
post = Post.find(params[:id])
render json: Rabl.render(post, 'posts/renderer', view_path: 'app/views', format: :json, scope: view_context)
end
end
11 changes: 11 additions & 0 deletions fixtures/rails7/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class UsersController < ApplicationController
respond_to :json

def index
@users = User.order('username ASC').load
end

def show
@user = User.find(params[:id])
end
end
1 change: 1 addition & 0 deletions fixtures/rails7/app/helpers
7 changes: 7 additions & 0 deletions fixtures/rails7/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
4 changes: 4 additions & 0 deletions fixtures/rails7/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
end
1 change: 1 addition & 0 deletions fixtures/rails7/app/models
1 change: 1 addition & 0 deletions fixtures/rails7/app/views
4 changes: 4 additions & 0 deletions fixtures/rails7/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
4 changes: 4 additions & 0 deletions fixtures/rails7/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative "../config/boot"
require "rake"
Rake.application.run
33 changes: 33 additions & 0 deletions fixtures/rails7/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env ruby
require "fileutils"

# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.

puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end

puts "\n== Preparing database =="
system! "bin/rails db:prepare"

puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! "bin/rails restart"
end
6 changes: 6 additions & 0 deletions fixtures/rails7/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is used by Rack-based servers to start the application.

require_relative "config/environment"

run Rails.application
Rails.application.load_server
22 changes: 22 additions & 0 deletions fixtures/rails7/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative "boot"

require "rails/all"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Rails7
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end
4 changes: 4 additions & 0 deletions fixtures/rails7/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
Loading