Skip to content

Commit

Permalink
improve environment detection helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelvilleneuve committed Oct 2, 2024
1 parent 1e40781 commit 56da2b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 10 additions & 2 deletions app/helpers/environments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ module EnvironmentsHelper
private

def production_env?
ENV["SENTRY_ENVIRONMENT"] == "production"
!staging_env? && !demo_env? && !local_env?
end

def staging_env?
ENV["SENTRY_ENVIRONMENT"] == "staging"
ENV["HOST"].include?("staging")
end

def demo_env?
ENV["HOST"].include?("demo")
end

def local_env?
ENV["HOST"].include?("local")
end
end
10 changes: 4 additions & 6 deletions app/helpers/rdv_insertion_instance_name_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module RdvInsertionInstanceNameHelper
def rdv_insertion_instance_name
return if production_env?

if Rails.env.development?
Rails.env
elsif ENV["HOST"].include?("staging")
if local_env?
"Local"
elsif staging_env?
"Staging"
else
elsif demo_env?
"Démo"
end
end
Expand Down

0 comments on commit 56da2b2

Please sign in to comment.