Lots of work on tests

This commit is contained in:
Robin Ward
2014-07-30 18:56:01 -04:00
parent b6684e7168
commit 6f36d5996d
43 changed files with 248 additions and 311 deletions

View File

@ -9,7 +9,7 @@ test('create', function() {
asyncTestDiscourse('find', function() {
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
Discourse.ApiKey.find().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api"), "it GETs the keys");
@ -17,7 +17,7 @@ asyncTestDiscourse('find', function() {
});
asyncTestDiscourse('generateMasterKey', function() {
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {}}));
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {}}));
Discourse.ApiKey.generateMasterKey().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api/key", {type: 'POST'}), "it POSTs to create a master key");
@ -27,7 +27,7 @@ asyncTestDiscourse('generateMasterKey', function() {
asyncTestDiscourse('regenerate', function() {
var apiKey = Discourse.ApiKey.create({id: 3456});
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 3456}}));
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 3456}}));
apiKey.regenerate().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api/key", {type: 'PUT', data: {id: 3456}}), "it PUTs the key");
@ -37,9 +37,9 @@ asyncTestDiscourse('regenerate', function() {
asyncTestDiscourse('revoke', function() {
var apiKey = Discourse.ApiKey.create({id: 3456});
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
apiKey.revoke().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api/key", {type: 'DELETE', data: {id: 3456}}), "it DELETES the key");
});
});
});