163 lines
6.3 KiB
HTML
163 lines
6.3 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Code coverage report for common/models/User-Identity.js</title>
|
|
<meta charset="utf-8">
|
|
<link rel="stylesheet" href="../../prettify.css">
|
|
<link rel="stylesheet" href="../../base.css">
|
|
<style type='text/css'>
|
|
div.coverage-summary .sorter {
|
|
background-image: url(../../sort-arrow-sprite.png);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header low">
|
|
<h1>Code coverage report for <span class="entity">common/models/User-Identity.js</span></h1>
|
|
<h2>
|
|
Statements: <span class="metric">16.67% <small>(4 / 24)</small></span>
|
|
Branches: <span class="metric">0% <small>(0 / 19)</small></span>
|
|
Functions: <span class="metric">25% <small>(1 / 4)</small></span>
|
|
Lines: <span class="metric">18.18% <small>(4 / 22)</small></span>
|
|
Ignored: <span class="metric"><span class="ignore-none">none</span></span>
|
|
</h2>
|
|
<div class="path"><a href="../../index.html">All files</a> » <a href="index.html">common/models/</a> » User-Identity.js</div>
|
|
</div>
|
|
<div class="body">
|
|
<pre><table class="coverage">
|
|
<tr><td class="line-count">1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36
|
|
37
|
|
38
|
|
39
|
|
40</td><td class="line-coverage"><span class="cline-any cline-yes">1</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">1</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">1</span>
|
|
<span class="cline-any cline-yes">1</span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-no"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var debug = require('debug')('freecc:models:userIdent');
|
|
|
|
var defaultProfileImage =
|
|
require('../utils/constantStrings.json').defaultProfileImage;
|
|
|
|
module.exports = function(UserIdent) {
|
|
UserIdent.observe('before save', <span class="fstat-no" title="function not covered" >function(ctx, next) {</span>
|
|
<span class="cstat-no" title="statement not covered" > var userIdent = ctx.currentInstance || ctx.instance;</span>
|
|
<span class="cstat-no" title="statement not covered" > if (!userIdent) {</span>
|
|
<span class="cstat-no" title="statement not covered" > debug('no user identity instance found');</span>
|
|
<span class="cstat-no" title="statement not covered" > return next();</span>
|
|
}
|
|
<span class="cstat-no" title="statement not covered" > userIdent.user(<span class="fstat-no" title="function not covered" >function(err, user) {</span></span>
|
|
<span class="cstat-no" title="statement not covered" > if (err) { <span class="cstat-no" title="statement not covered" >return next(err); </span>}</span>
|
|
<span class="cstat-no" title="statement not covered" > if (!user) {</span>
|
|
<span class="cstat-no" title="statement not covered" > debug('no user attached to identity!');</span>
|
|
<span class="cstat-no" title="statement not covered" > return next();</span>
|
|
}
|
|
|
|
<span class="cstat-no" title="statement not covered" > var picture = userIdent.profile && userIdent.profile[0] ?</span>
|
|
userIdent.profile[0].value :
|
|
null;
|
|
|
|
// check if user has picture
|
|
// set user.picture from twitter
|
|
<span class="cstat-no" title="statement not covered" > if (picture && !user.picture || user.picture === defaultProfileImage) {</span>
|
|
<span class="cstat-no" title="statement not covered" > debug('use has no pic');</span>
|
|
<span class="cstat-no" title="statement not covered" > user.picture = userIdent.profile.photos[0].value;</span>
|
|
<span class="cstat-no" title="statement not covered" > user.save(<span class="fstat-no" title="function not covered" >function(err) {</span></span>
|
|
<span class="cstat-no" title="statement not covered" > if (err) { <span class="cstat-no" title="statement not covered" >return next(err); </span>}</span>
|
|
<span class="cstat-no" title="statement not covered" > next();</span>
|
|
});
|
|
} else {
|
|
<span class="cstat-no" title="statement not covered" > debug('exiting after user ident');</span>
|
|
<span class="cstat-no" title="statement not covered" > next();</span>
|
|
}
|
|
});
|
|
});
|
|
};
|
|
</pre></td></tr>
|
|
</table></pre>
|
|
|
|
</div>
|
|
<div class="footer">
|
|
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Jun 11 2015 21:16:17 GMT-0400 (EDT)</div>
|
|
</div>
|
|
<script src="../../prettify.js"></script>
|
|
<script>
|
|
window.onload = function () {
|
|
if (typeof prettyPrint === 'function') {
|
|
prettyPrint();
|
|
}
|
|
};
|
|
</script>
|
|
<script src="../../sorter.js"></script>
|
|
</body>
|
|
</html>
|