Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Handle zamboni not sending fxa data
Browse files Browse the repository at this point in the history
  • Loading branch information
mstriemer authored and ngokevin committed Oct 10, 2014
1 parent 2585a5d commit b51ef47
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/media/js/commonplace/site_config.js
Expand Up @@ -8,8 +8,10 @@ define('site_config', ['defer', 'requests', 'settings', 'urls'],
function fetch() {
var def = defer.Deferred();
requests.get(urls.api.url('site-config')).done(function(data) {
settings.fxa_auth_url = data.fxa.fxa_auth_url;
settings.fxa_auth_state = data.fxa.fxa_auth_state;
if (data.hasOwnProperty('fxa')) {
settings.fxa_auth_url = data.fxa.fxa_auth_url;
settings.fxa_auth_state = data.fxa.fxa_auth_state;
}
settings.switches = data.waffle.switches || [];
def.resolve(data);
}).always(function() {
Expand Down
1 change: 1 addition & 0 deletions src/templates/tests.html
Expand Up @@ -29,6 +29,7 @@ <h2>Unit Tests</h2>
<script type="text/javascript" src="/tests/models.js"></script>
<script type="text/javascript" src="/tests/requests.js"></script>
<script type="text/javascript" src="/tests/rewriters.js"></script>
<script type="text/javascript" src="/tests/site_config.js"></script>
<script type="text/javascript" src="/tests/storage.js"></script>
<script type="text/javascript" src="/tests/urls.js"></script>
<script type="text/javascript" src="/tests/user.js"></script>
Expand Down
32 changes: 32 additions & 0 deletions src/tests/site_config.js
Expand Up @@ -52,6 +52,9 @@ test('sets fxa auth', function(done, fail) {
{
requests: {
get: mockSiteConfigRequestSuccess({
waffle: {
switches: ['dummy-switch']
},
fxa: {
fxa_auth_url: 'http://ngokevin.com',
fxa_auth_state: 'somemoreseolongtoken'
Expand All @@ -71,4 +74,33 @@ test('sets fxa auth', function(done, fail) {
fail
);
});

test('handles no fxa auth data', function(done, fail) {
var settings = {
api_cdn_whitelist: {}
};
mock(
'site_config',
{
requests: {
get: mockSiteConfigRequestSuccess({
waffle: {
switches: ['dummy-switch']
},
})
},
settings: settings,
},
function(siteConfig) {
var promise = siteConfig.promise;
promise.then(function() {
eq_(settings.fxa_auth_url, undefined);
eq_(settings.fxa_auth_state, undefined);
done();
});
},
fail
);
});

})();

0 comments on commit b51ef47

Please sign in to comment.