[ci skip] Remove loadscript class in favour of backend conditional

This commit is contained in:
Luke "Jared" Bennett 2017-04-04 14:58:45 +01:00
parent ccca73d779
commit cfd3d0fd37
No known key found for this signature in database
GPG key ID: 402ED51FB5D306C2
21 changed files with 225 additions and 3193 deletions

View file

@ -1,266 +0,0 @@
/* eslint-disable func-names, space-before-function-paren, no-var, quotes, consistent-return, prefer-arrow-callback, comma-dangle, object-shorthand, no-new, max-len */
/* global bp */
/* global Cookies */
/* global Flash */
/* global ConfirmDangerModal */
/* global AwardsHandler */
/* global Aside */
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
/*= require jquery2 */
/*= require jquery-ui/autocomplete */
/*= require jquery-ui/datepicker */
/*= require jquery-ui/draggable */
/*= require jquery-ui/effect-highlight */
/*= require jquery-ui/sortable */
/*= require jquery_ujs */
/*= require jquery.endless-scroll */
/*= require jquery.highlight */
/*= require jquery.waitforimages */
/*= require jquery.atwho */
/*= require jquery.scrollTo */
/*= require jquery.turbolinks */
/*= require js.cookie */
/*= require turbolinks */
/*= require autosave */
/*= require bootstrap/affix */
/*= require bootstrap/alert */
/*= require bootstrap/button */
/*= require bootstrap/collapse */
/*= require bootstrap/dropdown */
/*= require bootstrap/modal */
/*= require bootstrap/scrollspy */
/*= require bootstrap/tab */
/*= require bootstrap/transition */
/*= require bootstrap/tooltip */
/*= require bootstrap/popover */
/*= require select2 */
/*= require underscore */
/*= require dropzone */
/*= require mousetrap */
/*= require mousetrap/pause */
/*= require shortcuts */
/*= require shortcuts_navigation */
/*= require shortcuts_dashboard_navigation */
/*= require shortcuts_issuable */
/*= require shortcuts_network */
/*= require jquery.nicescroll */
/*= require date.format */
/*= require_directory ./behaviors */
/*= require_directory ./blob */
/*= require_directory ./templates */
/*= require_directory ./commit */
/*= require_directory ./extensions */
/*= require_directory ./lib/utils */
/*= require_directory ./u2f */
/*= require_directory ./droplab */
/*= require_directory . */
/*= require fuzzaldrin-plus */
/*= require es6-promise.auto */
/*= require raven_config */
(function () {
document.addEventListener('page:fetch', function () {
// Unbind scroll events
$(document).off('scroll');
// Close any open tooltips
$('.has-tooltip, [data-toggle="tooltip"]').tooltip('destroy');
});
window.addEventListener('hashchange', gl.utils.handleLocationHash);
window.addEventListener('load', function onLoad() {
window.removeEventListener('load', onLoad, false);
gl.utils.handleLocationHash();
}, false);
$(function () {
var $body = $('body');
var $document = $(document);
var $window = $(window);
var $sidebarGutterToggle = $('.js-sidebar-toggle');
var $flash = $('.flash-container');
var bootstrapBreakpoint = bp.getBreakpointSize();
var checkInitialSidebarSize;
var fitSidebarForSize;
// Set the default path for all cookies to GitLab's root directory
Cookies.defaults.path = gon.relative_url_root || '/';
// `hashchange` is not triggered when link target is already in window.location
$body.on('click', 'a[href^="#"]', function() {
var href = this.getAttribute('href');
if (href.substr(1) === gl.utils.getLocationHash()) {
setTimeout(gl.utils.handleLocationHash, 1);
}
});
// prevent default action for disabled buttons
$('.btn').click(function(e) {
if ($(this).hasClass('disabled')) {
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
});
$('.nav-sidebar').niceScroll({
cursoropacitymax: '0.4',
cursorcolor: '#FFF',
cursorborder: '1px solid #FFF'
});
$('.js-select-on-focus').on('focusin', function () {
return $(this).select().one('mouseup', function (e) {
return e.preventDefault();
});
// Click a .js-select-on-focus field, select the contents
// Prevent a mouseup event from deselecting the input
});
$('.remove-row').bind('ajax:success', function () {
$(this).tooltip('destroy')
.closest('li')
.fadeOut();
});
$('.js-remove-tr').bind('ajax:before', function () {
return $(this).hide();
});
$('.js-remove-tr').bind('ajax:success', function () {
return $(this).closest('tr').fadeOut();
});
$('select.select2').select2({
width: 'resolve',
// Initialize select2 selects
dropdownAutoWidth: true
});
$('.js-select2').bind('select2-close', function () {
return setTimeout((function () {
$('.select2-container-active').removeClass('select2-container-active');
return $(':focus').blur();
}), 1);
// Close select2 on escape
});
// Initialize tooltips
$.fn.tooltip.Constructor.DEFAULTS.trigger = 'hover';
$body.tooltip({
selector: '.has-tooltip, [data-toggle="tooltip"]',
placement: function (_, el) {
return $(el).data('placement') || 'bottom';
}
});
$('.trigger-submit').on('change', function () {
return $(this).parents('form').submit();
// Form submitter
});
gl.utils.localTimeAgo($('abbr.timeago, .js-timeago'), true);
// Flash
if ($flash.length > 0) {
$flash.click(function () {
return $(this).fadeOut();
});
$flash.show();
}
// Disable form buttons while a form is submitting
$body.on('ajax:complete, ajax:beforeSend, submit', 'form', function (e) {
var buttons;
buttons = $('[type="submit"]', this);
switch (e.type) {
case 'ajax:beforeSend':
case 'submit':
return buttons.disable();
default:
return buttons.enable();
}
});
$(document).ajaxError(function (e, xhrObj) {
var ref = xhrObj.status;
if (xhrObj.status === 401) {
return new Flash('You need to be logged in.', 'alert');
} else if (ref === 404 || ref === 500) {
return new Flash('Something went wrong on our end.', 'alert');
}
});
$('.account-box').hover(function () {
// Show/Hide the profile menu when hovering the account box
return $(this).toggleClass('hover');
});
$document.on('click', '.diff-content .js-show-suppressed-diff', function () {
var $container;
$container = $(this).parent();
$container.next('table').show();
return $container.remove();
// Commit show suppressed diff
});
$('.navbar-toggle').on('click', function () {
$('.header-content .title').toggle();
$('.header-content .header-logo').toggle();
$('.header-content .navbar-collapse').toggle();
return $('.navbar-toggle').toggleClass('active');
});
// Show/hide comments on diff
$body.on('click', '.js-toggle-diff-comments', function (e) {
var $this = $(this);
var notesHolders = $this.closest('.diff-file').find('.notes_holder');
$this.toggleClass('active');
if ($this.hasClass('active')) {
notesHolders.show().find('.hide').show();
} else {
notesHolders.hide();
}
$this.trigger('blur');
return e.preventDefault();
});
$document.off('click', '.js-confirm-danger');
$document.on('click', '.js-confirm-danger', function (e) {
var btn = $(e.target);
var form = btn.closest('form');
var text = btn.data('confirm-danger-message');
e.preventDefault();
return new ConfirmDangerModal(form, text);
});
$('input[type="search"]').each(function () {
var $this = $(this);
$this.attr('value', $this.val());
});
$document.off('keyup', 'input[type="search"]').on('keyup', 'input[type="search"]', function () {
var $this;
$this = $(this);
return $this.attr('value', $this.val());
});
$document.off('breakpoint:change').on('breakpoint:change', function (e, breakpoint) {
var $gutterIcon;
if (breakpoint === 'sm' || breakpoint === 'xs') {
$gutterIcon = $sidebarGutterToggle.find('i');
if ($gutterIcon.hasClass('fa-angle-double-right')) {
return $sidebarGutterToggle.trigger('click');
}
}
});
fitSidebarForSize = function () {
var oldBootstrapBreakpoint;
oldBootstrapBreakpoint = bootstrapBreakpoint;
bootstrapBreakpoint = bp.getBreakpointSize();
if (bootstrapBreakpoint !== oldBootstrapBreakpoint) {
return $document.trigger('breakpoint:change', [bootstrapBreakpoint]);
}
};
checkInitialSidebarSize = function () {
bootstrapBreakpoint = bp.getBreakpointSize();
if (bootstrapBreakpoint === 'xs' || 'sm') {
return $document.trigger('breakpoint:change', [bootstrapBreakpoint]);
}
};
$window.off('resize.app').on('resize.app', function () {
return fitSidebarForSize();
});
gl.awardsHandler = new AwardsHandler();
checkInitialSidebarSize();
new Aside();
// bind sidebar events
new gl.Sidebar();
});
}).call(this);

View file

@ -1,26 +0,0 @@
(() => {
const global = window.gl || (window.gl = {});
class LoadScript {
static load(source, id = '') {
if (!source) return Promise.reject('source url must be defined');
if (id && document.querySelector(`#${id}`)) return Promise.reject('script id already exists');
return new Promise((resolve, reject) => this.appendScript(source, id, resolve, reject));
}
static appendScript(source, id, resolve, reject) {
const scriptElement = document.createElement('script');
scriptElement.type = 'text/javascript';
if (id) scriptElement.id = id;
scriptElement.onload = resolve;
scriptElement.onerror = reject;
scriptElement.src = source;
document.body.appendChild(scriptElement);
}
}
global.LoadScript = LoadScript;
return global.LoadScript;
})();

View file

@ -0,0 +1,10 @@
import RavenConfig from './raven_config';
RavenConfig.init({
sentryDsn: gon.sentry_dsn,
currentUserId: gon.current_user_id,
whitelistUrls: [gon.gitlab_url],
isProduction: gon.is_production,
});
export default RavenConfig;

View file

@ -0,0 +1,46 @@
import Raven from 'raven-js';
class RavenConfig {
static init(options = {}) {
this.options = options;
this.configure();
this.bindRavenErrors();
if (this.options.currentUserId) this.setUser();
}
static configure() {
Raven.config(this.options.sentryDsn, {
whitelistUrls: this.options.whitelistUrls,
environment: this.options.isProduction ? 'production' : 'development',
}).install();
}
static setUser() {
Raven.setUserContext({
id: this.options.currentUserId,
});
}
static bindRavenErrors() {
$(document).on('ajaxError.raven', this.handleRavenErrors);
}
static handleRavenErrors(event, req, config, err) {
const error = err || req.statusText;
Raven.captureMessage(error, {
extra: {
type: config.type,
url: config.url,
data: config.data,
status: req.status,
response: req.responseText.substring(0, 100),
error,
event,
},
});
}
}
export default RavenConfig;

View file

@ -1,66 +0,0 @@
/* global Raven */
/*= require lib/utils/load_script */
(() => {
const global = window.gl || (window.gl = {});
class RavenConfig {
static init(options = {}) {
this.options = options;
if (!this.options.sentryDsn || !this.options.ravenAssetUrl) return Promise.reject('sentry dsn and raven asset url is required');
return global.LoadScript.load(this.options.ravenAssetUrl, 'raven-js')
.then(() => {
this.configure();
this.bindRavenErrors();
if (this.options.currentUserId) this.setUser();
});
}
static configure() {
Raven.config(this.options.sentryDsn, {
whitelistUrls: this.options.whitelistUrls,
environment: this.options.isProduction ? 'production' : 'development',
}).install();
}
static setUser() {
Raven.setUserContext({
id: this.options.currentUserId,
});
}
static bindRavenErrors() {
$(document).on('ajaxError.raven', this.handleRavenErrors);
}
static handleRavenErrors(event, req, config, err) {
const error = err || req.statusText;
Raven.captureMessage(error, {
extra: {
type: config.type,
url: config.url,
data: config.data,
status: req.status,
response: req.responseText.substring(0, 100),
error,
event,
},
});
}
}
global.RavenConfig = RavenConfig;
document.addEventListener('DOMContentLoaded', () => {
if (!window.gon) return;
global.RavenConfig.init({
sentryDsn: gon.sentry_dsn,
ravenAssetUrl: gon.raven_asset_url,
currentUserId: gon.current_user_id,
whitelistUrls: [gon.gitlab_url],
isProduction: gon.is_production,
}).catch($.noop);
});
})();

View file

@ -9,7 +9,9 @@ module SentryHelper
def sentry_dsn_public
sentry_dsn = ApplicationSetting.current.sentry_dsn
return unless sentry_dsn
uri = URI.parse(sentry_dsn)
uri.password = nil
uri.to_s

View file

@ -9,3 +9,5 @@
= yield :scripts_body
= render "layouts/init_auto_complete" if @gfm_form
= javascript_include_tag(*webpack_asset_paths("raven")) if sentry_enabled?

View file

@ -35,3 +35,5 @@
= link_to "Explore", explore_root_path
= link_to "Help", help_path
= link_to "About GitLab", "https://about.gitlab.com/"
= javascript_include_tag(*webpack_asset_paths("raven")) if sentry_enabled?

View file

@ -16,3 +16,5 @@
= link_to "Explore", explore_root_path
= link_to "Help", help_path
= link_to "About GitLab", "https://about.gitlab.com/"
= javascript_include_tag(*webpack_asset_paths("raven")) if sentry_enabled?

View file

@ -45,6 +45,7 @@ var config = {
u2f: ['vendor/u2f'],
users: './users/users_bundle.js',
vue_pipelines: './vue_pipelines_index/index.js',
raven: './raven/index.js',
},
output: {

View file

@ -13,7 +13,6 @@ module Gitlab
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 = sentry_dsn_public if sentry_enabled?
gon.raven_asset_url = ActionController::Base.helpers.asset_path('raven.js') if sentry_enabled?
gon.gitlab_url = Gitlab.config.gitlab.url
gon.is_production = Rails.env.production?

View file

@ -30,6 +30,7 @@
"mousetrap": "^1.4.6",
"pikaday": "^1.5.1",
"raphael": "^2.2.7",
"raven-js": "^3.14.0",
"raw-loader": "^0.5.1",
"select2": "3.5.2-browserify",
"stats-webpack-plugin": "^0.4.3",

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'RavenJS', feature: true, js: true do
let(:raven_path) { '/raven.js' }
feature 'RavenJS', :feature, :js do
let(:raven_path) { '/raven.bundle.js' }
it 'should not load raven if sentry is disabled' do
visit new_user_session_path
@ -10,8 +10,8 @@ feature 'RavenJS', feature: true, js: true do
end
it 'should load raven if sentry is enabled' do
allow_any_instance_of(ApplicationController).to receive_messages(sentry_dsn_public: 'https://mock:sentry@dsn/path',
sentry_enabled?: true)
allow_any_instance_of(SentryHelper).to receive_messages(sentry_dsn_public: 'https://key@domain.com/id',
sentry_enabled?: true)
visit new_user_session_path

View file

@ -1,10 +0,0 @@
/* eslint-disable no-unused-vars */
class ClassSpecHelper {
static itShouldBeAStaticMethod(base, method) {
return it('should be a static method', () => {
expect(base[method]).toBeDefined();
expect(base.prototype[method]).toBeUndefined();
});
}
}

View file

@ -1,35 +0,0 @@
/* global ClassSpecHelper */
//= require ./class_spec_helper
describe('ClassSpecHelper', () => {
describe('.itShouldBeAStaticMethod', function () {
beforeEach(() => {
class TestClass {
instanceMethod() { this.prop = 'val'; }
static staticMethod() {}
}
this.TestClass = TestClass;
});
ClassSpecHelper.itShouldBeAStaticMethod(ClassSpecHelper, 'itShouldBeAStaticMethod');
it('should have a defined spec', () => {
expect(ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'staticMethod').description).toBe('should be a static method');
});
it('should pass for a static method', () => {
const spec = ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'staticMethod');
expect(spec.status()).toBe('passed');
});
it('should fail for an instance method', (done) => {
const spec = ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'instanceMethod');
spec.resultCallback = (result) => {
expect(result.status).toBe('failed');
done();
};
spec.execute();
});
});
});

View file

@ -1,95 +0,0 @@
/* global ClassSpecHelper */
/*= require lib/utils/load_script */
/*= require class_spec_helper */
describe('LoadScript', () => {
const global = window.gl || (window.gl = {});
const LoadScript = global.LoadScript;
it('should be defined in the global scope', () => {
expect(LoadScript).toBeDefined();
});
describe('.load', () => {
ClassSpecHelper.itShouldBeAStaticMethod(LoadScript, 'load');
it('should reject if no source argument is provided', () => {
spyOn(Promise, 'reject');
LoadScript.load();
expect(Promise.reject).toHaveBeenCalledWith('source url must be defined');
});
it('should reject if the script id already exists', () => {
spyOn(Promise, 'reject');
spyOn(document, 'querySelector').and.returnValue({});
LoadScript.load('src.js', 'src-id');
expect(Promise.reject).toHaveBeenCalledWith('script id already exists');
});
it('should return a promise on completion', () => {
expect(LoadScript.load('src.js')).toEqual(jasmine.any(Promise));
});
it('should call appendScript when the promise is constructed', () => {
spyOn(LoadScript, 'appendScript');
LoadScript.load('src.js', 'src-id');
expect(LoadScript.appendScript).toHaveBeenCalledWith('src.js', 'src-id', jasmine.any(Promise.resolve.constructor), jasmine.any(Promise.reject.constructor));
});
});
describe('.appendScript', () => {
beforeEach(() => {
spyOn(document.body, 'appendChild');
});
ClassSpecHelper.itShouldBeAStaticMethod(LoadScript, 'appendScript');
describe('when called', () => {
let mockScriptTag;
beforeEach(() => {
mockScriptTag = {};
spyOn(document, 'createElement').and.returnValue(mockScriptTag);
LoadScript.appendScript('src.js', 'src-id', () => {}, () => {});
});
it('should create a script tag', () => {
expect(document.createElement).toHaveBeenCalledWith('script');
});
it('should set the MIME type', () => {
expect(mockScriptTag.type).toBe('text/javascript');
});
it('should set the script id', () => {
expect(mockScriptTag.id).toBe('src-id');
});
it('should set an onload handler', () => {
expect(mockScriptTag.onload).toEqual(jasmine.any(Function));
});
it('should set an onerror handler', () => {
expect(mockScriptTag.onerror).toEqual(jasmine.any(Function));
});
it('should set the src attribute', () => {
expect(mockScriptTag.src).toBe('src.js');
});
it('should append the script tag to the body element', () => {
expect(document.body.appendChild).toHaveBeenCalledWith(mockScriptTag);
});
});
it('should not set the script id if no id is provided', () => {
const mockScriptTag = {};
spyOn(document, 'createElement').and.returnValue(mockScriptTag);
LoadScript.appendScript('src.js', undefined);
expect(mockScriptTag.id).toBeUndefined();
});
});
});

View file

@ -0,0 +1,11 @@
import RavenConfig from '~/raven/index';
describe('RavenConfig options', () => {
it('should set sentryDsn');
it('should set currentUserId');
it('should set whitelistUrls');
it('should set isProduction');
});

View file

@ -0,0 +1,137 @@
import Raven from 'raven-js';
import RavenConfig from '~/raven/raven_config';
import ClassSpecHelper from '../helpers/class_spec_helper';
fdescribe('RavenConfig', () => {
describe('init', () => {
beforeEach(() => {
spyOn(RavenConfig, 'configure');
spyOn(RavenConfig, 'bindRavenErrors');
spyOn(RavenConfig, 'setUser');
});
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'init');
describe('when called', () => {
let options;
beforeEach(() => {
options = {
sentryDsn: '//sentryDsn',
ravenAssetUrl: '//ravenAssetUrl',
currentUserId: 1,
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
};
RavenConfig.init(options);
});
it('should set the options property', () => {
expect(RavenConfig.options).toEqual(options);
});
it('should call the configure method', () => {
expect(RavenConfig.configure).toHaveBeenCalled();
});
it('should call the error bindings method', () => {
expect(RavenConfig.bindRavenErrors).toHaveBeenCalled();
});
it('should call setUser', () => {
expect(RavenConfig.setUser).toHaveBeenCalled();
});
});
it('should not call setUser if there is no current user ID', () => {
RavenConfig.init({
sentryDsn: '//sentryDsn',
ravenAssetUrl: '//ravenAssetUrl',
currentUserId: undefined,
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
});
expect(RavenConfig.setUser).not.toHaveBeenCalled();
});
});
describe('configure', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'configure');
describe('when called', () => {
let options;
let raven;
beforeEach(() => {
options = {
sentryDsn: '//sentryDsn',
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
};
raven = jasmine.createSpyObj('raven', ['install']);
spyOn(Raven, 'config').and.returnValue(raven);
spyOn(Raven, 'install');
RavenConfig.configure.call({
options,
});
});
it('should call Raven.config', () => {
expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, {
whitelistUrls: options.whitelistUrls,
environment: 'production',
});
});
it('should call Raven.install', () => {
expect(Raven.install).toHaveBeenCalled();
});
describe('if isProduction is false', () => {
beforeEach(() => {
options.isProduction = false;
RavenConfig.configure.call({
options,
});
});
it('should set .environment to development', () => {
expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, {
whitelistUrls: options.whitelistUrls,
environment: 'development',
});
});
});
});
});
describe('setUser', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'setUser');
describe('when called', () => {
beforeEach(() => {});
});
});
describe('bindRavenErrors', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'bindRavenErrors');
describe('when called', () => {
beforeEach(() => {});
});
});
describe('handleRavenErrors', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'handleRavenErrors');
describe('when called', () => {
beforeEach(() => {});
});
});
});

View file

@ -1,142 +0,0 @@
/* global ClassSpecHelper */
/*= require raven */
/*= require lib/utils/load_script */
/*= require raven_config */
/*= require class_spec_helper */
describe('RavenConfig', () => {
const global = window.gl || (window.gl = {});
const RavenConfig = global.RavenConfig;
it('should be defined in the global scope', () => {
expect(RavenConfig).toBeDefined();
});
describe('.init', () => {
beforeEach(() => {
spyOn(global.LoadScript, 'load').and.callThrough();
spyOn(document, 'querySelector').and.returnValue(undefined);
spyOn(RavenConfig, 'configure');
spyOn(RavenConfig, 'bindRavenErrors');
spyOn(RavenConfig, 'setUser');
spyOn(Promise, 'reject');
});
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'init');
describe('when called', () => {
let options;
let initPromise;
beforeEach(() => {
options = {
sentryDsn: '//sentryDsn',
ravenAssetUrl: '//ravenAssetUrl',
currentUserId: 1,
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
};
initPromise = RavenConfig.init(options);
});
it('should set the options property', () => {
expect(RavenConfig.options).toEqual(options);
});
it('should load a #raven-js script with the raven asset URL', () => {
expect(global.LoadScript.load).toHaveBeenCalledWith(options.ravenAssetUrl, 'raven-js');
});
it('should return a promise', () => {
expect(initPromise).toEqual(jasmine.any(Promise));
});
it('should call the configure method', () => {
initPromise.then(() => {
expect(RavenConfig.configure).toHaveBeenCalled();
});
});
it('should call the error bindings method', () => {
initPromise.then(() => {
expect(RavenConfig.bindRavenErrors).toHaveBeenCalled();
});
});
it('should call setUser', () => {
initPromise.then(() => {
expect(RavenConfig.setUser).toHaveBeenCalled();
});
});
});
it('should not call setUser if there is no current user ID', () => {
RavenConfig.init({
sentryDsn: '//sentryDsn',
ravenAssetUrl: '//ravenAssetUrl',
currentUserId: undefined,
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
});
expect(RavenConfig.setUser).not.toHaveBeenCalled();
});
it('should reject if there is no Sentry DSN', () => {
RavenConfig.init({
sentryDsn: undefined,
ravenAssetUrl: '//ravenAssetUrl',
currentUserId: 1,
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
});
expect(Promise.reject).toHaveBeenCalledWith('sentry dsn and raven asset url is required');
});
it('should reject if there is no Raven asset URL', () => {
RavenConfig.init({
sentryDsn: '//sentryDsn',
ravenAssetUrl: undefined,
currentUserId: 1,
whitelistUrls: ['//gitlabUrl'],
isProduction: true,
});
expect(Promise.reject).toHaveBeenCalledWith('sentry dsn and raven asset url is required');
});
});
describe('.configure', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'configure');
describe('when called', () => {
beforeEach(() => {});
});
});
describe('.setUser', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'setUser');
describe('when called', () => {
beforeEach(() => {});
});
});
describe('.bindRavenErrors', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'bindRavenErrors');
describe('when called', () => {
beforeEach(() => {});
});
});
describe('.handleRavenErrors', () => {
ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'handleRavenErrors');
describe('when called', () => {
beforeEach(() => {});
});
});
});

File diff suppressed because it is too large Load diff

View file

@ -2730,7 +2730,7 @@ json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1:
dependencies:
jsonify "~0.0.0"
json-stringify-safe@~5.0.1:
json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
@ -3604,6 +3604,12 @@ raphael@^2.2.7:
dependencies:
eve-raphael "0.5.0"
raven-js@^3.14.0:
version "3.14.0"
resolved "https://registry.yarnpkg.com/raven-js/-/raven-js-3.14.0.tgz#94dda81d975fdc4a42f193db437cf70021d654e0"
dependencies:
json-stringify-safe "^5.0.1"
raw-body@~2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.2.0.tgz#994976cf6a5096a41162840492f0bdc5d6e7fb96"