Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use top level namespace for Rails::Railtie class #5

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Run RSpec tests
on: [push, pull_request]
jobs:
jobs:
test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1.81.0
uses: ruby/setup-ruby@v1.190.0
with:
# Not needed with a .ruby-version file
ruby-version: 2.7
ruby-version: 3.3.0
bundler-cache: true
- name: Run tests
run: |
Expand Down
16 changes: 8 additions & 8 deletions lib/dotenv/beefy/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Dotenv
module Beefy
class Railtie < Rails::Railtie
class Railtie < ::Rails::Railtie
config.before_configuration { load_environments }

# Load environment dotfiles in the following order (e.g. if in "test" environment on "darwin")
Expand All @@ -13,27 +13,27 @@ class Railtie < Rails::Railtie
# 4. .env.test
# 5. .env.darwin
# 6. .env
#
#
# The order matters, because the files loaded first will "lock in" the value for that ENV var.
# Dotenv.load memoizes each ENV value, and if the value is set, it cannot be updated later.
# If you want to update ENV values as new values come in, you need to use Dotenv.overload(*files)
def load_environments
files = []
environments.each do |env|

environments.each do |env|
files << ".env.#{env}.local"
end

# This is a dotenv-rails convention to ignore `.env.local` in a test environment
# @see https://github.com/bkeepers/dotenv/blob/c237d6d6291c898d8affb290b510c7aac49aed71/lib/dotenv/rails.rb#L66-L73
files << '.env.local' unless Rails.env.test?
environments.each do |env|
files << '.env.local' unless Rails.env.test?

environments.each do |env|
files << ".env.#{env}"
end

files << '.env'

Dotenv.load(*files)
end

Expand Down
Loading