Updated specs, added rewire, updated layouts to move conditional raven and gon to head
This commit is contained in:
parent
067361327b
commit
e22bd9650d
9 changed files with 86 additions and 19 deletions
|
@ -28,9 +28,12 @@
|
|||
= stylesheet_link_tag "application", media: "all"
|
||||
= stylesheet_link_tag "print", media: "print"
|
||||
|
||||
= Gon::Base.render_data
|
||||
|
||||
= javascript_include_tag(*webpack_asset_paths("runtime"))
|
||||
= javascript_include_tag(*webpack_asset_paths("common"))
|
||||
= javascript_include_tag(*webpack_asset_paths("main"))
|
||||
= javascript_include_tag(*webpack_asset_paths("raven")) if sentry_enabled?
|
||||
|
||||
- if content_for?(:page_specific_javascripts)
|
||||
= yield :page_specific_javascripts
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
%html{ lang: "en", class: "#{page_class}" }
|
||||
= render "layouts/head"
|
||||
%body{ class: @body_class, data: { page: body_data_page, project: "#{@project.path if @project}", group: "#{@group.path if @group}" } }
|
||||
= Gon::Base.render_data
|
||||
|
||||
= render "layouts/header/default", title: header_title
|
||||
= render 'layouts/page', sidebar: sidebar, nav: nav
|
||||
|
||||
= yield :scripts_body
|
||||
= render "layouts/init_auto_complete" if @gfm_form
|
||||
|
||||
= javascript_include_tag(*webpack_asset_paths("raven")) if sentry_enabled?
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
= render "layouts/head"
|
||||
%body.ui_charcoal.login-page.application.navless{ data: { page: body_data_page } }
|
||||
.page-wrap
|
||||
= Gon::Base.render_data
|
||||
= render "layouts/header/empty"
|
||||
= render "layouts/broadcast"
|
||||
.container.navless-container
|
||||
|
@ -35,5 +34,3 @@
|
|||
= 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?
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
%html{ lang: "en" }
|
||||
= render "layouts/head"
|
||||
%body.ui_charcoal.login-page.application.navless
|
||||
= Gon::Base.render_data
|
||||
= render "layouts/header/empty"
|
||||
= render "layouts/broadcast"
|
||||
.container.navless-container
|
||||
|
@ -16,5 +15,3 @@
|
|||
= 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?
|
||||
|
|
|
@ -61,7 +61,7 @@ var config = {
|
|||
{
|
||||
test: /\.js$/,
|
||||
exclude: /(node_modules|vendor\/assets)/,
|
||||
loader: 'babel-loader'
|
||||
loader: 'babel-loader?plugins=rewire'
|
||||
},
|
||||
{
|
||||
test: /\.svg$/,
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
},
|
||||
"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",
|
||||
|
|
|
@ -27,6 +27,19 @@
|
|||
"jasmine/no-suite-dupes": [1, "branch"],
|
||||
"jasmine/no-spec-dupes": [1, "branch"],
|
||||
"no-console": 0,
|
||||
"prefer-arrow-callback": 0
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-underscore-dangle": [
|
||||
2,
|
||||
{
|
||||
"allow": [
|
||||
"__GetDependency__",
|
||||
"__Rewire__",
|
||||
"__ResetDependency__",
|
||||
"__get__",
|
||||
"__set__",
|
||||
"__RewireAPI__"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import $ from 'jquery';
|
||||
import Raven from 'raven-js';
|
||||
import RavenConfig from '~/raven/raven_config';
|
||||
import RavenConfig, { __RewireAPI__ as RavenConfigRewire } from '~/raven/raven_config';
|
||||
|
||||
fdescribe('RavenConfig', () => {
|
||||
describe('RavenConfig', () => {
|
||||
describe('init', () => {
|
||||
let options;
|
||||
|
||||
|
@ -116,21 +115,78 @@ fdescribe('RavenConfig', () => {
|
|||
});
|
||||
|
||||
describe('bindRavenErrors', () => {
|
||||
let $document;
|
||||
let $;
|
||||
|
||||
beforeEach(() => {
|
||||
$document = jasmine.createSpyObj('$document', ['on']);
|
||||
$ = jasmine.createSpy('$').and.returnValue($document);
|
||||
|
||||
RavenConfigRewire.__set__('$', $);
|
||||
|
||||
RavenConfig.bindRavenErrors();
|
||||
});
|
||||
|
||||
it('should query for document using jquery', () => {
|
||||
console.log($, 'or', $.fn);
|
||||
// expect($).toHaveBeenCalledWith()
|
||||
expect($).toHaveBeenCalledWith(document);
|
||||
});
|
||||
|
||||
it('should call .on', function () {
|
||||
// expect($document.on).toHaveBeenCalledWith('ajaxError.raven', RavenConfig.handleRavenErrors);
|
||||
expect($document.on).toHaveBeenCalledWith('ajaxError.raven', RavenConfig.handleRavenErrors);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleRavenErrors', () => {
|
||||
beforeEach(() => {});
|
||||
let event;
|
||||
let req;
|
||||
let config;
|
||||
let err;
|
||||
|
||||
beforeEach(() => {
|
||||
event = {};
|
||||
req = { status: 'status', responseText: 'responseText', statusText: 'statusText' };
|
||||
config = { type: 'type', url: 'url', data: 'data' };
|
||||
err = {};
|
||||
|
||||
spyOn(Raven, 'captureMessage');
|
||||
|
||||
RavenConfig.handleRavenErrors(event, req, config, err);
|
||||
});
|
||||
|
||||
it('should call Raven.captureMessage', () => {
|
||||
expect(Raven.captureMessage).toHaveBeenCalledWith(err, {
|
||||
extra: {
|
||||
type: config.type,
|
||||
url: config.url,
|
||||
data: config.data,
|
||||
status: req.status,
|
||||
response: req.responseText.substring(0, 100),
|
||||
error: err,
|
||||
event,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
describe('if no err is provided', () => {
|
||||
beforeEach(() => {
|
||||
Raven.captureMessage.calls.reset();
|
||||
|
||||
RavenConfig.handleRavenErrors(event, req, config);
|
||||
});
|
||||
|
||||
it('should use req.statusText as the error value', () => {
|
||||
expect(Raven.captureMessage).toHaveBeenCalledWith(req.statusText, {
|
||||
extra: {
|
||||
type: config.type,
|
||||
url: config.url,
|
||||
data: config.data,
|
||||
status: req.status,
|
||||
response: req.responseText.substring(0, 100),
|
||||
error: req.statusText,
|
||||
event,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -406,6 +406,10 @@ 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"
|
||||
|
|
Loading…
Reference in a new issue