Rename LOCAL_AUTHENTICATION to OSS_CONFIG
This commit is contained in:
@@ -71,7 +71,7 @@ group :test do
|
||||
end
|
||||
|
||||
require_relative "lib/bootstrap"
|
||||
unless Bootstrap.local_authentication?
|
||||
unless Bootstrap.oss_config?
|
||||
eval_gemfile "gems/fizzy-saas/Gemfile"
|
||||
gem "fizzy-saas", path: "gems/fizzy-saas"
|
||||
end
|
||||
|
||||
@@ -14,8 +14,8 @@ if [ -f tmp/solid-queue.txt ]; then
|
||||
export SOLID_QUEUE_IN_PUMA=1
|
||||
fi
|
||||
|
||||
if [ -f tmp/local-auth.txt ]; then
|
||||
export LOCAL_AUTHENTICATION=1
|
||||
if [ -f tmp/oss-config.txt ]; then
|
||||
export OSS_CONFIG=1
|
||||
fi
|
||||
|
||||
exec ./bin/rails server -p 3006
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
require_relative "../lib/bootstrap"
|
||||
if !Bootstrap.local_authentication?
|
||||
if !Bootstrap.oss_config?
|
||||
# default from rails/test_unit/runner.rb but adding the saas gem test files
|
||||
ENV["DEFAULT_TEST"] = "{gems/fizzy-saas/,}test/**/*_test.rb"
|
||||
ENV["DEFAULT_TEST_EXCLUDE"] = "{gems/fizzy-saas/,}test/{system,dummy,fixtures}/**/*_test.rb"
|
||||
|
||||
@@ -11,7 +11,7 @@ system("bundle config set --local auto_install true")
|
||||
system("bundle check") || system!("bundle install")
|
||||
|
||||
require_relative "../lib/bootstrap"
|
||||
load File.expand_path("../gems/fizzy-saas/bin/setup", __dir__) unless Bootstrap.local_authentication?
|
||||
load File.expand_path("../gems/fizzy-saas/bin/setup", __dir__) unless Bootstrap.oss_config?
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
if ARGV.include?("--reset")
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ CI.run do
|
||||
step "Security: Importmap audit", "bin/importmap audit"
|
||||
step "Security: Brakeman audit", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
|
||||
|
||||
step "Tests: Rails with 37id auth", "bin/rails test"
|
||||
step "Tests: Rails with local auth", "LOCAL_AUTHENTICATION=1 bin/rails test"
|
||||
step "Tests: Rails: SaaS config", "bin/rails test"
|
||||
step "Tests: Rails: OSS config", "OSS_CONFIG=1 bin/rails test"
|
||||
step "Tests: 37id", "bin/rails 37id:test:units"
|
||||
step "Tests: System", "bin/rails test:system"
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
require "bootstrap"
|
||||
Rails.application.config.x.local_authentication = Bootstrap.local_authentication?
|
||||
Rails.application.config.x.oss_config = Bootstrap.oss_config?
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ Rails.application.routes.draw do
|
||||
|
||||
root "events#index"
|
||||
|
||||
unless Rails.application.config.x.local_authentication
|
||||
unless Rails.application.config.x.oss_config
|
||||
mount Fizzy::Saas::Engine, at: "/", as: "saas"
|
||||
end
|
||||
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ end
|
||||
def create_tenant(signal_account_name, bare: false)
|
||||
if bare
|
||||
tenant_id = Digest::SHA256.hexdigest(signal_account_name)[0..8].to_i(16)
|
||||
elsif Rails.application.config.x.local_authentication
|
||||
elsif Rails.application.config.x.oss_config
|
||||
tenant_id = ActiveRecord::FixtureSet.identify signal_account_name
|
||||
else
|
||||
signal_account = SignalId::Account.find_by_product_and_name!("fizzy", signal_account_name)
|
||||
@@ -22,7 +22,7 @@ def create_tenant(signal_account_name, bare: false)
|
||||
|
||||
ApplicationRecord.destroy_tenant tenant_id
|
||||
ApplicationRecord.create_tenant(tenant_id) do
|
||||
account = if bare || Rails.application.config.x.local_authentication
|
||||
account = if bare || Rails.application.config.x.oss_config
|
||||
Account.create(name: signal_account_name, tenant_id: tenant_id).tap do
|
||||
User.create!(
|
||||
name: "David Heinemeier Hansson",
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
module Bootstrap
|
||||
def self.local_authentication?
|
||||
ENV.fetch("LOCAL_AUTHENTICATION", "") != "" || !File.directory?(File.expand_path("../gems/fizzy-saas", __dir__))
|
||||
def self.oss_config?
|
||||
ENV.fetch("OSS_CONFIG", "") != "" || !File.directory?(File.expand_path("../gems/fizzy-saas", __dir__))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
# This script creates a new user that can be logged into via LOCAL_AUTHENTICATION, avoiding Launchpad/37id integration.
|
||||
# In order to login as this user, you must set the `LOCAL_AUTHENTICATION` environment variable when running the Rails server:
|
||||
#
|
||||
# LOCAL_AUTHENTICATION=1 bin/dev
|
||||
#
|
||||
|
||||
require_relative "../config/environment"
|
||||
|
||||
unless Rails.env.development?
|
||||
puts "ERROR: This script is intended to be run in development mode only."
|
||||
exit 1
|
||||
end
|
||||
|
||||
if ARGV.length < 2
|
||||
puts "Usage: #{$0} <email> <tenant>"
|
||||
exit 1
|
||||
end
|
||||
|
||||
email_address = ARGV[0]
|
||||
tenant = ARGV[1]
|
||||
|
||||
ApplicationRecord.with_tenant(tenant) do
|
||||
user = User.create!(
|
||||
name: email_address.split("@").first,
|
||||
email_address: email_address,
|
||||
password: "secret123456"
|
||||
)
|
||||
|
||||
puts "Created: "
|
||||
pp user
|
||||
end
|
||||
@@ -1,8 +1,6 @@
|
||||
require "test_helper"
|
||||
|
||||
class PeriodHighlightTest < ActiveSupport::TestCase
|
||||
# Skipping when locally authenticating because the VCR cassettes would need to be re-recorded.
|
||||
unless Rails.application.config.x.local_authentication
|
||||
include VcrTestHelper
|
||||
|
||||
setup do
|
||||
@@ -26,5 +24,4 @@ class PeriodHighlightTest < ActiveSupport::TestCase
|
||||
|
||||
assert_equal new_period_highlights, existing_period_highlights
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
require "test_helper"
|
||||
|
||||
class User::HighlightsTest < ActiveSupport::TestCase
|
||||
# Skipping when locally authenticating because the VCR cassettes would need to be re-recorded.
|
||||
unless Rails.application.config.x.local_authentication
|
||||
include VcrTestHelper
|
||||
|
||||
setup do
|
||||
@@ -63,5 +61,4 @@ class User::HighlightsTest < ActiveSupport::TestCase
|
||||
# Should include 7 events from the current week
|
||||
assert_equal 7, period.events.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+1
-1
@@ -65,6 +65,6 @@ RubyLLM.configure do |config|
|
||||
config.openai_api_key ||= "DUMMY-TEST-KEY" # Run tests with VCR without having to configure OpenAI API key locally.
|
||||
end
|
||||
|
||||
unless Rails.application.config.x.local_authentication
|
||||
unless Rails.application.config.x.oss_config
|
||||
load File.expand_path("../gems/fizzy-saas/test/test_helper.rb", __dir__)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user