Revert "Revert "REFACTOR: support booting discourse with DISCOURSE_NO_CONSTANTS""

This reverts commit c21457d6a7a369fb52dfd3cd01b3882055c85d62.
This commit is contained in:
Sam
2015-11-21 12:27:06 +11:00
parent d8734fc542
commit 5c899c765b
99 changed files with 394 additions and 384 deletions

View File

@ -1,11 +1,13 @@
import { blank, present } from 'helpers/qunit-helpers';
import AdminUser from 'admin/models/admin-user';
import ApiKey from 'admin/models/api-key';
module("Discourse.AdminUser");
asyncTestDiscourse('generate key', function() {
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 1234, key: 'asdfasdf'}}));
var adminUser = Discourse.AdminUser.create({id: 333});
var adminUser = AdminUser.create({id: 333});
blank(adminUser.get('api_key'), 'it has no api key by default');
adminUser.generateApiKey().then(function() {
@ -17,8 +19,8 @@ asyncTestDiscourse('generate key', function() {
asyncTestDiscourse('revoke key', function() {
var apiKey = Discourse.ApiKey.create({id: 1234, key: 'asdfasdf'}),
adminUser = Discourse.AdminUser.create({id: 333, api_key: apiKey});
var apiKey = ApiKey.create({id: 1234, key: 'asdfasdf'}),
adminUser = AdminUser.create({id: 333, api_key: apiKey});
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve());

View File

@ -1,9 +1,10 @@
import { present } from 'helpers/qunit-helpers';
import ApiKey from 'admin/models/api-key';
module("Discourse.ApiKey");
test('create', function() {
var apiKey = Discourse.ApiKey.create({id: 123, user: {id: 345}});
var apiKey = ApiKey.create({id: 123, user: {id: 345}});
present(apiKey, 'it creates the api key');
present(apiKey.get('user'), 'it creates the user inside');
@ -12,7 +13,7 @@ test('create', function() {
asyncTestDiscourse('find', function() {
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
Discourse.ApiKey.find().then(function() {
ApiKey.find().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api"), "it GETs the keys");
});
@ -20,14 +21,14 @@ asyncTestDiscourse('find', function() {
asyncTestDiscourse('generateMasterKey', function() {
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {}}));
Discourse.ApiKey.generateMasterKey().then(function() {
ApiKey.generateMasterKey().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api/key", {type: 'POST'}), "it POSTs to create a master key");
});
});
asyncTestDiscourse('regenerate', function() {
var apiKey = Discourse.ApiKey.create({id: 3456});
var apiKey = ApiKey.create({id: 3456});
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 3456}}));
apiKey.regenerate().then(function() {
@ -37,7 +38,7 @@ asyncTestDiscourse('regenerate', function() {
});
asyncTestDiscourse('revoke', function() {
var apiKey = Discourse.ApiKey.create({id: 3456});
var apiKey = ApiKey.create({id: 3456});
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
apiKey.revoke().then(function() {

View File

@ -1,9 +1,11 @@
import FlaggedPost from 'admin/models/flagged-post';
module("Discourse.FlaggedPost");
test('delete first post', function() {
sandbox.stub(Discourse, 'ajax');
Discourse.FlaggedPost.create({ id: 1, topic_id: 2, post_number: 1 })
FlaggedPost.create({ id: 1, topic_id: 2, post_number: 1 })
.deletePost();
ok(Discourse.ajax.calledWith("/t/2", { type: 'DELETE', cache: false }), "it deleted the topic");
@ -12,7 +14,7 @@ test('delete first post', function() {
test('delete second post', function() {
sandbox.stub(Discourse, 'ajax');
Discourse.FlaggedPost.create({ id: 1, topic_id: 2, post_number: 2 })
FlaggedPost.create({ id: 1, topic_id: 2, post_number: 2 })
.deletePost();
ok(Discourse.ajax.calledWith("/posts/1", { type: 'DELETE', cache: false }), "it deleted the post");