mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:19:53 +01:00
Refactor TurboStreamable spec to use an anonymous controller
This commit is contained in:
parent
0aac4caf45
commit
4dc88fe1ef
3 changed files with 28 additions and 22 deletions
|
@ -171,11 +171,5 @@ Rails.application.routes.draw do
|
|||
|
||||
get "/nodeinfo/2.1", to: "well_known/node_info#nodeinfo", as: :node_info
|
||||
|
||||
if Rails.env.test?
|
||||
get "turbo_streamable" => "turbo_streamable_test#create"
|
||||
get "turbo_streamable_blocked" => "turbo_streamable_test#blocked"
|
||||
get "turbo_streamable_not_found" => "turbo_streamable_test#not_found"
|
||||
end
|
||||
|
||||
puts "processing time of routes.rb: #{"#{(Time.zone.now - start).round(3).to_s.ljust(5, '0')}s".light_green}"
|
||||
end
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
require "rails_helper"
|
||||
|
||||
class TurboStreamableTestController < ApplicationController
|
||||
describe ApplicationController, type: :controller do
|
||||
controller do
|
||||
include TurboStreamable
|
||||
|
||||
turbo_stream_actions :create, :blocked, :not_found
|
||||
|
@ -26,7 +27,14 @@ class TurboStreamableTestController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
describe TurboStreamableTestController, type: :controller do
|
||||
before do
|
||||
routes.draw do
|
||||
get "create" => "anonymous#create"
|
||||
get "blocked" => "anonymous#blocked"
|
||||
get "not_found" => "anonymous#not_found"
|
||||
end
|
||||
end
|
||||
|
||||
render_views
|
||||
|
||||
shared_examples_for "it returns a toast as Turbo Stream response" do |action, message|
|
||||
|
|
|
@ -60,6 +60,10 @@ RSpec.configure do |config|
|
|||
# arbitrary gems may also be filtered via:
|
||||
# config.filter_gems_from_backtrace("gem name")
|
||||
|
||||
# anonymous controllers will infer ApplicationController instead of the
|
||||
# described class
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include Devise::Test::ControllerHelpers, type: :helper
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue