Fixed specs

This commit is contained in:
Luke "Jared" Bennett 2017-04-28 16:01:22 +01:00
parent 0e8afe1343
commit 97633d5616
No known key found for this signature in database
GPG key ID: 402ED51FB5D306C2
6 changed files with 24 additions and 18 deletions

View file

@ -61,7 +61,7 @@ const RavenConfig = {
environment: this.options.isProduction ? 'production' : 'development',
ignoreErrors: this.IGNORE_ERRORS,
ignoreUrls: this.IGNORE_URLS,
shouldSendCallback: this.shouldSendSample,
shouldSendCallback: this.shouldSendSample.bind(this),
}).install();
},

View file

@ -33,7 +33,10 @@
= webpack_bundle_tag "runtime"
= webpack_bundle_tag "common"
= webpack_bundle_tag "main"
= webpack_bundle_tag "raven" if Gitlab.config.clientside_sentry_enabled
= webpack_bundle_tag "raven" if current_application_settings.clientside_sentry_enabled
= 'LUKETEST'
= current_application_settings.clientside_sentry_enabled
- if content_for?(:page_specific_javascripts)
= yield :page_specific_javascripts

View file

@ -72,6 +72,7 @@ module Gitlab
runners_token
secret_token
sentry_dsn
clientside_sentry_enabled
clientside_sentry_dsn
variables
)

View file

@ -10,7 +10,7 @@ module Gitlab
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
gon.katex_css_url = ActionController::Base.helpers.asset_path('katex.css')
gon.katex_js_url = ActionController::Base.helpers.asset_path('katex.js')
gon.sentry_dsn = Gitlab.config.clientside_sentry_dsn if Gitlab.config.clientside_sentry_enabled
gon.sentry_dsn = current_application_settings.clientside_sentry_dsn if current_application_settings.clientside_sentry_enabled
gon.gitlab_url = Gitlab.config.gitlab.url
gon.is_production = Rails.env.production?

View file

@ -10,8 +10,7 @@ feature 'RavenJS', :feature, :js do
end
it 'should load raven if sentry is enabled' do
allow_any_instance_of(SentryHelper).to receive_messages(sentry_dsn_public: 'https://key@domain.com/id',
sentry_enabled?: true)
stub_application_setting(clientside_sentry_dsn: 'https://key@domain.com/id', clientside_sentry_enabled: true)
visit new_user_session_path
@ -19,6 +18,7 @@ feature 'RavenJS', :feature, :js do
end
def has_requested_raven
p page.driver.network_traffic
page.driver.network_traffic.one? {|request| request.url.end_with?(raven_path)}
end
end

View file

@ -77,6 +77,7 @@ describe('RavenConfig', () => {
describe('configure', () => {
let options;
let raven;
let ravenConfig;
beforeEach(() => {
options = {
@ -85,22 +86,25 @@ describe('RavenConfig', () => {
isProduction: true,
};
ravenConfig = jasmine.createSpyObj('ravenConfig', ['shouldSendSample']);
raven = jasmine.createSpyObj('raven', ['install']);
spyOn(Raven, 'config').and.returnValue(raven);
RavenConfig.configure.call({
options,
});
ravenConfig.options = options;
ravenConfig.IGNORE_ERRORS = 'ignore_errors';
ravenConfig.IGNORE_URLS = 'ignore_urls';
RavenConfig.configure.call(ravenConfig);
});
it('should call Raven.config', () => {
expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, {
whitelistUrls: options.whitelistUrls,
environment: 'production',
ignoreErrors: Raven.IGNORE_ERRORS,
ignoreUrls: Raven.IGNORE_URLS,
shouldSendCallback: Raven.shouldSendSample,
ignoreErrors: ravenConfig.IGNORE_ERRORS,
ignoreUrls: ravenConfig.IGNORE_URLS,
shouldSendCallback: jasmine.any(Function),
});
});
@ -109,18 +113,16 @@ describe('RavenConfig', () => {
});
it('should set .environment to development if isProduction is false', () => {
options.isProduction = false;
ravenConfig.options.isProduction = false;
RavenConfig.configure.call({
options,
});
RavenConfig.configure.call(ravenConfig);
expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, {
whitelistUrls: options.whitelistUrls,
environment: 'development',
ignoreErrors: Raven.IGNORE_ERRORS,
ignoreUrls: Raven.IGNORE_URLS,
shouldSendCallback: Raven.shouldSendSample,
ignoreErrors: ravenConfig.IGNORE_ERRORS,
ignoreUrls: ravenConfig.IGNORE_URLS,
shouldSendCallback: jasmine.any(Function),
});
});
});