DEV: enables and fixes multisite-spec (#9557)

This commit is contained in:
Joffrey JAFFEUX 2020-04-27 20:55:36 +02:00 committed by GitHub
parent d38b2e508e
commit 01f2819dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 63 additions and 67 deletions

View File

@ -1,69 +1,65 @@
# frozen_string_literal: true # frozen_string_literal: true
# require 'rails_helper' require 'rails_helper'
#
# describe 'multisite' do describe 'multisite', type: :multisite do
# class DBNameMiddleware
# class DBNameMiddleware def initialize(app, config = {})
# def initialize(app, config = {}) @app = app
# @app = app end
# end
# def call(env)
# def call(env) # note current_db is already being ruined on boot cause its not multisite
# # note current_db is already being ruined on boot cause its not multisite [200, {}, [RailsMultisite::ConnectionManagement.current_hostname]]
# [200, {}, [RailsMultisite::ConnectionManagement.current_hostname]] end
# end end
# end
# let :session do
# let :session do stack = ActionDispatch::MiddlewareStack.new
# RailsMultisite::ConnectionManagement.config_filename = "spec/fixtures/multisite/two_dbs.yml" stack.use RailsMultisite::Middleware, RailsMultisite::DiscoursePatches.config
# RailsMultisite::ConnectionManagement.load_settings! stack.use DBNameMiddleware
#
# stack = ActionDispatch::MiddlewareStack.new routes = ActionDispatch::Routing::RouteSet.new
# stack.use RailsMultisite::ConnectionManagement, RailsMultisite::DiscoursePatches.config stack.build(routes)
# stack.use DBNameMiddleware end
#
# routes = ActionDispatch::Routing::RouteSet.new it "should always allow /srv/status through" do
# stack.build(routes) headers = {
# end "HTTP_HOST" => "unknown.com",
# "REQUEST_METHOD" => "GET",
# it "should always allow /srv/status through" do "PATH_INFO" => "/srv/status",
# headers = { "rack.input" => StringIO.new
# "HTTP_HOST" => "unknown.com", }
# "REQUEST_METHOD" => "GET",
# "PATH_INFO" => "/srv/status", code, _, body = session.call(headers)
# "rack.input" => StringIO.new expect(code).to eq(200)
# } expect(body.join).to eq("test.localhost")
# end
# code, _, body = session.call(headers)
# expect(code).to eq(200) it "should 404 on unknown routes" do
# expect(body.join).to eq("test.localhost") headers = {
# end "HTTP_HOST" => "unknown.com",
# "REQUEST_METHOD" => "GET",
# it "should 404 on unknown routes" do "PATH_INFO" => "/topics",
# headers = { "rack.input" => StringIO.new
# "HTTP_HOST" => "unknown.com", }
# "REQUEST_METHOD" => "GET",
# "PATH_INFO" => "/topics", code, _ = session.call(headers)
# "rack.input" => StringIO.new expect(code).to eq(404)
# } end
#
# code, _ = session.call(headers) it "should hit correct site elsewise" do
# expect(code).to eq(404)
# end headers = {
# "HTTP_HOST" => "test2.localhost",
# it "should hit correct site elsewise" do "REQUEST_METHOD" => "GET",
# "PATH_INFO" => "/topics",
# headers = { "rack.input" => StringIO.new
# "HTTP_HOST" => "test2.localhost", }
# "REQUEST_METHOD" => "GET",
# "PATH_INFO" => "/topics", code, _, body = session.call(headers)
# "rack.input" => StringIO.new expect(code).to eq(200)
# } expect(body.join).to eq("test2.localhost")
# end
# code, _, body = session.call(headers)
# expect(code).to eq(200) end
# expect(body.join).to eq("test2.localhost")
# end
#
# end