Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ jobs:
runs-on: ubuntu-latest
name: Linting
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
- name: Install dependencies
run: bundle install
- name: Run tests
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
fail-fast: false
matrix:
database: [mysql, postgres, sqlite]
ruby-version:
- 3.1
- 3.2
- 3.3
- 3.4
- 4.0
services:
mysql:
image: mysql:8.0.31
Expand All @@ -32,15 +38,15 @@ jobs:
env:
TARGET_DB: ${{ matrix.database }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: bundle install
- name: Setup db
run: |
cd test/dummy
bin/rails db:setup
cd ../../
- name: Run tests
run: bin/test
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "bundler/setup"

APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"

require "bundler/gem_tasks"
14 changes: 14 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path("../lib/solid_cable/engine", __dir__)
APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)

# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/engine/commands"
6 changes: 0 additions & 6 deletions lib/solid_cable/railtie.rb

This file was deleted.

2 changes: 2 additions & 0 deletions solid_cable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
spec.add_dependency "activejob", rails_version
spec.add_dependency "actioncable", rails_version
spec.add_dependency "railties", rails_version

spec.add_development_dependency "minitest", "~> 5.0"
end
8 changes: 4 additions & 4 deletions test/config_stubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module ConfigStubs
extend ActiveSupport::Concern

class ConfigStub
def initialize(**)
def initialize(**opts)
@config = ActiveSupport::OrderedOptions.new.
update({ adapter: :test }.merge(**))
update({ adapter: :test }.merge(**opts))
end

def config_for(_file)
Expand All @@ -23,7 +23,7 @@ def run!
end
end

def with_cable_config(**)
Rails.stub(:application, ConfigStub.new(**)) { yield }
def with_cable_config(**opts)
Rails.stub(:application, ConfigStub.new(**opts)) { yield }
end
end
2 changes: 0 additions & 2 deletions test/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# 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.

Expand Down
Empty file removed test/dummy/app/assets/images/.keep
Empty file.
1 change: 0 additions & 1 deletion test/dummy/app/assets/stylesheets/application.css

This file was deleted.

6 changes: 0 additions & 6 deletions test/dummy/app/channels/application_cable/channel.rb

This file was deleted.

6 changes: 0 additions & 6 deletions test/dummy/app/channels/application_cable/connection.rb

This file was deleted.

4 changes: 2 additions & 2 deletions test/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
end
2 changes: 0 additions & 2 deletions test/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 0 additions & 2 deletions test/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
Expand Down
2 changes: 0 additions & 2 deletions test/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
17 changes: 15 additions & 2 deletions test/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<title><%= content_for(:title) || "Dummy" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="application-name" content="Dummy">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= stylesheet_link_tag "application" %>
<%= yield :head %>

<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>

<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">

<%# Includes all stylesheet files in app/assets/stylesheets %>
<%= stylesheet_link_tag :app %>
</head>

<body>
Expand Down
22 changes: 22 additions & 0 deletions test/dummy/app/views/pwa/manifest.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Dummy",
"icons": [
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/",
"description": "Dummy.",
"theme_color": "red",
"background_color": "red"
}
26 changes: 26 additions & 0 deletions test/dummy/app/views/pwa/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Add a service worker for processing Web Push notifications:
//
// self.addEventListener("push", async (event) => {
// const { title, options } = await event.data.json()
// event.waitUntil(self.registration.showNotification(title, options))
// })
//
// self.addEventListener("notificationclick", function(event) {
// event.notification.close()
// event.waitUntil(
// clients.matchAll({ type: "window" }).then((clientList) => {
// for (let i = 0; i < clientList.length; i++) {
// let client = clientList[i]
// let clientPath = (new URL(client.url)).pathname
//
// if (clientPath == event.notification.data.path && "focus" in client) {
// return client.focus()
// }
// }
//
// if (clients.openWindow) {
// return clients.openWindow(event.notification.data.path)
// }
// })
// )
// })
6 changes: 6 additions & 0 deletions test/dummy/bin/ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
require_relative "../config/boot"
require "active_support/continuous_integration"

CI = ActiveSupport::ContinuousIntegration
require_relative "../config/ci.rb"
2 changes: 2 additions & 0 deletions test/dummy/bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
2 changes: 0 additions & 2 deletions test/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
2 changes: 0 additions & 2 deletions test/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../config/boot"
require "rake"
Rake.application.run
16 changes: 8 additions & 8 deletions test/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "fileutils"

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

def system!(*)
system(*, exception: true)
def system!(*args)
system(*args, exception: true)
end

FileUtils.chdir APP_ROOT do
Expand All @@ -16,7 +13,6 @@ FileUtils.chdir APP_ROOT do
# 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 =="
Expand All @@ -26,10 +22,14 @@ FileUtils.chdir APP_ROOT do

puts "\n== Preparing database =="
system! "bin/rails db:prepare"
system! "bin/rails db:reset" if ARGV.include?("--reset")

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

puts "\n== Restarting application server =="
system! "bin/rails restart"
unless ARGV.include?("--skip-server")
puts "\n== Starting development server =="
STDOUT.flush # flush the output before exec(2) so that it displays
exec "bin/dev"
end
end
2 changes: 0 additions & 2 deletions test/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
Expand Down
7 changes: 4 additions & 3 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative "boot"

require "rails/all"
Expand All @@ -12,10 +10,13 @@ module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f

# For compatibility with applications that use this config
config.action_controller.include_all_helpers = false

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks))
config.autoload_lib(ignore: %w[assets tasks])

# Configuration for the application, engines, and railties goes here.
#
Expand Down
2 changes: 0 additions & 2 deletions test/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)

Expand Down
18 changes: 18 additions & 0 deletions test/dummy/config/ci.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Run using bin/ci

CI.run do
step "Setup", "bin/setup --skip-server"


step "Tests: Rails", "bin/rails test"
step "Tests: System", "bin/rails test:system"
step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"

# Optional: set a green GitHub commit status to unblock PR merge.
# Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
# if success?
# step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
# else
# failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
# end
end
2 changes: 0 additions & 2 deletions test/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# Load the Rails application.
require_relative "application"

Expand Down
Loading