diff options
-rw-r--r-- | app/assets/javascripts/raven/raven_config.js | 6 | ||||
-rw-r--r-- | config/webpack.config.js | 3 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | spec/javascripts/.eslintrc | 15 | ||||
-rw-r--r-- | spec/javascripts/raven/raven_config_spec.js | 30 | ||||
-rw-r--r-- | yarn.lock | 4 |
6 files changed, 32 insertions, 27 deletions
diff --git a/app/assets/javascripts/raven/raven_config.js b/app/assets/javascripts/raven/raven_config.js index bb9be7cb196..9c756a4130b 100644 --- a/app/assets/javascripts/raven/raven_config.js +++ b/app/assets/javascripts/raven/raven_config.js @@ -1,5 +1,4 @@ import Raven from 'raven-js'; -import $ from 'jquery'; const RavenConfig = { init(options = {}) { @@ -24,11 +23,12 @@ const RavenConfig = { }, bindRavenErrors() { - $(document).on('ajaxError.raven', this.handleRavenErrors); + window.$(document).on('ajaxError.raven', this.handleRavenErrors); }, handleRavenErrors(event, req, config, err) { const error = err || req.statusText; + const responseText = req.responseText || 'Unknown response text'; Raven.captureMessage(error, { extra: { @@ -36,7 +36,7 @@ const RavenConfig = { url: config.url, data: config.data, status: req.status, - response: req.responseText.substring(0, 100), + response: responseText.substring(0, 100), error, event, }, diff --git a/config/webpack.config.js b/config/webpack.config.js index 79c1d66a242..2153c8bbaf2 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -15,7 +15,6 @@ var DEV_SERVER_HOST = process.env.DEV_SERVER_HOST || 'localhost'; var DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808; var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false'; var WEBPACK_REPORT = process.env.WEBPACK_REPORT; -var rewirePlugin = IS_PRODUCTION ? '?plugins=rewire' : ''; var config = { context: path.join(ROOT_PATH, 'app/assets/javascripts'), @@ -69,7 +68,7 @@ var config = { { test: /\.js$/, exclude: /(node_modules|vendor\/assets)/, - loader: `babel-loader${rewirePlugin}`, + loader: 'babel-loader', }, { test: /\.vue$/, diff --git a/package.json b/package.json index cf66d7ec58e..4ac1526bba1 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ }, "devDependencies": { "babel-plugin-istanbul": "^4.0.0", - "babel-plugin-rewire": "^1.1.0", "eslint": "^3.10.1", "eslint-config-airbnb-base": "^10.0.1", "eslint-import-resolver-webpack": "^0.8.1", diff --git a/spec/javascripts/.eslintrc b/spec/javascripts/.eslintrc index a3a8bb050c9..3d922021978 100644 --- a/spec/javascripts/.eslintrc +++ b/spec/javascripts/.eslintrc @@ -27,19 +27,6 @@ "jasmine/no-suite-dupes": [1, "branch"], "jasmine/no-spec-dupes": [1, "branch"], "no-console": 0, - "prefer-arrow-callback": 0, - "no-underscore-dangle": [ - 2, - { - "allow": [ - "__GetDependency__", - "__Rewire__", - "__ResetDependency__", - "__get__", - "__set__", - "__RewireAPI__" - ] - } - ] + "prefer-arrow-callback": 0 } } diff --git a/spec/javascripts/raven/raven_config_spec.js b/spec/javascripts/raven/raven_config_spec.js index b8bb558d22e..55f3949c740 100644 --- a/spec/javascripts/raven/raven_config_spec.js +++ b/spec/javascripts/raven/raven_config_spec.js @@ -1,5 +1,5 @@ import Raven from 'raven-js'; -import RavenConfig, { __RewireAPI__ as RavenConfigRewire } from '~/raven/raven_config'; +import RavenConfig from '~/raven/raven_config'; describe('RavenConfig', () => { describe('init', () => { @@ -122,13 +122,13 @@ describe('RavenConfig', () => { $document = jasmine.createSpyObj('$document', ['on']); $ = jasmine.createSpy('$').and.returnValue($document); - RavenConfigRewire.__set__('$', $); + window.$ = $; RavenConfig.bindRavenErrors(); }); it('should query for document using jquery', () => { - expect($).toHaveBeenCalledWith(document); + expect(window.$).toHaveBeenCalledWith(document); }); it('should call .on', function () { @@ -188,5 +188,29 @@ describe('RavenConfig', () => { }); }); }); + + describe('if no req.responseText is provided', () => { + beforeEach(() => { + req.responseText = undefined; + + Raven.captureMessage.calls.reset(); + + RavenConfig.handleRavenErrors(event, req, config, err); + }); + + it('should use `Unknown response text` as the response', () => { + expect(Raven.captureMessage).toHaveBeenCalledWith(err, { + extra: { + type: config.type, + url: config.url, + data: config.data, + status: req.status, + response: 'Unknown response text', + error: err, + event, + }, + }); + }); + }); }); }); diff --git a/yarn.lock b/yarn.lock index e41f737c88c..dd169cf28ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -425,10 +425,6 @@ babel-plugin-istanbul@^4.0.0: istanbul-lib-instrument "^1.4.2" test-exclude "^4.0.0" -babel-plugin-rewire@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/babel-plugin-rewire/-/babel-plugin-rewire-1.1.0.tgz#a6b966d9d8c06c03d95dcda2eec4e2521519549b" - babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" |