Commit 359f3aa8ce51c82df2bc1ead0b66337df9751498
1 parent
bbd28eeb
Exists in
master
and in
14 other branches
application_controller: provide sample environment to avoid crashes
This was previously done to avoid crashes on development environment, but some selenium tests, for unknown reasons, produces requests where Environment.default returns nil even though all steps passes.
Showing
1 changed file
with
2 additions
and
3 deletions
Show diff stats
app/controllers/application_controller.rb
... | ... | @@ -131,12 +131,11 @@ class ApplicationController < ActionController::Base |
131 | 131 | @domain = Domain.find_by_name(request.host) |
132 | 132 | if @domain.nil? |
133 | 133 | @environment = Environment.default |
134 | - if @environment.nil? && Rails.env.development? | |
135 | - # This should only happen in development ... | |
134 | + # Avoid crashes on test and development setups | |
135 | + if @environment.nil? && !Rails.env.production? | |
136 | 136 | @environment = Environment.new |
137 | 137 | @environment.name = "Noosfero" |
138 | 138 | @environment.is_default = true |
139 | - @environment.save! | |
140 | 139 | end |
141 | 140 | else |
142 | 141 | @environment = @domain.environment | ... | ... |