From 1c672e93b79222faed8f31d7a900b3fd5d981963 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Fri, 23 Feb 2024 14:04:51 -0800 Subject: [PATCH] Create executable bug report Rails application This template draws inspiration from Rails' [bug report templates][]. [bug report templates]: https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#create-an-executable-test-case --- .github/workflows/ci.yml | 3 ++ README.md | 8 ++++ bug_report_template.rb | 95 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 bug_report_template.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55168746..93e57529 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,9 @@ jobs: rubygems: latest bundler-cache: true + - name: Run Bug Template Tests + run: ruby bug_report_template.rb + - name: Run tests id: test run: bundle exec rake TESTOPT=-vdc diff --git a/README.md b/README.md index bbcfeda5..15a7daab 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,14 @@ The [`Turbo::Broadcastable::TestHelper`](./lib/turbo/broadcastable/test_helper.r Run the tests with `./bin/test`. +## Contributing + +Having a way to reproduce your issue will help people confirm, investigate, and ultimately fix your issue. You can do this by providing an executable test case. To make this process easier, we have prepared an [executable bug report Rails application](./bug_report_template.rb) for you to use as a starting point. + +This template includes the boilerplate code to set up a System Test case. Copy the content of the template into a `.rb` file and make the necessary changes to demonstrate the issue. You can execute it by running `ruby the_file.rb` in your terminal. If all goes well, you should see your test case failing. + +You can then share your executable test case as a gist or paste the content into the issue description. + ## License Turbo is released under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/bug_report_template.rb b/bug_report_template.rb new file mode 100644 index 00000000..43df4f21 --- /dev/null +++ b/bug_report_template.rb @@ -0,0 +1,95 @@ +require "bundler/inline" + +gemfile(true) do + source "https://rubygems.org" + + git_source(:github) { |repo| "https://github.com/#{repo}.git" } + + gem "rails" + gem "propshaft" + gem "sqlite3" + gem "turbo-rails" + + gem "capybara" + gem "cuprite", "~> 0.9", require: "capybara/cuprite" +end + +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_view/railtie" +# require "action_mailer/railtie" +# require "active_job/railtie" +# require "action_cable/engine" +# require "action_mailbox/engine" +# require "action_text/engine" +require "rails/test_unit/railtie" + +class App < Rails::Application + config.load_defaults Rails::VERSION::STRING.to_f + + config.root = __dir__ + config.hosts << "example.org" + config.eager_load = false + config.session_store :cookie_store, key: "cookie_store_key" + config.secret_key_base = "secret_key_base" + config.turbo.draw_routes = false + + Rails.logger = config.logger = Logger.new($stdout) + + routes.append do + root to: "application#index" + end +end + +class ApplicationController < ActionController::Base + def index + render inline: DATA.read + end +end + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :cuprite, using: :chrome, screen_size: [1400, 1400], options: { js_errors: true } + + Capybara.server = :webrick +end + +ENV["DATABASE_URL"] = "sqlite3::memory:" +ENV["RAILS_ENV"] ||= "test" + +Rails.application.initialize! + +require "rails/test_help" + +class TurboSystemTest < ApplicationSystemTestCase + test "reproduces bug" do + visit root_path + + assert_text "Loaded with Turbo" + end +end + +__END__ + + + + + <%= csrf_meta_tags %> + + + + + + + Loaded without Turbo +