|
13 | 13 | 'RACK_ENV' => 'development', |
14 | 14 | 'HTML2RSS_SECRET_KEY' => boot_secret_key, |
15 | 15 | 'BUILD_TAG' => '2026-03-27', |
16 | | - 'GIT_SHA' => 'abc1234' |
| 16 | + 'GIT_SHA' => 'abc1234', |
| 17 | + 'SENTRY_ENABLE_LOGS' => nil |
17 | 18 | } |
18 | 19 | end |
19 | 20 |
|
|
56 | 57 | end |
57 | 58 | end |
58 | 59 |
|
59 | | - it 'configures Sentry for errors and logs when a DSN is present', :aggregate_failures do |
| 60 | + it 'configures Sentry for error reporting when a DSN is present', :aggregate_failures do |
60 | 61 | stub_environment_validation |
61 | 62 | allow(Html2rss::Web::Boot::Sentry).to receive(:configure!).and_call_original |
62 | 63 | allow(Html2rss::Web::Boot::Sentry).to receive(:require).with('sentry-ruby').and_return(true) |
|
71 | 72 | expect_sentry_to_be_configured |
72 | 73 | end |
73 | 74 |
|
| 75 | + it 'enables Sentry logs when SENTRY_ENABLE_LOGS is true', :aggregate_failures do |
| 76 | + stub_environment_validation |
| 77 | + allow(Html2rss::Web::Boot::Sentry).to receive(:configure!).and_call_original |
| 78 | + allow(Html2rss::Web::Boot::Sentry).to receive(:require).with('sentry-ruby').and_return(true) |
| 79 | + allow(Bundler).to receive(:require) |
| 80 | + fake_sentry = build_fake_sentry |
| 81 | + stub_const('Sentry', fake_sentry) |
| 82 | + |
| 83 | + ClimateControl.modify(boot_env.merge('SENTRY_DSN' => sentry_dsn, 'SENTRY_ENABLE_LOGS' => 'true')) do |
| 84 | + described_class.call! |
| 85 | + end |
| 86 | + |
| 87 | + expect_sentry_config(:enable_logs, true) |
| 88 | + end |
| 89 | + |
| 90 | + it 'fails fast when SENTRY_ENABLE_LOGS is malformed' do |
| 91 | + stub_environment_validation |
| 92 | + allow(Html2rss::Web::Boot::Sentry).to receive(:configure!).and_call_original |
| 93 | + allow(Html2rss::Web::Boot::Sentry).to receive(:require).with('sentry-ruby').and_return(true) |
| 94 | + allow(Bundler).to receive(:require) |
| 95 | + fake_sentry = build_fake_sentry |
| 96 | + stub_const('Sentry', fake_sentry) |
| 97 | + |
| 98 | + expect do |
| 99 | + ClimateControl.modify(boot_env.merge('SENTRY_DSN' => sentry_dsn, 'SENTRY_ENABLE_LOGS' => '1')) do |
| 100 | + described_class.call! |
| 101 | + end |
| 102 | + end.to raise_error(ArgumentError, /SENTRY_ENABLE_LOGS/) |
| 103 | + end |
| 104 | + |
74 | 105 | it 'logs build metadata on startup' do |
75 | 106 | stub_environment_validation |
76 | 107 | logger = instance_double(Logger, info: nil) |
@@ -113,7 +144,7 @@ def expect_sensitive_env_to_be_scrubbed |
113 | 144 | def expect_sentry_to_be_configured |
114 | 145 | expect(Bundler).to have_received(:require).with(:sentry) |
115 | 146 | expect_sentry_config(:dsn, sentry_dsn) |
116 | | - expect_sentry_config(:enable_logs, true) |
| 147 | + expect_sentry_config(:enable_logs, false) |
117 | 148 | expect_sentry_config(:release, '2026-03-27+abc1234') |
118 | 149 | end |
119 | 150 |
|
|
0 commit comments