Test Solution for Forem-link Embed issues on Canary2 (#16843)
* solution * fixing specs * complete specs * nudge Travis * resolve database issues * nudge Travis * Check that the settings table exists before loading the class This maybe fixes an issue in test-console-check accessing a missing table `users` (because we're requiring settings during the initializer, and we're initializing the app during a schema load on a newly created db). * refactor check * privatize and rename * add self * reposition private class method * Prevent accidentally deploying to DEV * Skip tests to try deploying to benhalpern * Allow PR to deploy to benhalpern * Allow other branches to deploy * Oops * Revert changes to travis.yml Co-authored-by: Dan Uber <dan@forem.com> Co-authored-by: Andy Z <17884966+Zhao-Andy@users.noreply.github.com>
This commit is contained in:
parent
63b5c9102d
commit
39bc67ec15
2 changed files with 8 additions and 1 deletions
|
|
@ -4,8 +4,14 @@ module URL
|
|||
ApplicationConfig["APP_PROTOCOL"]
|
||||
end
|
||||
|
||||
def self.database_available?
|
||||
ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?("site_configs")
|
||||
end
|
||||
|
||||
private_class_method :database_available?
|
||||
|
||||
def self.domain
|
||||
if Rails.application&.initialized? && Settings::General.respond_to?(:app_domain)
|
||||
if database_available?
|
||||
Settings::General.app_domain
|
||||
else
|
||||
ApplicationConfig["APP_DOMAIN"]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe URL, type: :lib do
|
||||
before do
|
||||
allow(ApplicationConfig).to receive(:[]).and_call_original
|
||||
allow(ApplicationConfig).to receive(:[]).with("APP_PROTOCOL").and_return("https://")
|
||||
allow(ApplicationConfig).to receive(:[]).with("APP_DOMAIN").and_return("test.forem.cloud")
|
||||
allow(Settings::General).to receive(:app_domain).and_return("dev.to")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue