mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
* Add setting fields to model * Allow to configure SMTP settings * Normalize locales * Cleanup locales * Remove 'coming soon' * fix test * Reset credentials * Reset development config * Check smtp spelling * Use post instead of get method * TLS ENV variable is more descriptive * Rework application mailer * Follow rails convention for mailer action params * Reset schema.rb to main * Test WIP * Add test for controller and mailer * Move tests from controller to model * Custom error message if settings are not all present * Comment smtp config in development env * Add default tls enabled value * Rubocop * Fix controller test * Reset credentials * Normalize locales * Test * fix test * Fix application mailer test that fails randomly * Error flash message instead of notice * Rework application mailer tests
33 lines
1.3 KiB
Ruby
33 lines
1.3 KiB
Ruby
# Dynamic settings the user can change within the app (helpful for self-hosting)
|
|
class Setting < RailsSettings::Base
|
|
cache_prefix { "v1" }
|
|
|
|
field :render_deploy_hook,
|
|
type: :string,
|
|
default: ENV["RENDER_DEPLOY_HOOK"],
|
|
validates: { allow_blank: true, format: { with: /\Ahttps:\/\/api\.render\.com\/deploy\/srv-.+\z/ } }
|
|
|
|
field :upgrades_mode,
|
|
type: :string,
|
|
default: ENV.fetch("UPGRADES_MODE", "manual"),
|
|
validates: { inclusion: { in: %w[manual auto] } }
|
|
|
|
field :upgrades_target,
|
|
type: :string,
|
|
default: ENV.fetch("UPGRADES_TARGET", "release"),
|
|
validates: { inclusion: { in: %w[release commit] } }
|
|
|
|
field :app_domain, type: :string, default: ENV["APP_DOMAIN"]
|
|
field :email_sender, type: :string, default: ENV["EMAIL_SENDER"]
|
|
|
|
scope :smtp_settings do
|
|
field :smtp_host, type: :string, read_only: true, default: ENV["SMTP_ADDRESS"]
|
|
field :smtp_port, type: :string, read_only: true, default: ENV["SMTP_PORT"]
|
|
field :smtp_username, type: :string, read_only: true, default: ENV["SMTP_USERNAME"]
|
|
field :smtp_password, type: :string, read_only: true, default: ENV["SMTP_PASSWORD"]
|
|
end
|
|
|
|
def self.smtp_settings_populated?
|
|
Setting.defined_fields.select { |f| f.scope == :smtp_settings }.map(&:read).all?(&:present?)
|
|
end
|
|
end
|