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
@@ -32,7 +32,7 @@ test("save", function() {
controller = this.subject({ model: [badge, otherBadge] });
controller.send('selectBadge', badge);
sinon.stub(badge, "save").returns(Ember.RSVP.resolve({}));
sandbox.stub(badge, "save").returns(Ember.RSVP.resolve({}));
controller.send("save");
ok(badge.save.calledOnce, "called save on the badge");
});
@@ -42,7 +42,7 @@ test("destroy", function() {
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
controller = this.subject({model: [badge, otherBadge]});
sinon.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
sandbox.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
bootbox.confirm = function(text, yes, no, func) {
func(false);
@@ -2,7 +2,7 @@ module("Discourse.AdminUser");
asyncTestDiscourse('generate key', function() {
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 1234, key: 'asdfasdf'}}));
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 1234, key: 'asdfasdf'}}));
var adminUser = Discourse.AdminUser.create({id: 333});
@@ -19,7 +19,7 @@ asyncTestDiscourse('revoke key', function() {
var apiKey = Discourse.ApiKey.create({id: 1234, key: 'asdfasdf'}),
adminUser = Discourse.AdminUser.create({id: 333, api_key: apiKey});
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve());
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve());
equal(adminUser.get('api_key'), apiKey, 'it has the api key in the beginning');
adminUser.revokeApiKey().then(function() {
@@ -27,4 +27,4 @@ asyncTestDiscourse('revoke key', function() {
ok(Discourse.ajax.calledWith("/admin/users/333/revoke_api_key", { type: 'DELETE' }), "it DELETEd to the url");
blank(adminUser.get('api_key'), 'it cleared the api_key');
});
});
});
@@ -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");
});
});
});
@@ -1,7 +1,7 @@
module("Discourse.FlaggedPost");
test('delete first post', function() {
this.stub(Discourse, 'ajax');
sandbox.stub(Discourse, 'ajax');
Discourse.FlaggedPost.create({ id: 1, topic_id: 2, post_number: 1 })
.deletePost();
@@ -10,7 +10,7 @@ test('delete first post', function() {
});
test('delete second post', function() {
this.stub(Discourse, 'ajax');
sandbox.stub(Discourse, 'ajax');
Discourse.FlaggedPost.create({ id: 1, topic_id: 2, post_number: 2 })
.deletePost();