mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Revert "Revert "REFACTOR: support booting discourse with DISCOURSE_NO_CONSTANTS""
This reverts commit c21457d6a7.
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import createStore from 'helpers/create-store';
|
||||
import AdminUser from 'admin/models/admin-user';
|
||||
|
||||
var buildPost = function(args) {
|
||||
return Discourse.Post.create(_.merge({
|
||||
@@ -9,7 +10,7 @@ var buildPost = function(args) {
|
||||
};
|
||||
|
||||
var buildAdminUser = function(args) {
|
||||
return Discourse.AdminUser.create(_.merge({
|
||||
return AdminUser.create(_.merge({
|
||||
id: 11,
|
||||
username: 'urist'
|
||||
}, args || {}));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Quote from 'discourse/lib/quote';
|
||||
import Post from 'discourse/models/post';
|
||||
|
||||
module("Discourse.BBCode");
|
||||
|
||||
@@ -78,7 +79,7 @@ test("size tags", function() {
|
||||
|
||||
test("quotes", function() {
|
||||
|
||||
var post = Discourse.Post.create({
|
||||
var post = Post.create({
|
||||
cooked: "<p><b>lorem</b> ipsum</p>",
|
||||
username: "eviltrout",
|
||||
post_number: 1,
|
||||
|
||||
@@ -185,7 +185,7 @@ test('initial category when uncategorized is not allowed', function() {
|
||||
test('open with a quote', function() {
|
||||
const quote = '[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]';
|
||||
const newComposer = function() {
|
||||
return openComposer({action: Discourse.Composer.REPLY, draftKey: 'asfd', draftSequence: 1, quote: quote});
|
||||
return openComposer({action: Composer.REPLY, draftKey: 'asfd', draftSequence: 1, quote: quote});
|
||||
};
|
||||
|
||||
equal(newComposer().get('originalText'), quote, "originalText is the quote" );
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import EmailLog from 'admin/models/email-log';
|
||||
|
||||
module("Discourse.EmailLog");
|
||||
|
||||
test("create", function() {
|
||||
ok(Discourse.EmailLog.create(), "it can be created without arguments");
|
||||
ok(EmailLog.create(), "it can be created without arguments");
|
||||
});
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { blank } from 'helpers/qunit-helpers';
|
||||
import Report from 'admin/models/report';
|
||||
|
||||
module("Discourse.Report");
|
||||
module("Report");
|
||||
|
||||
function reportWithData(data) {
|
||||
return Discourse.Report.create({
|
||||
return Report.create({
|
||||
type: 'topics',
|
||||
data: _.map(data, function(val, index) {
|
||||
return { x: moment().subtract(index, "days").format('YYYY-MM-DD'), y: val };
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module("Discourse.StaffActionLog");
|
||||
import StaffActionLog from 'admin/models/staff-action-log';
|
||||
|
||||
module("StaffActionLog");
|
||||
|
||||
test("create", function() {
|
||||
ok(Discourse.StaffActionLog.create(), "it can be created without arguments");
|
||||
ok(StaffActionLog.create(), "it can be created without arguments");
|
||||
});
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
module("Discourse.VersionCheck");
|
||||
import VersionCheck from 'admin/models/version-check';
|
||||
|
||||
module("VersionCheck");
|
||||
|
||||
test('dataIsOld', function() {
|
||||
var dataIsOld = function(args, expected, message) {
|
||||
equal(Discourse.VersionCheck.create(args).get('dataIsOld'), expected, message);
|
||||
equal(VersionCheck.create(args).get('dataIsOld'), expected, message);
|
||||
};
|
||||
|
||||
dataIsOld({updated_at: moment().subtract(2, 'hours').toJSON()}, false, '2 hours ago');
|
||||
@@ -15,7 +17,7 @@ test('staleData', function() {
|
||||
return moment().subtract(hoursAgo, 'hours').toJSON();
|
||||
};
|
||||
var staleData = function(args, expected, message) {
|
||||
equal(Discourse.VersionCheck.create(args).get('staleData'), expected, message);
|
||||
equal(VersionCheck.create(args).get('staleData'), expected, message);
|
||||
};
|
||||
|
||||
staleData({missing_versions_count: 0, installed_version: '0.9.3', latest_version: '0.9.3', updated_at: updatedAt(2)}, false, 'up to date');
|
||||
|
||||
Reference in New Issue
Block a user