BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
13b60eb7
Unverified
Commit
13b60eb7
authored
Apr 13, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Index and singleton improvements with some more unit, more to come
parent
cfd3d0fd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
84 deletions
+66
-84
index.js
app/assets/javascripts/raven/index.js
+4
-2
raven_config.js
app/assets/javascripts/raven/raven_config.js
+14
-11
sentry_helper_spec.rb
spec/helpers/sentry_helper_spec.rb
+11
-4
index_spec.js
spec/javascripts/raven/index_spec.js
+36
-6
raven_config_spec.js
spec/javascripts/raven/raven_config_spec.js
+1
-12
spec_helper.js
spec/javascripts/spec_helper.js
+0
-49
No files found.
app/assets/javascripts/raven/index.js
View file @
13b60eb7
import
RavenConfig
from
'./raven_config'
;
RavenConfig
.
init
(
{
const
index
=
RavenConfig
.
init
.
bind
(
RavenConfig
,
{
sentryDsn
:
gon
.
sentry_dsn
,
currentUserId
:
gon
.
current_user_id
,
whitelistUrls
:
[
gon
.
gitlab_url
],
isProduction
:
gon
.
is_production
,
});
export
default
RavenConfig
;
index
();
export
default
index
;
app/assets/javascripts/raven/raven_config.js
View file @
13b60eb7
import
Raven
from
'raven-js'
;
import
$
from
'jquery'
;
c
lass
RavenConfig
{
static
init
(
options
=
{})
{
c
onst
RavenConfig
=
{
init
(
options
=
{})
{
this
.
options
=
options
;
this
.
configure
();
this
.
bindRavenErrors
();
if
(
this
.
options
.
currentUserId
)
this
.
setUser
();
}
static
configure
()
{
return
this
;
},
configure
()
{
Raven
.
config
(
this
.
options
.
sentryDsn
,
{
whitelistUrls
:
this
.
options
.
whitelistUrls
,
environment
:
this
.
options
.
isProduction
?
'production'
:
'development'
,
}).
install
();
}
}
,
s
tatic
s
etUser
()
{
setUser
()
{
Raven
.
setUserContext
({
id
:
this
.
options
.
currentUserId
,
});
}
}
,
static
bindRavenErrors
()
{
bindRavenErrors
()
{
$
(
document
).
on
(
'ajaxError.raven'
,
this
.
handleRavenErrors
);
}
}
,
static
handleRavenErrors
(
event
,
req
,
config
,
err
)
{
handleRavenErrors
(
event
,
req
,
config
,
err
)
{
const
error
=
err
||
req
.
statusText
;
Raven
.
captureMessage
(
error
,
{
...
...
@@ -40,7 +43,7 @@ class RavenConfig {
event
,
},
});
}
}
,
}
export
default
RavenConfig
;
spec/helpers/sentry_helper_spec.rb
View file @
13b60eb7
...
...
@@ -3,13 +3,20 @@ require 'spec_helper'
describe
SentryHelper
do
describe
'#sentry_dsn_public'
do
it
'returns nil if no sentry_dsn is set'
do
allow
(
ApplicationSetting
.
current
).
to
receive
(
:sentry_dsn
).
and_return
(
nil
)
expect
(
helper
.
sentry_dsn_public
).
to
eq
(
nil
)
mock_sentry_dsn
(
nil
)
expect
(
helper
.
sentry_dsn_public
).
to
eq
nil
end
it
'returns the uri string with no password if sentry_dsn is set'
do
allow
(
ApplicationSetting
.
current
).
to
receive
(
:sentry_dsn
).
and_return
(
'https://test:dsn@host/path'
)
expect
(
helper
.
sentry_dsn_public
).
to
eq
(
'https://test@host/path'
)
mock_sentry_dsn
(
'https://test:dsn@host/path'
)
expect
(
helper
.
sentry_dsn_public
).
to
eq
'https://test@host/path'
end
end
def
mock_sentry_dsn
(
value
)
allow_message_expectations_on_nil
allow
(
ApplicationSetting
.
current
).
to
receive
(
:sentry_dsn
).
and_return
(
value
)
end
end
spec/javascripts/raven/index_spec.js
View file @
13b60eb7
import
RavenConfig
from
'~/raven/index'
;
import
RavenConfig
from
'~/raven/raven_config'
;
import
index
from
'~/raven/index'
;
describe
(
'RavenConfig options'
,
()
=>
{
it
(
'should set sentryDsn'
);
fdescribe
(
'RavenConfig options'
,
()
=>
{
let
sentryDsn
;
let
currentUserId
;
let
gitlabUrl
;
let
isProduction
;
let
indexReturnValue
;
it
(
'should set currentUserId'
);
beforeEach
(()
=>
{
sentryDsn
=
'sentryDsn'
;
currentUserId
=
'currentUserId'
;
gitlabUrl
=
'gitlabUrl'
;
isProduction
=
'isProduction'
;
it
(
'should set whitelistUrls'
);
window
.
gon
=
{
sentry_dsn
:
sentryDsn
,
current_user_id
:
currentUserId
,
gitlab_url
:
gitlabUrl
,
is_production
:
isProduction
,
};
it
(
'should set isProduction'
);
spyOn
(
RavenConfig
.
init
,
'bind'
);
indexReturnValue
=
index
();
});
it
(
'should init with .sentryDsn, .currentUserId, .whitelistUrls and .isProduction'
,
()
=>
{
expect
(
RavenConfig
.
init
.
bind
).
toHaveBeenCalledWith
(
RavenConfig
,
{
sentryDsn
,
currentUserId
,
whitelistUrls
:
[
gitlabUrl
],
isProduction
,
});
});
it
(
'should return RavenConfig'
,
()
=>
{
expect
(
indexReturnValue
).
toBe
(
RavenConfig
);
});
});
spec/javascripts/raven/raven_config_spec.js
View file @
13b60eb7
import
Raven
from
'raven-js'
;
import
RavenConfig
from
'~/raven/raven_config'
;
import
ClassSpecHelper
from
'../helpers/class_spec_helper'
;
f
describe
(
'RavenConfig'
,
()
=>
{
describe
(
'RavenConfig'
,
()
=>
{
describe
(
'init'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
RavenConfig
,
'configure'
);
...
...
@@ -10,8 +9,6 @@ fdescribe('RavenConfig', () => {
spyOn
(
RavenConfig
,
'setUser'
);
});
ClassSpecHelper
.
itShouldBeAStaticMethod
(
RavenConfig
,
'init'
);
describe
(
'when called'
,
()
=>
{
let
options
;
...
...
@@ -58,8 +55,6 @@ fdescribe('RavenConfig', () => {
});
describe
(
'configure'
,
()
=>
{
ClassSpecHelper
.
itShouldBeAStaticMethod
(
RavenConfig
,
'configure'
);
describe
(
'when called'
,
()
=>
{
let
options
;
let
raven
;
...
...
@@ -112,24 +107,18 @@ fdescribe('RavenConfig', () => {
});
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
(()
=>
{});
});
...
...
spec/javascripts/spec_helper.js
deleted
100644 → 0
View file @
cfd3d0fd
/* eslint-disable space-before-function-paren */
// PhantomJS (Teaspoons default driver) doesn't have support for
// Function.prototype.bind, which has caused confusion. Use this polyfill to
// avoid the confusion.
/*= require support/bind-poly */
// You can require your own javascript files here. By default this will include
// everything in application, however you may get better load performance if you
// require the specific files that are being used in the spec that tests them.
/*= require jquery */
/*= require jquery.turbolinks */
/*= require bootstrap */
/*= require underscore */
/*= require es6-promise.auto */
// Teaspoon includes some support files, but you can use anything from your own
// support path too.
// require support/jasmine-jquery-1.7.0
// require support/jasmine-jquery-2.0.0
/*= require support/jasmine-jquery-2.1.0 */
// require support/sinon
// require support/your-support-file
// Deferring execution
// If you're using CommonJS, RequireJS or some other asynchronous library you can
// defer execution. Call Teaspoon.execute() after everything has been loaded.
// Simple example of a timeout:
// Teaspoon.defer = true
// setTimeout(Teaspoon.execute, 1000)
// Matching files
// By default Teaspoon will look for files that match
// _spec.{js,js.es6}. Add a filename_spec.js file in your spec path
// and it'll be included in the default suite automatically. If you want to
// customize suites, check out the configuration in teaspoon_env.rb
// Manifest
// If you'd rather require your spec files manually (to control order for
// instance) you can disable the suite matcher in the configuration and use this
// file as a manifest.
// For more information: http://github.com/modeset/teaspoon
// set our fixtures path
jasmine
.
getFixtures
().
fixturesPath
=
'/teaspoon/fixtures'
;
jasmine
.
getJSONFixtures
().
fixturesPath
=
'/teaspoon/fixtures'
;
// defined in ActionDispatch::TestRequest
// see https://github.com/rails/rails/blob/v4.2.7.1/actionpack/lib/action_dispatch/testing/test_request.rb#L7
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
TEST_HOST
=
'http://test.host'
;
window
.
gon
=
window
.
gon
||
{};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment