Skip to content

Commit

Permalink
Fix Dotenv::Railtie.overload to keep .env files priority policy
Browse files Browse the repository at this point in the history
  • Loading branch information
domcermak committed Jun 25, 2022
1 parent 9e101a5 commit fcdeac4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/dotenv/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def load
#
# Same as `load`, but will override existing values in `ENV`
def overload
Dotenv.overload(*dotenv_files)
Dotenv.overload(*dotenv_files.reverse)
end

# Internal: `Rails.root` is nil in Rails 4.1 before the application is
Expand Down
6 changes: 3 additions & 3 deletions spec/dotenv/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def add(*items)
)
end

it "overloads .env.test with .env" do
expect(ENV["DOTENV"]).to eql("true")
it "overloads .env with .env.test" do
expect(ENV["DOTENV"]).to eql("test")
end

context "when loading a file containing already set variables" do
Expand All @@ -125,7 +125,7 @@ def add(*items)

expect do
subject
end.to(change { ENV["DOTENV"] }.from("predefined").to("true"))
end.to(change { ENV["DOTENV"] }.from("predefined").to("test"))
end
end
end
Expand Down

0 comments on commit fcdeac4

Please sign in to comment.