Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Development environment loaded regardless of Rails.env #14288

Closed
swistak opened this Issue · 3 comments

3 participants

@swistak

I've found a strange issue. Regardless of Rails.env and RAILS_ENV set the config/environments/development.rb is always loaded from test/test_helper.rb

Inside test/test_helper.rb

ENV["RAILS_ENV"] ||= "test"
Rails.env = ENV["RAILS_ENV"]

Inside config/environments/development.rb
puts "Dev env loded"

Inside config/environments/test.rb
puts "Test env loaded"

running rake test results in
Dev env loaded

This happen only from inseide rake tasks, probably becouse env is already loaded. But since env loading happens after env is changed to "test", it should not affect which environment is loaded.

Rails version 4.0.2

@swistak

From my investigation it looks like the initializers (including config/environments/development.rb) are set up upon loading of config/application.rb inside Rakefile

So changing Rails.env inside rake task after rake tasks are loaded does not change which env file gets loaded.

@swistak swistak referenced this issue in plataformatec/devise
Closed

Devise breaks controller tests #2915

@robin850 robin850 added the railties label
@rails-bot rails-bot added the stale label
@rails-bot
Collaborator

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

@rails-bot rails-bot closed this
@rails-bot
Collaborator

This issue has been automatically closed because of inactivity.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.