Skip to content

Commit

Permalink
Use BUGSNAG_RELEASE_STAGE by default
Browse files Browse the repository at this point in the history
Previously we read 'BUGSNAG_RELEASE_STAGE' only in the Rails
integration, so other apps had to use 'RACK_ENV' (if they run in Rack)
or set it manually in code

Now we will always use the 'BUGSNAG_RELEASE_STAGE' environment variable
if it's set
  • Loading branch information
imjoehaines committed Jul 23, 2020
1 parent 84aac9d commit c1cbda6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/bugsnag/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def initialize
self.runtime_versions["ruby"] = RUBY_VERSION
self.runtime_versions["jruby"] = JRUBY_VERSION if defined?(JRUBY_VERSION)
self.timeout = 15
self.release_stage = ENV['BUGSNAG_RELEASE_STAGE']
self.notify_release_stages = nil
self.auto_capture_sessions = true

Expand Down
2 changes: 1 addition & 1 deletion lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Railtie < ::Rails::Railtie
# initializer. If not, the key will be validated in after_initialize.
Bugsnag.configure(false) do |config|
config.logger = ::Rails.logger
config.release_stage = ENV["BUGSNAG_RELEASE_STAGE"] || ::Rails.env.to_s
config.release_stage ||= ::Rails.env.to_s
config.project_root = ::Rails.root.to_s
config.middleware.insert_before Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::Rails3Request
config.runtime_versions["rails"] = ::Rails::VERSION::STRING
Expand Down
15 changes: 15 additions & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@
end
end

describe "release_stage" do
after(:each) do
ENV["BUGSNAG_RELEASE_STAGE"] = nil
end

it "has no default value" do
expect(subject.release_stage).to be_nil
end

it "uses the 'BUGSNAG_RELEASE_STAGE' environment variable if set" do
ENV["BUGSNAG_RELEASE_STAGE"] = "foobar"
expect(subject.release_stage).to eq("foobar")
end
end

describe "#notify_endpoint" do
it "defaults to DEFAULT_NOTIFY_ENDPOINT" do
expect(subject.notify_endpoint).to eq(Bugsnag::Configuration::DEFAULT_NOTIFY_ENDPOINT)
Expand Down

0 comments on commit c1cbda6

Please sign in to comment.