mirror of
https://github.com/discourse/discourse.git
synced 2025-02-28 08:19:13 +00:00
DEV: Use getOwner
from @ember/application
in tests (#23670)
This commit is contained in:
parent
3669723a86
commit
52722c7086
@ -12,7 +12,7 @@ import {
|
||||
getCachedTopicList,
|
||||
setCachedTopicList,
|
||||
} from "discourse/lib/cached-topic-list";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
acceptance("Personal Message", function (needs) {
|
||||
needs.user();
|
||||
@ -27,7 +27,7 @@ acceptance("Personal Message", function (needs) {
|
||||
});
|
||||
|
||||
test("redirects to inbox after topic is archived and clears topicList cache", async function (assert) {
|
||||
const session = getOwnerWithFallback(this).lookup("service:session");
|
||||
const session = getOwner(this).lookup("service:session");
|
||||
setCachedTopicList(session, {});
|
||||
|
||||
await visit("/t/pm-for-testing/12");
|
||||
|
@ -116,7 +116,7 @@ export function updateCurrentUser(properties) {
|
||||
|
||||
// Note: do not use this in acceptance tests. Use `loggedIn: true` instead
|
||||
export function logIn() {
|
||||
User.resetCurrent(currentUser());
|
||||
return User.resetCurrent(currentUser());
|
||||
}
|
||||
|
||||
// Note: Only use if `loggedIn: true` has been used in an acceptance test
|
||||
|
@ -3,13 +3,13 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Integration | Component | pending-post", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("it renders", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
store.createRecord("category", { id: 2 });
|
||||
const post = store.createRecord("pending-post", {
|
||||
id: 1,
|
||||
|
@ -6,7 +6,7 @@ import { action } from "@ember/object";
|
||||
import { extraConnectorClass } from "discourse/lib/plugin-connectors";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import Component from "@glimmer/component";
|
||||
import templateOnly from "@ember/component/template-only";
|
||||
import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated";
|
||||
@ -256,9 +256,7 @@ module("Integration | Component | plugin-outlet", function (hooks) {
|
||||
"doesn't render conditional outlet"
|
||||
);
|
||||
|
||||
getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
).always_display = true;
|
||||
getOwner(this).lookup("service:site-settings").always_display = true;
|
||||
await settled();
|
||||
assert.true(exists(".conditional-render"), "renders conditional outlet");
|
||||
});
|
||||
|
@ -4,7 +4,7 @@ import { render } from "@ember/test-helpers";
|
||||
import I18n from "I18n";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module(
|
||||
"Integration | Component | select-kit/category-chooser",
|
||||
@ -267,7 +267,7 @@ module(
|
||||
});
|
||||
|
||||
test("filter works with non english characters", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
store.createRecord("category", {
|
||||
id: 1,
|
||||
name: "chữ Quốc ngữ",
|
||||
@ -287,7 +287,7 @@ module(
|
||||
});
|
||||
|
||||
test("decodes entities in row title", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
store.createRecord("category", {
|
||||
id: 1,
|
||||
name: "cat-with-entities",
|
||||
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
@ -12,7 +12,7 @@ module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
||||
this.siteSettings.automatically_unpin_topics = false;
|
||||
this.set("subject", selectKit());
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set(
|
||||
"topic",
|
||||
store.createRecord("topic", {
|
||||
@ -38,7 +38,7 @@ module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
||||
test("pinning", async function (assert) {
|
||||
this.siteSettings.automatically_unpin_topics = false;
|
||||
this.set("subject", selectKit());
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set(
|
||||
"topic",
|
||||
store.createRecord("topic", {
|
||||
|
@ -5,7 +5,7 @@ import I18n from "I18n";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
function buildTopic(opts) {
|
||||
return this.store.createRecord("topic", {
|
||||
@ -30,7 +30,7 @@ module(
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
|
@ -4,7 +4,7 @@ import { render } from "@ember/test-helpers";
|
||||
import I18n from "I18n";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
function extractDescriptions(rows) {
|
||||
return [...rows].map((el) => el.querySelector(".desc").textContent.trim());
|
||||
@ -22,7 +22,7 @@ module(
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("regular topic notification level descriptions", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set(
|
||||
"topic",
|
||||
store.createRecord("topic", {
|
||||
@ -63,7 +63,7 @@ module(
|
||||
});
|
||||
|
||||
test("PM topic notification level descriptions", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set(
|
||||
"topic",
|
||||
store.createRecord("topic", {
|
||||
|
@ -3,13 +3,13 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Integration | Component | topic-list-item", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("checkbox is rendered checked if topic is in selected array", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", { id: 24234 });
|
||||
const topic2 = store.createRecord("topic", { id: 24235 });
|
||||
this.setProperties({
|
||||
|
@ -2,13 +2,13 @@ import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { click, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Integration | Component | topic-list", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("bulk select", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.setProperties({
|
||||
topics: [
|
||||
store.createRecord("topic", { id: 24234 }),
|
||||
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { count } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
function postStreamTest(name, attrs) {
|
||||
test(name, async function (assert) {
|
||||
@ -22,8 +22,8 @@ module("Integration | Component | Widget | post-stream", function (hooks) {
|
||||
|
||||
postStreamTest("basics", {
|
||||
posts() {
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic");
|
||||
topic.set("details.created_by", { id: 123 });
|
||||
|
||||
@ -129,7 +129,7 @@ module("Integration | Component | Widget | post-stream", function (hooks) {
|
||||
|
||||
postStreamTest("deleted posts", {
|
||||
posts() {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic");
|
||||
topic.set("details.created_by", { id: 123 });
|
||||
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import EmberObject from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Integration | Component | Widget | post", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
@ -162,7 +162,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
||||
});
|
||||
|
||||
test("like count button", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", { id: 123 });
|
||||
const post = store.createRecord("post", {
|
||||
id: 1,
|
||||
@ -517,7 +517,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
||||
});
|
||||
|
||||
test("expand first post", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set("args", { expandablePost: true });
|
||||
this.set("post", store.createRecord("post", { id: 1234 }));
|
||||
|
||||
@ -961,7 +961,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
||||
emoji: "tooth",
|
||||
description: "off to dentist",
|
||||
};
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { status });
|
||||
this.set("args", { user });
|
||||
|
||||
@ -976,7 +976,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
||||
emoji: "tooth",
|
||||
description: "off to dentist",
|
||||
};
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { status });
|
||||
this.set("args", { user });
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { render } from "@ember/test-helpers";
|
||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import Category from "discourse/models/category";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
const createArgs = (topic) => {
|
||||
return {
|
||||
@ -37,7 +37,7 @@ module(
|
||||
id: 123,
|
||||
});
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", {
|
||||
user_id: this.currentUser.id,
|
||||
});
|
||||
@ -60,7 +60,7 @@ module(
|
||||
id: 123,
|
||||
});
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", {
|
||||
user_id: this.currentUser.id,
|
||||
});
|
||||
|
@ -4,13 +4,13 @@ import { click, render } from "@ember/test-helpers";
|
||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Integration | Component | Widget | topic-status", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("basics", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set("args", {
|
||||
topic: store.createRecord("topic", { closed: true }),
|
||||
disableActions: true,
|
||||
@ -24,7 +24,7 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
|
||||
});
|
||||
|
||||
test("extendability", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
TopicStatusIcons.addObject([
|
||||
"has_accepted_answer",
|
||||
"far-check-square",
|
||||
@ -45,7 +45,7 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
|
||||
});
|
||||
|
||||
test("toggling pin status", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.set("args", {
|
||||
topic: store.createRecord("topic", { closed: true, pinned: true }),
|
||||
});
|
||||
|
@ -13,10 +13,8 @@ import pretender, {
|
||||
resetPretender,
|
||||
} from "discourse/tests/helpers/create-pretender";
|
||||
import { resetSettings } from "discourse/tests/helpers/site-settings";
|
||||
import {
|
||||
getOwnerWithFallback,
|
||||
setDefaultOwner,
|
||||
} from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
||||
import {
|
||||
getSettledState,
|
||||
isSettled,
|
||||
@ -343,7 +341,7 @@ export default function setupTests(config) {
|
||||
});
|
||||
|
||||
QUnit.testDone(function () {
|
||||
testCleanup(getOwnerWithFallback(app), app);
|
||||
testCleanup(getOwner(app), app);
|
||||
|
||||
sinon.restore();
|
||||
resetPretender();
|
||||
|
@ -1,17 +1,15 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("reorder set unique position number", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup(
|
||||
"controller:reorder-categories"
|
||||
);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("categories", [
|
||||
store.createRecord("category", { id: 1, position: 0 }),
|
||||
store.createRecord("category", { id: 2, position: 0 }),
|
||||
@ -26,10 +24,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
});
|
||||
|
||||
test("reorder places subcategories after their parent categories, while maintaining the relative order", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup(
|
||||
"controller:reorder-categories"
|
||||
);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const parent = store.createRecord("category", {
|
||||
id: 1,
|
||||
@ -55,7 +51,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
});
|
||||
|
||||
const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("categories", [child2, parent, other, child1]);
|
||||
|
||||
controller.reorder();
|
||||
@ -67,10 +63,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
});
|
||||
|
||||
test("changing the position number of a category should place it at given position", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup(
|
||||
"controller:reorder-categories"
|
||||
);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const elem1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
@ -90,7 +84,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
slug: "test",
|
||||
});
|
||||
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("categories", [elem1, elem2, elem3]);
|
||||
|
||||
// Move category 'foo' from position 0 to position 2
|
||||
@ -104,10 +98,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
});
|
||||
|
||||
test("changing the position number of a category should place it at given position and respect children", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup(
|
||||
"controller:reorder-categories"
|
||||
);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const elem1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
@ -134,7 +126,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
slug: "test",
|
||||
});
|
||||
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("categories", [elem1, child1, elem2, elem3]);
|
||||
|
||||
controller.send("change", elem1, { target: { value: 3 } });
|
||||
@ -148,10 +140,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
});
|
||||
|
||||
test("changing the position through click on arrow of a category should place it at given position and respect children", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup(
|
||||
"controller:reorder-categories"
|
||||
);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const child2 = store.createRecord("category", {
|
||||
id: 105,
|
||||
@ -187,7 +177,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
||||
slug: "test",
|
||||
});
|
||||
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("categories", [elem1, child1, child2, elem2, elem3]);
|
||||
|
||||
controller.reorder();
|
||||
|
@ -5,7 +5,7 @@ import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import EmberObject from "@ember/object";
|
||||
import { Placeholder } from "discourse/lib/posts-with-placeholders";
|
||||
import { next } from "@ember/runloop";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import sinon from "sinon";
|
||||
|
||||
function topicWithStream(streamDetails) {
|
||||
@ -18,11 +18,11 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
test("editTopic", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
const model = this.store.createRecord("topic");
|
||||
controller.setProperties({ model });
|
||||
assert.notOk(controller.editingTopic, "we are not editing by default");
|
||||
@ -59,12 +59,10 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
let modalDisplayed = false;
|
||||
model.destroy = async () => (destroyed = true);
|
||||
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
siteSettings.min_topic_views_for_delete_confirm = 5;
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({
|
||||
model,
|
||||
deleteTopicModal: () => (modalDisplayed = true),
|
||||
@ -103,7 +101,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
|
||||
test("toggleMultiSelect", async function (assert) {
|
||||
const model = this.store.createRecord("topic");
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
assert.notOk(
|
||||
@ -148,7 +146,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
const model = topicWithStream.call(this, {
|
||||
posts: [{ id: 1 }, { id: 2 }, { id: 3 }],
|
||||
});
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
controller.set("selectedPostIds", [1, 2, 42]);
|
||||
@ -166,7 +164,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
|
||||
test("selectedAllPosts", function (assert) {
|
||||
const model = topicWithStream.call(this, { stream: [1, 2, 3] });
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
controller.set("selectedPostIds", [1, 2]);
|
||||
@ -200,7 +198,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
],
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
assert.strictEqual(
|
||||
@ -240,12 +238,12 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
|
||||
test("showSelectedPostsAtBottom", function (assert) {
|
||||
const model = this.store.createRecord("topic", { posts_count: 3 });
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
assert.notOk(controller.showSelectedPostsAtBottom, "false on desktop");
|
||||
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("mobileView", true);
|
||||
|
||||
assert.notOk(
|
||||
@ -271,7 +269,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({
|
||||
model,
|
||||
currentUser,
|
||||
@ -318,7 +316,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
});
|
||||
model.set("details.can_move_posts", false);
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
assert.notOk(
|
||||
@ -364,7 +362,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
});
|
||||
model.set("currentUser", currentUser);
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model, currentUser });
|
||||
|
||||
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
|
||||
@ -396,12 +394,10 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
});
|
||||
model.set("currentUser", currentUser);
|
||||
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
siteSettings.moderators_change_post_ownership = true;
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model, currentUser });
|
||||
|
||||
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
|
||||
@ -433,7 +429,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
assert.notOk(controller.canMergePosts, "false when no posts are selected");
|
||||
@ -464,7 +460,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
});
|
||||
|
||||
test("Select/deselect all", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
const model = topicWithStream.call(this, { stream: [1, 2, 3] });
|
||||
controller.setProperties({ model });
|
||||
|
||||
@ -490,7 +486,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
});
|
||||
|
||||
test("togglePostSelection", function (assert) {
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
|
||||
assert.strictEqual(
|
||||
controller.selectedPostIds[0],
|
||||
@ -514,7 +510,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
});
|
||||
|
||||
test("selectBelow", function (assert) {
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("post_types", { small_action: 3, whisper: 4 });
|
||||
|
||||
const model = topicWithStream.call(this, {
|
||||
@ -526,7 +522,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
],
|
||||
});
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
assert.deepEqual(
|
||||
@ -548,7 +544,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
posts: [{ id: 1 }, { id: 2 }],
|
||||
});
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
|
||||
controller.send("selectReplies", { id: 1 });
|
||||
@ -586,7 +582,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
const model = topicWithStream.call(this, {
|
||||
posts: [{ id: 1 }],
|
||||
});
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model });
|
||||
const placeholder = new Placeholder("post-placeholder");
|
||||
|
||||
@ -617,7 +613,7 @@ module("Unit | Controller | topic", function (hooks) {
|
||||
posts: [post, { id: 3 }, { id: 4 }],
|
||||
});
|
||||
|
||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
||||
const controller = getOwner(this).lookup("controller:topic");
|
||||
controller.setProperties({ model, currentUser });
|
||||
|
||||
const done = assert.async();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { buildQuote } from "discourse/lib/quote";
|
||||
import PrettyText from "pretty-text/pretty-text";
|
||||
|
||||
@ -8,7 +8,7 @@ module("Unit | Utility | build-quote", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("quotes", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", {
|
||||
cooked: "<p><b>lorem</b> ipsum</p>",
|
||||
username: "eviltrout",
|
||||
@ -58,7 +58,7 @@ module("Unit | Utility | build-quote", function (hooks) {
|
||||
});
|
||||
|
||||
test("quoting a quote", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", {
|
||||
cooked: new PrettyText().cook(
|
||||
'[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]\n*Test*'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { module, test } from "qunit";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { helperContext } from "discourse-common/lib/helpers";
|
||||
|
||||
@ -12,7 +12,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("Regular categoryBadge", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const category = store.createRecord("category", {
|
||||
name: "hello",
|
||||
id: 123,
|
||||
@ -43,7 +43,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("undefined color", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const noColor = store.createRecord("category", { name: "hello", id: 123 });
|
||||
const tag = $.parseHTML(categoryBadgeHTML(noColor))[0];
|
||||
|
||||
@ -54,7 +54,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("topic count", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const category = store.createRecord("category", { name: "hello", id: 123 });
|
||||
|
||||
assert.ok(
|
||||
@ -69,7 +69,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("allowUncategorized", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const uncategorized = store.createRecord("category", {
|
||||
name: "uncategorized",
|
||||
id: 345,
|
||||
@ -89,12 +89,10 @@ module("Unit | Utility | category-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("category names are wrapped in dir-spans", function (assert) {
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
siteSettings.support_mixed_text_direction = true;
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const rtlCategory = store.createRecord("category", {
|
||||
name: "תכנות עם Ruby",
|
||||
id: 123,
|
||||
@ -118,10 +116,8 @@ module("Unit | Utility | category-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("recursive", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
|
||||
const foo = store.createRecord("category", {
|
||||
name: "foo",
|
||||
|
@ -13,7 +13,7 @@ import { setPrefix } from "discourse-common/lib/get-url";
|
||||
import sinon from "sinon";
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Utility | computed", function (hooks) {
|
||||
setupTest(hooks);
|
||||
@ -29,9 +29,7 @@ module("Unit | Utility | computed", function (hooks) {
|
||||
});
|
||||
|
||||
test("setting", function (assert) {
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
|
||||
let t = EmberObject.extend({
|
||||
siteSettings,
|
||||
|
@ -3,15 +3,13 @@ import { emojiUnescape } from "discourse/lib/text";
|
||||
import { module, test } from "qunit";
|
||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Utility | emoji", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("emojiUnescape", function (assert) {
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
|
||||
const testUnescape = (input, expected, description, settings = {}) => {
|
||||
const originalSettings = {};
|
||||
|
@ -12,7 +12,7 @@ import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { module, test } from "qunit";
|
||||
import domFromString from "discourse-common/lib/dom-from-string";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
function formatMins(mins, opts = {}) {
|
||||
const dt = new Date(new Date() - mins * 60 * 1000);
|
||||
@ -150,9 +150,7 @@ module("Unit | Utility | formatter", function (hooks) {
|
||||
});
|
||||
|
||||
test("formatting tiny dates", function (assert) {
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
|
||||
const shortDateYear = shortDateTester("MMM 'YY");
|
||||
siteSettings.relative_date_duration = 14;
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import LinkLookup from "discourse/lib/link-lookup";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Utility | link-lookup", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.post = store.createRecord("post");
|
||||
this.linkLookup = new LinkLookup({
|
||||
"en.wikipedia.org/wiki/handheld_game_console": {
|
||||
|
@ -3,7 +3,7 @@ import EmberObject from "@ember/object";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Utility | plugin-api", function (hooks) {
|
||||
setupTest(hooks);
|
||||
@ -16,7 +16,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
getOwnerWithFallback(this).register("test-thingy:main", TestThingy);
|
||||
getOwner(this).register("test-thingy:main", TestThingy);
|
||||
|
||||
withPluginApi("1.1.0", (api) => {
|
||||
api.modifyClass("test-thingy:main", {
|
||||
@ -29,7 +29,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
const thingy = getOwnerWithFallback(this).lookup("test-thingy:main");
|
||||
const thingy = getOwner(this).lookup("test-thingy:main");
|
||||
assert.strictEqual(thingy.prop, "hello there");
|
||||
});
|
||||
|
||||
@ -41,10 +41,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
}
|
||||
}
|
||||
|
||||
getOwnerWithFallback(this).register(
|
||||
"native-test-thingy:main",
|
||||
NativeTestThingy
|
||||
);
|
||||
getOwner(this).register("native-test-thingy:main", NativeTestThingy);
|
||||
|
||||
withPluginApi("1.1.0", (api) => {
|
||||
api.modifyClass("native-test-thingy:main", {
|
||||
@ -57,7 +54,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
const thingy = getOwnerWithFallback(this).lookup("native-test-thingy:main");
|
||||
const thingy = getOwner(this).lookup("native-test-thingy:main");
|
||||
assert.strictEqual(thingy.prop, "howdy partner");
|
||||
});
|
||||
|
||||
@ -72,13 +69,9 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
}
|
||||
}
|
||||
|
||||
getOwnerWithFallback(this).register(
|
||||
"class-test-thingy:main",
|
||||
new ClassTestThingy(),
|
||||
{
|
||||
getOwner(this).register("class-test-thingy:main", new ClassTestThingy(), {
|
||||
instantiate: false,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
withPluginApi("1.1.0", (api) => {
|
||||
api.modifyClass("class-test-thingy:main", {
|
||||
@ -90,7 +83,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
const thingy = getOwnerWithFallback(this).lookup("class-test-thingy:main");
|
||||
const thingy = getOwner(this).lookup("class-test-thingy:main");
|
||||
assert.strictEqual(thingy.keep, "hey!");
|
||||
assert.strictEqual(thingy.prop, "g'day");
|
||||
});
|
||||
@ -102,7 +95,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
getOwnerWithFallback(this).register("test-class:main", Base, {
|
||||
getOwner(this).register("test-class:main", Base, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
|
@ -12,16 +12,14 @@ import I18n from "I18n";
|
||||
import sinon from "sinon";
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Utility | uploads", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
test("validateUploadedFiles", function (assert) {
|
||||
@ -349,9 +347,7 @@ module("Unit | Utility | uploads", function (hooks) {
|
||||
""
|
||||
);
|
||||
|
||||
const capabilities = getOwnerWithFallback(this).lookup(
|
||||
"service:capabilities"
|
||||
);
|
||||
const capabilities = getOwner(this).lookup("service:capabilities");
|
||||
sinon.stub(capabilities, "isIOS").get(() => true);
|
||||
assert.strictEqual(
|
||||
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
||||
|
@ -23,7 +23,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { click, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Utilities", function (hooks) {
|
||||
setupTest(hooks);
|
||||
@ -88,9 +88,7 @@ module("Unit | Utilities", function (hooks) {
|
||||
meta.content = "hot";
|
||||
document.body.appendChild(meta);
|
||||
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
initializeDefaultHomepage(siteSettings);
|
||||
|
||||
assert.strictEqual(
|
||||
@ -102,9 +100,7 @@ module("Unit | Utilities", function (hooks) {
|
||||
});
|
||||
|
||||
test("defaultHomepage via site settings", function (assert) {
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
siteSettings.top_menu = "top|latest|hot";
|
||||
initializeDefaultHomepage(siteSettings);
|
||||
|
||||
@ -116,9 +112,7 @@ module("Unit | Utilities", function (hooks) {
|
||||
});
|
||||
|
||||
test("setDefaultHomepage", function (assert) {
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
initializeDefaultHomepage(siteSettings);
|
||||
|
||||
assert.strictEqual(defaultHomepage(), "latest");
|
||||
|
@ -5,13 +5,13 @@ import pretender, {
|
||||
} from "discourse/tests/helpers/create-pretender";
|
||||
import Badge from "discourse/models/badge";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | badge", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("newBadge", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const badge1 = store.createRecord("badge", { name: "New Badge" });
|
||||
const badge2 = store.createRecord("badge", { id: 1, name: "Old Badge" });
|
||||
|
||||
@ -50,7 +50,7 @@ module("Unit | Model | badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("updateFromJson", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const badge = store.createRecord("badge", { name: "Badge 1" });
|
||||
badge.updateFromJson({
|
||||
badge_types: [{ id: 6, name: "Silver 1" }],
|
||||
@ -66,7 +66,7 @@ module("Unit | Model | badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("save", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const badge = store.createRecord("badge", {
|
||||
id: 1999,
|
||||
name: "New Badge",
|
||||
@ -89,7 +89,7 @@ module("Unit | Model | badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("destroy", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const badge = store.createRecord("badge", {
|
||||
name: "New Badge",
|
||||
description: "This is a new badge.",
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | bookmark", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("topicForList - Topic bookmarkable", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const bookmark = store.createRecord("bookmark", {
|
||||
id: 1,
|
||||
bookmarkable_type: "Topic",
|
||||
@ -26,7 +26,7 @@ module("Unit | Model | bookmark", function (hooks) {
|
||||
});
|
||||
|
||||
test("topicForList - Post bookmarkable", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const bookmark = store.createRecord("bookmark", {
|
||||
id: 1,
|
||||
bookmarkable_type: "Post",
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { module, test } from "qunit";
|
||||
import Category from "discourse/models/category";
|
||||
import sinon from "sinon";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | category", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("slugFor", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const slugFor = function (cat, val, text) {
|
||||
assert.strictEqual(Category.slugFor(cat), val, text);
|
||||
@ -69,7 +69,7 @@ module("Unit | Model | category", function (hooks) {
|
||||
});
|
||||
|
||||
test("findBySlug", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const darth = store.createRecord("category", { id: 1, slug: "darth" }),
|
||||
luke = store.createRecord("category", {
|
||||
id: 2,
|
||||
@ -132,7 +132,7 @@ module("Unit | Model | category", function (hooks) {
|
||||
});
|
||||
|
||||
test("findSingleBySlug", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const darth = store.createRecord("category", { id: 1, slug: "darth" }),
|
||||
luke = store.createRecord("category", {
|
||||
id: 2,
|
||||
@ -195,7 +195,7 @@ module("Unit | Model | category", function (hooks) {
|
||||
});
|
||||
|
||||
test("findBySlugPathWithID", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
||||
const bar = store.createRecord("category", {
|
||||
@ -219,7 +219,7 @@ module("Unit | Model | category", function (hooks) {
|
||||
});
|
||||
|
||||
test("minimumRequiredTags", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const foo = store.createRecord("category", {
|
||||
id: 1,
|
||||
@ -283,7 +283,7 @@ module("Unit | Model | category", function (hooks) {
|
||||
});
|
||||
|
||||
test("search with category name", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const category1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
name: "middle term",
|
||||
@ -389,7 +389,7 @@ module("Unit | Model | category", function (hooks) {
|
||||
});
|
||||
|
||||
test("search with category slug", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const category1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
name: "middle term",
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
import { currentUser } from "discourse/tests/helpers/qunit-helpers";
|
||||
import AppEvents from "discourse/services/app-events";
|
||||
import { module, test } from "qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import pretender, {
|
||||
parsePostData,
|
||||
@ -17,7 +17,7 @@ import pretender, {
|
||||
function createComposer(opts = {}) {
|
||||
opts.user ??= currentUser();
|
||||
opts.appEvents = AppEvents.create();
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
return store.createRecord("composer", opts);
|
||||
}
|
||||
|
||||
@ -31,13 +31,11 @@ module("Unit | Model | composer", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
});
|
||||
|
||||
test("replyLength", function (assert) {
|
||||
const replyLength = function (val, expectedLength) {
|
||||
const replyLength = (val, expectedLength) => {
|
||||
const composer = createComposer.call(this, { reply: val });
|
||||
assert.strictEqual(composer.replyLength, expectedLength);
|
||||
};
|
||||
@ -73,7 +71,13 @@ module("Unit | Model | composer", function (hooks) {
|
||||
test("missingReplyCharacters", function (assert) {
|
||||
this.siteSettings.min_first_post_length = 40;
|
||||
|
||||
function missingReplyCharacters(val, isPM, isFirstPost, expected, message) {
|
||||
const missingReplyCharacters = (
|
||||
val,
|
||||
isPM,
|
||||
isFirstPost,
|
||||
expected,
|
||||
message
|
||||
) => {
|
||||
let action;
|
||||
|
||||
if (isFirstPost) {
|
||||
@ -86,7 +90,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
|
||||
const composer = createComposer.call(this, { reply: val, action });
|
||||
assert.strictEqual(composer.missingReplyCharacters, expected, message);
|
||||
}
|
||||
};
|
||||
|
||||
missingReplyCharacters(
|
||||
"hi",
|
||||
@ -129,7 +133,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("missingTitleCharacters", function (assert) {
|
||||
const missingTitleCharacters = function (val, isPM, expected, message) {
|
||||
const missingTitleCharacters = (val, isPM, expected, message) => {
|
||||
const composer = createComposer.call(this, {
|
||||
title: val,
|
||||
action: isPM ? PRIVATE_MESSAGE : REPLY,
|
||||
@ -152,7 +156,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("replyDirty", function (assert) {
|
||||
const composer = createComposer();
|
||||
const composer = createComposer.call(this);
|
||||
assert.ok(!composer.replyDirty, "by default it's false");
|
||||
|
||||
composer.setProperties({
|
||||
@ -169,7 +173,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("appendText", function (assert) {
|
||||
const composer = createComposer();
|
||||
const composer = createComposer.call(this);
|
||||
|
||||
assert.blank(composer.reply, "the reply is blank by default");
|
||||
|
||||
@ -202,7 +206,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("prependText", function (assert) {
|
||||
const composer = createComposer();
|
||||
const composer = createComposer.call(this);
|
||||
|
||||
assert.blank(composer.reply, "the reply is blank by default");
|
||||
|
||||
@ -227,7 +231,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
test("Title length for regular topics", function (assert) {
|
||||
this.siteSettings.min_topic_title_length = 5;
|
||||
this.siteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer();
|
||||
const composer = createComposer.call(this);
|
||||
|
||||
composer.set("title", "asdf");
|
||||
assert.ok(!composer.titleLengthValid, "short titles are not valid");
|
||||
@ -255,7 +259,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("Post length for private messages with non human users", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", { pm_with_non_human_user: true });
|
||||
const composer = createComposer.call(this, {
|
||||
topic,
|
||||
@ -265,10 +269,10 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("editingFirstPost", function (assert) {
|
||||
const composer = createComposer();
|
||||
const composer = createComposer.call(this);
|
||||
assert.ok(!composer.editingFirstPost, "it's false by default");
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", { id: 123, post_number: 2 });
|
||||
composer.setProperties({ post, action: EDIT });
|
||||
assert.ok(
|
||||
@ -284,7 +288,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
});
|
||||
|
||||
test("clearState", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const composer = createComposer.call(this, {
|
||||
originalText: "asdf",
|
||||
reply: "asdf2",
|
||||
@ -340,7 +344,7 @@ module("Unit | Model | composer", function (hooks) {
|
||||
test("open with a quote", function (assert) {
|
||||
const quote =
|
||||
'[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]';
|
||||
const newComposer = function () {
|
||||
const newComposer = () => {
|
||||
return openComposer.call(this, {
|
||||
action: REPLY,
|
||||
draftKey: "abcd",
|
||||
@ -364,9 +368,9 @@ module("Unit | Model | composer", function (hooks) {
|
||||
test("Title length for static page topics as admin", function (assert) {
|
||||
this.siteSettings.min_topic_title_length = 5;
|
||||
this.siteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer();
|
||||
const composer = createComposer.call(this);
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", {
|
||||
id: 123,
|
||||
post_number: 2,
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setPrefix } from "discourse-common/lib/get-url";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | email-log", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("create", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
assert.ok(
|
||||
store.createRecord("email-log"),
|
||||
"it can be created without arguments"
|
||||
@ -32,7 +32,7 @@ module("Unit | Model | email-log", function (hooks) {
|
||||
"/forum/letter_avatar_proxy/v2/letter/w/dfb087/{size}.png",
|
||||
},
|
||||
};
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const emailLog = store.createRecord("email-log", attrs);
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | group", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("displayName", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const group = store.createRecord("group", {
|
||||
name: "test",
|
||||
display_name: "donkey",
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | invite", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("create", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
assert.ok(
|
||||
store.createRecord("invite"),
|
||||
"it can be created without arguments"
|
||||
|
@ -1,19 +1,19 @@
|
||||
import { module, test } from "qunit";
|
||||
import Category from "discourse/models/category";
|
||||
import NavItem from "discourse/models/nav-item";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | nav-item", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const fooCategory = store.createRecord("category", {
|
||||
slug: "foo",
|
||||
id: 123,
|
||||
});
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.categories.addObject(fooCategory);
|
||||
});
|
||||
|
||||
@ -34,7 +34,7 @@ module("Unit | Model | nav-item", function (hooks) {
|
||||
});
|
||||
|
||||
test("count", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const navItem = store.createRecord("nav-item", { name: "new" });
|
||||
|
||||
assert.strictEqual(navItem.count, 0, "it has no count by default");
|
||||
@ -54,7 +54,7 @@ module("Unit | Model | nav-item", function (hooks) {
|
||||
});
|
||||
|
||||
test("displayName", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const navItem = store.createRecord("nav-item", {
|
||||
name: "something",
|
||||
});
|
||||
@ -69,7 +69,7 @@ module("Unit | Model | nav-item", function (hooks) {
|
||||
});
|
||||
|
||||
test("title", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const navItem = store.createRecord("nav-item", {
|
||||
name: "something",
|
||||
});
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { settled } from "@ember/test-helpers";
|
||||
|
||||
module("Unit | Model | pending-post", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("Properties", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const category = store.createRecord("category", { id: 2 });
|
||||
const post = store.createRecord("pending-post", {
|
||||
id: 1,
|
||||
@ -38,7 +38,7 @@ module("Unit | Model | pending-post", function (hooks) {
|
||||
});
|
||||
|
||||
test("it cooks raw_text", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("pending-post", {
|
||||
raw_text: "**bold text**",
|
||||
});
|
||||
|
@ -4,11 +4,11 @@ import Post from "discourse/models/post";
|
||||
import User from "discourse/models/user";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import sinon from "sinon";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
function buildStream(id, stream) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", { id, chunk_size: 5 });
|
||||
|
||||
if (stream) {
|
||||
@ -24,7 +24,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("create", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
assert.ok(
|
||||
store.createRecord("postStream"),
|
||||
"it can be created with no parameters"
|
||||
@ -40,7 +40,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("appending posts", function (assert) {
|
||||
const postStream = buildStream.call(this, 4567, [1, 3, 4]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
assert.strictEqual(postStream.lastPostId, 4, "the last post id is 4");
|
||||
|
||||
@ -110,7 +110,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("closestPostNumberFor", function (assert) {
|
||||
const postStream = buildStream.call(this, 1231);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
assert.blank(
|
||||
postStream.closestPostNumberFor(1),
|
||||
@ -193,7 +193,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("removePosts", function (assert) {
|
||||
const postStream = buildStream.call(this, 10000001, [1, 2, 3]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const p1 = store.createRecord("post", { id: 1, post_number: 2 }),
|
||||
p2 = store.createRecord("post", { id: 2, post_number: 3 }),
|
||||
@ -532,7 +532,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("identity map", async function (assert) {
|
||||
const postStream = buildStream.call(this, 1234);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const p1 = postStream.appendPost(
|
||||
store.createRecord("post", { id: 1, post_number: 1 })
|
||||
@ -577,7 +577,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("appendMore for megatopic", async function (assert) {
|
||||
const postStream = buildStream.call(this, 1234);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", { id: 1, post_number: 1 });
|
||||
|
||||
postStream.setProperties({
|
||||
@ -600,7 +600,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("prependMore for megatopic", async function (assert) {
|
||||
const postStream = buildStream.call(this, 1234);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", { id: 6, post_number: 6 });
|
||||
|
||||
postStream.setProperties({
|
||||
@ -623,7 +623,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("staging and undoing a new post", function (assert) {
|
||||
const postStream = buildStream.call(this, 10101, [1]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const original = store.createRecord("post", {
|
||||
id: 1,
|
||||
@ -724,7 +724,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("staging and committing a post", function (assert) {
|
||||
const postStream = buildStream.call(this, 10101, [1]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const original = store.createRecord("post", {
|
||||
id: 1,
|
||||
@ -808,7 +808,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
// This can happen in a race condition between staging a post and it coming through on the
|
||||
// message bus. If the id of a post changes we should reconsider the loadedAllPosts property.
|
||||
const postStream = buildStream.call(this, 10101, [1, 2]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const postWithoutId = store.createRecord("post", {
|
||||
raw: "hello world this is my new post",
|
||||
});
|
||||
@ -828,7 +828,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("triggerRecoveredPost", async function (assert) {
|
||||
const postStream = buildStream.call(this, 4567);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
[1, 2, 3, 5].forEach((id) => {
|
||||
postStream.appendPost(
|
||||
@ -857,7 +857,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("committing and triggerNewPostsInStream race condition", function (assert) {
|
||||
const postStream = buildStream.call(this, 4964);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
postStream.appendPost(
|
||||
store.createRecord("post", { id: 1, post_number: 1 })
|
||||
@ -893,7 +893,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("triggerNewPostInStream for ignored posts", async function (assert) {
|
||||
const postStream = buildStream.call(this, 280, [1]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
User.resetCurrent(
|
||||
store.createRecord("user", {
|
||||
username: "eviltrout",
|
||||
@ -956,7 +956,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
);
|
||||
const postsWithPlaceholders = postStream.postsWithPlaceholders;
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const testProxy = ArrayProxy.create({ content: postsWithPlaceholders });
|
||||
|
||||
@ -1029,7 +1029,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
||||
|
||||
test("progressIndexOfPostId", function (assert) {
|
||||
const postStream = buildStream.call(this, 4567, [1, 3, 4]);
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const post = store.createRecord("post", { id: 1, post_number: 5 });
|
||||
|
||||
assert.strictEqual(postStream.progressIndexOfPostId(post), 1);
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | post", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
test("defaults", function (assert) {
|
||||
|
@ -4,7 +4,7 @@ import { publishToMessageBus } from "discourse/tests/helpers/qunit-helpers";
|
||||
import MessageBus from "message-bus-client";
|
||||
import PrivateMessageTopicTrackingState from "discourse/services/pm-topic-tracking-state";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
function setupPretender() {
|
||||
pretender.get(`/u/test/private-message-topic-tracking-state`, () => {
|
||||
@ -24,7 +24,7 @@ module("Unit | Model | private-message-topic-tracking-state", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("modifying state calls onStateChange callbacks", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||
messageBus: MessageBus,
|
||||
currentUser: store.createRecord("user", { id: 77889, username: "test" }),
|
||||
@ -50,7 +50,7 @@ module(
|
||||
|
||||
test("modifies the topic state only if the topic was not created by the current user", async function (assert) {
|
||||
setupPretender();
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||
messageBus: MessageBus,
|
||||
currentUser: store.createRecord("user", {
|
||||
@ -110,7 +110,7 @@ module(
|
||||
|
||||
test("modifies the last_read_post_number and highest_post_number", async function (assert) {
|
||||
setupPretender();
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||
messageBus: MessageBus,
|
||||
currentUser: store.createRecord("user", {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setPrefix } from "discourse-common/lib/get-url";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
function reportWithData(data) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
return store.createRecord("report", {
|
||||
type: "topics",
|
||||
@ -352,7 +352,7 @@ module("Unit | Model | report", function (hooks) {
|
||||
{ type: "bytes", property: "filesize", title: "Filesize" },
|
||||
];
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const report = store.createRecord("report", {
|
||||
type: "topics",
|
||||
labels,
|
||||
|
@ -2,14 +2,14 @@ import { module, test } from "qunit";
|
||||
import RestAdapter from "discourse/adapters/rest";
|
||||
import RestModel from "discourse/models/rest";
|
||||
import sinon from "sinon";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | rest-model", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("munging", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
class Grape extends RestModel {}
|
||||
Grape.reopenClass({
|
||||
munge: function (json) {
|
||||
@ -18,13 +18,13 @@ module("Unit | Model | rest-model", function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
getOwnerWithFallback(this).register("model:grape", Grape);
|
||||
getOwner(this).register("model:grape", Grape);
|
||||
const g = store.createRecord("grape", { store, percent: 0.4 });
|
||||
assert.strictEqual(g.inverse, 0.6, "it runs `munge` on `create`");
|
||||
});
|
||||
|
||||
test("update", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = await store.find("widget", 123);
|
||||
assert.strictEqual(widget.name, "Trout Lure");
|
||||
assert.ok(!widget.isSaving, "it is not saving");
|
||||
@ -45,7 +45,7 @@ module("Unit | Model | rest-model", function (hooks) {
|
||||
});
|
||||
|
||||
test("updating simultaneously", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = await store.find("widget", 123);
|
||||
|
||||
const firstPromise = widget.update({ name: "new name" });
|
||||
@ -58,7 +58,7 @@ module("Unit | Model | rest-model", function (hooks) {
|
||||
});
|
||||
|
||||
test("save new", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget");
|
||||
|
||||
assert.ok(widget.isNew, "it is a new record");
|
||||
@ -84,7 +84,7 @@ module("Unit | Model | rest-model", function (hooks) {
|
||||
});
|
||||
|
||||
test("creating simultaneously", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget");
|
||||
|
||||
const firstPromise = widget.save({ name: "Evil Widget" });
|
||||
@ -97,15 +97,15 @@ module("Unit | Model | rest-model", function (hooks) {
|
||||
});
|
||||
|
||||
test("destroyRecord", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = await store.find("widget", 123);
|
||||
|
||||
assert.ok(await widget.destroyRecord());
|
||||
});
|
||||
|
||||
test("custom api name", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
getOwnerWithFallback(this).register(
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
getOwner(this).register(
|
||||
"adapter:my-widget",
|
||||
class extends RestAdapter {
|
||||
// An adapter like this is used when the server-side key/url
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | result-set", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("defaults", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const resultSet = store.createRecord("result-set", { content: [] });
|
||||
assert.strictEqual(resultSet.length, 0);
|
||||
assert.strictEqual(resultSet.totalRows, 0);
|
||||
@ -17,7 +17,7 @@ module("Unit | Model | result-set", function (hooks) {
|
||||
});
|
||||
|
||||
test("pagination support", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const resultSet = await store.findAll("widget");
|
||||
assert.strictEqual(resultSet.length, 2);
|
||||
assert.strictEqual(resultSet.totalRows, 4);
|
||||
@ -36,7 +36,7 @@ module("Unit | Model | result-set", function (hooks) {
|
||||
});
|
||||
|
||||
test("refresh support", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const resultSet = await store.findAll("widget");
|
||||
assert.strictEqual(
|
||||
resultSet.refreshUrl,
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import Site from "discourse/models/site";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | site", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("create", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
assert.ok(store.createRecord("site"), "it can create with no parameters");
|
||||
});
|
||||
|
||||
@ -21,7 +21,7 @@ module("Unit | Model | site", function (hooks) {
|
||||
});
|
||||
|
||||
test("create categories", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const site = store.createRecord("site", {
|
||||
categories: [
|
||||
{ id: 3456, name: "Test Subcategory", parent_category_id: 1234 },
|
||||
@ -73,7 +73,7 @@ module("Unit | Model | site", function (hooks) {
|
||||
});
|
||||
|
||||
test("sortedCategories returns categories sorted by topic counts and sorts child categories after parent", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const site = store.createRecord("site", {
|
||||
categories: [
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | staff-action-log", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("create", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
assert.ok(
|
||||
store.createRecord("staff-action-log"),
|
||||
"it can be created without arguments"
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | tag", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
test("totalCount when pm_count is not present", function (assert) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | theme", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("can add an upload correctly", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const theme = store.createRecord("theme");
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import User from "discourse/models/user";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | topic-details", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("defaults", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", { id: 1234 });
|
||||
const details = topic.details;
|
||||
|
||||
@ -16,7 +16,7 @@ module("Unit | Model | topic-details", function (hooks) {
|
||||
});
|
||||
|
||||
test("updateFromJson", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const topic = store.createRecord("topic", { id: 1234 });
|
||||
const details = topic.details;
|
||||
|
||||
|
@ -2,14 +2,14 @@ import { module, test } from "qunit";
|
||||
import Category from "discourse/models/category";
|
||||
import Topic from "discourse/models/topic";
|
||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | topic", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
test("defaults", function (assert) {
|
||||
@ -204,9 +204,7 @@ module("Unit | Model | topic", function (hooks) {
|
||||
fancy_title: "This is a test",
|
||||
});
|
||||
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
siteSettings.support_mixed_text_direction = true;
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -11,7 +11,7 @@ import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||
import TopicTrackingState from "discourse/models/topic-tracking-state";
|
||||
import User from "discourse/models/user";
|
||||
import sinon from "sinon";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Unit | Model | topic-tracking-state", function (hooks) {
|
||||
@ -19,7 +19,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.clock = fakeTime("2012-12-31 12:00");
|
||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
||||
this.store = getOwner(this).lookup("service:store");
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
@ -672,7 +672,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
||||
});
|
||||
|
||||
test("getSubCategoryIds", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
||||
const bar = store.createRecord("category", {
|
||||
id: 2,
|
||||
@ -693,7 +693,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
||||
});
|
||||
|
||||
test("countNew", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const foo = store.createRecord("category", {
|
||||
id: 1,
|
||||
slug: "foo",
|
||||
@ -842,10 +842,8 @@ module("Unit | Model | topic-tracking-state | /unread", function (hooks) {
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
|
||||
this.currentUser = store.createRecord("user", {
|
||||
username: "chuck",
|
||||
@ -1097,10 +1095,8 @@ module("Unit | Model | topic-tracking-state | /new", function (hooks) {
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
|
||||
this.currentUser = store.createRecord("user", {
|
||||
username: "chuck",
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import UserAction from "discourse/models/user-action";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | user-action", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("collapsing likes", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const actions = UserAction.collapseStream([
|
||||
store.createRecord("user-action", {
|
||||
action_type: UserAction.TYPES.likes_given,
|
||||
|
@ -3,7 +3,7 @@ import UserBadge from "discourse/models/user-badge";
|
||||
import badgeFixtures from "discourse/tests/fixtures/user-badges";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | user-badge", function (hooks) {
|
||||
setupTest(hooks);
|
||||
@ -58,14 +58,14 @@ module("Unit | Model | user-badge", function (hooks) {
|
||||
});
|
||||
|
||||
test("revoke", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const userBadge = store.createRecord("user-badge", { id: 1 });
|
||||
const result = await userBadge.revoke();
|
||||
assert.deepEqual(result, { success: true });
|
||||
});
|
||||
|
||||
test("favorite", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const userBadge = store.createRecord("user-badge", { id: 1 });
|
||||
assert.notOk(userBadge.is_favorite);
|
||||
|
||||
|
@ -2,13 +2,13 @@ import { module, test } from "qunit";
|
||||
import I18n from "I18n";
|
||||
import { NEW_TOPIC_KEY } from "discourse/models/composer";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | user-draft", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("stream", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||
const stream = user.userDraftsStream;
|
||||
|
||||
@ -22,7 +22,7 @@ module("Unit | Model | user-draft", function (hooks) {
|
||||
});
|
||||
|
||||
test("draft", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const drafts = [
|
||||
store.createRecord("user-draft", {
|
||||
draft_key: "topic_1",
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { module, test } from "qunit";
|
||||
import UserAction from "discourse/models/user-action";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | user-stream", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("basics", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||
const stream = user.stream;
|
||||
assert.present(stream, "a user has a stream by default");
|
||||
@ -21,7 +21,7 @@ module("Unit | Model | user-stream", function (hooks) {
|
||||
});
|
||||
|
||||
test("filterParam", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||
const stream = user.stream;
|
||||
|
||||
|
@ -4,13 +4,13 @@ import PreloadStore from "discourse/lib/preload-store";
|
||||
import sinon from "sinon";
|
||||
import { settled } from "@ember/test-helpers";
|
||||
import User from "discourse/models/user";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Model | user", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("staff", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||
|
||||
assert.ok(!user.staff, "user is not staff");
|
||||
@ -23,7 +23,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("searchContext", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { id: 1, username: "EvilTrout" });
|
||||
|
||||
assert.deepEqual(
|
||||
@ -34,7 +34,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("isAllowedToUploadAFile", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { trust_level: 0, admin: true });
|
||||
assert.ok(
|
||||
user.isAllowedToUploadAFile("image"),
|
||||
@ -49,7 +49,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("canMangeGroup", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", { admin: true });
|
||||
const group = store.createRecord("group", { automatic: true });
|
||||
|
||||
@ -79,7 +79,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("muted ids", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", {
|
||||
username: "chuck",
|
||||
muted_category_ids: [],
|
||||
@ -118,7 +118,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("subsequent calls to trackStatus and stopTrackingStatus increase and decrease subscribers counter", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user");
|
||||
assert.strictEqual(user._subscribersCount, 0);
|
||||
|
||||
@ -136,7 +136,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("attempt to stop tracking status if status wasn't tracked doesn't throw", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user");
|
||||
user.stopTrackingStatus();
|
||||
assert.ok(true);
|
||||
@ -151,7 +151,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
description: "user2 status",
|
||||
emoji: "speech_balloon",
|
||||
};
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user1 = store.createRecord("user", {
|
||||
id: 1,
|
||||
status: status1,
|
||||
@ -179,7 +179,7 @@ module("Unit | Model | user", function (hooks) {
|
||||
});
|
||||
|
||||
test("create() doesn't set internal status tracking fields", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const user = store.createRecord("user", {
|
||||
_subscribersCount: 10,
|
||||
_clearStatusTimerId: 100,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { module, test } from "qunit";
|
||||
|
||||
@ -6,7 +6,7 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("basic state", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const field = store.createRecord("wizard-field", { type: "text" });
|
||||
assert.ok(field.unchecked);
|
||||
assert.ok(!field.valid);
|
||||
@ -14,7 +14,7 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("text - required - validation", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const field = store.createRecord("wizard-field", {
|
||||
type: "text",
|
||||
required: true,
|
||||
@ -34,7 +34,7 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("text - optional - validation", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const field = store.createRecord("wizard-field", { type: "text" });
|
||||
assert.ok(field.unchecked);
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { currentUser } from "discourse/tests/helpers/qunit-helpers";
|
||||
import Session from "discourse/models/session";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
module("Unit | Service | document-title", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
Session.current().hasFocus = true;
|
||||
this.documentTitle = getOwnerWithFallback(this).lookup(
|
||||
"service:document-title"
|
||||
);
|
||||
const session = getOwner(this).lookup("service:session");
|
||||
session.hasFocus = true;
|
||||
|
||||
this.documentTitle = getOwner(this).lookup("service:document-title");
|
||||
});
|
||||
|
||||
test("it updates the document title", function (assert) {
|
||||
@ -29,8 +28,13 @@ module("Unit | Service | document-title", function (hooks) {
|
||||
});
|
||||
|
||||
test("it displays notification counts for logged in users", function (assert) {
|
||||
this.documentTitle.currentUser = currentUser();
|
||||
this.documentTitle.currentUser.user_option.dynamic_favicon = false;
|
||||
const currentUser = logIn();
|
||||
this.owner.unregister("service:current-user");
|
||||
this.owner.register("service:current-user", currentUser, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
currentUser.user_option.dynamic_favicon = false;
|
||||
this.documentTitle.setTitle("test notifications");
|
||||
this.documentTitle.updateNotificationCount(5);
|
||||
assert.strictEqual(document.title, "test notifications");
|
||||
@ -42,13 +46,17 @@ module("Unit | Service | document-title", function (hooks) {
|
||||
});
|
||||
|
||||
test("it doesn't display notification counts for users in do not disturb", function (assert) {
|
||||
this.documentTitle.currentUser = currentUser();
|
||||
const currentUser = logIn();
|
||||
this.owner.unregister("service:current-user");
|
||||
this.owner.register("service:current-user", currentUser, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
const date = new Date();
|
||||
date.setHours(date.getHours() + 1);
|
||||
this.documentTitle.currentUser.do_not_disturb_until = date.toUTCString();
|
||||
currentUser.do_not_disturb_until = date.toUTCString();
|
||||
|
||||
this.documentTitle.currentUser.user_option.dynamic_favicon = false;
|
||||
currentUser.user_option.dynamic_favicon = false;
|
||||
this.documentTitle.setTitle("test notifications");
|
||||
this.documentTitle.updateNotificationCount(5);
|
||||
assert.strictEqual(document.title, "test notifications");
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
module("Unit | Service | emoji-store", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.emojiStore = getOwnerWithFallback(this).lookup("service:emoji-store");
|
||||
this.emojiStore = getOwner(this).lookup("service:emoji-store");
|
||||
this.emojiStore.reset();
|
||||
});
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { module, test } from "qunit";
|
||||
import { click } from "@ember/test-helpers";
|
||||
import { LIGHTBOX_APP_EVENT_NAMES } from "discourse/lib/lightbox/constants";
|
||||
import domFromString from "discourse-common/lib/dom-from-string";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import sinon from "sinon";
|
||||
|
||||
@ -17,8 +17,8 @@ module("Unit | Service | Experimental Lightbox", function (hooks) {
|
||||
const selector = ".lightbox";
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.lightbox = getOwnerWithFallback(this).lookup("service:lightbox");
|
||||
this.appEvents = getOwnerWithFallback(this).lookup("service:app-events");
|
||||
this.lightbox = getOwner(this).lookup("service:lightbox");
|
||||
this.appEvents = getOwner(this).lookup("service:app-events");
|
||||
});
|
||||
|
||||
test("Lightbox Service has appEvents", async function (assert) {
|
||||
|
@ -7,7 +7,7 @@ import { PresenceChannelNotFound } from "discourse/services/presence";
|
||||
import { setTestPresence } from "discourse/lib/user-presence";
|
||||
import sinon from "sinon";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
function usersFixture() {
|
||||
@ -63,7 +63,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
||||
});
|
||||
|
||||
test("subscribing and receiving updates", async function (assert) {
|
||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
||||
let presenceService = getOwner(this).lookup("service:presence");
|
||||
let channel = presenceService.getChannel("/test/ch1");
|
||||
let changes = 0;
|
||||
const countChanges = () => changes++;
|
||||
@ -106,7 +106,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
||||
});
|
||||
|
||||
test("fetches data when no initial state", async function (assert) {
|
||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
||||
let presenceService = getOwner(this).lookup("service:presence");
|
||||
let channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
await channel.subscribe();
|
||||
@ -152,7 +152,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
||||
});
|
||||
|
||||
test("raises error when subscribing to nonexistent channel", async function (assert) {
|
||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
||||
let presenceService = getOwner(this).lookup("service:presence");
|
||||
let channel = presenceService.getChannel("/nonexistent/ch1");
|
||||
|
||||
assert.rejects(
|
||||
@ -163,7 +163,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
||||
});
|
||||
|
||||
test("can subscribe to count_only channel", async function (assert) {
|
||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
||||
let presenceService = getOwner(this).lookup("service:presence");
|
||||
let channel = presenceService.getChannel("/count-only/ch1");
|
||||
|
||||
await channel.subscribe();
|
||||
@ -200,7 +200,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
||||
});
|
||||
|
||||
test("can share data between multiple PresenceChannel objects", async function (assert) {
|
||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
||||
let presenceService = getOwner(this).lookup("service:presence");
|
||||
let channel = presenceService.getChannel("/test/ch1");
|
||||
let channelDup = presenceService.getChannel("/test/ch1");
|
||||
|
||||
@ -285,8 +285,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("can join and leave channels", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
@ -313,8 +312,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("join should be a no-op if already present", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
@ -330,8 +328,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("leave should be a no-op if not present", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
@ -355,8 +352,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
(resolve) => (resolveServerResponse = resolve)
|
||||
);
|
||||
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
@ -381,8 +377,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("raises an error when entering a non-existent channel", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/blah/does-not-exist");
|
||||
await assert.rejects(
|
||||
@ -393,8 +388,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("deduplicates calls from multiple PresenceChannel instances", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
const channelDup = presenceService.getChannel("/test/ch1");
|
||||
@ -433,8 +427,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("updates the server presence after going idle", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
@ -471,8 +464,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
});
|
||||
|
||||
test("handles the onlyWhileActive flag", async function (assert) {
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
await channel.enter();
|
||||
@ -531,8 +523,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
||||
return response(429, { extras: { wait_seconds: 2 } });
|
||||
});
|
||||
|
||||
const presenceService =
|
||||
getOwnerWithFallback(this).lookup("service:presence");
|
||||
const presenceService = getOwner(this).lookup("service:presence");
|
||||
presenceService.currentUser = currentUser();
|
||||
const channel = presenceService.getChannel("/test/ch1");
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { inject as service } from "@ember/service";
|
||||
import EmberObject, { computed } from "@ember/object";
|
||||
|
||||
@ -17,9 +17,7 @@ module("Unit | Service | site-settings", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.siteSettings = getOwnerWithFallback(this).lookup(
|
||||
"service:site-settings"
|
||||
);
|
||||
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
});
|
||||
|
||||
test("contains settings", function (assert) {
|
||||
@ -29,8 +27,8 @@ module("Unit | Service | site-settings", function (hooks) {
|
||||
test("notifies getters", function (assert) {
|
||||
this.siteSettings.title = "original";
|
||||
|
||||
getOwnerWithFallback(this).register("test-class:main", TestClass);
|
||||
const object = getOwnerWithFallback(this).lookup("test-class:main");
|
||||
getOwner(this).register("test-class:main", TestClass);
|
||||
const object = getOwner(this).lookup("test-class:main");
|
||||
assert.strictEqual(object.text, "The title: original");
|
||||
|
||||
this.siteSettings.title = "updated";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import pretender, {
|
||||
fixturesByUrl,
|
||||
response,
|
||||
@ -10,7 +10,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("createRecord", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget", { id: 111, name: "hello" });
|
||||
|
||||
assert.false(widget.isNew, "it is not a new record");
|
||||
@ -19,7 +19,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("createRecord without an `id`", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget", { name: "hello" });
|
||||
|
||||
assert.true(widget.isNew, "it is a new record");
|
||||
@ -27,7 +27,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("createRecord doesn't modify the input `id` field", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget", { id: 1, name: "hello" });
|
||||
|
||||
const obj = { id: 1, name: "something" };
|
||||
@ -39,7 +39,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("createRecord without attributes", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget");
|
||||
|
||||
assert.strictEqual(widget.id, undefined, "there is no id");
|
||||
@ -47,7 +47,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("createRecord with a record as attributes returns that record from the map", function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget", { id: 33 });
|
||||
const secondWidget = store.createRecord("widget", { id: 33 });
|
||||
|
||||
@ -55,7 +55,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("find", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
|
||||
const widget = await store.find("widget", 123);
|
||||
assert.strictEqual(widget.name, "Trout Lure");
|
||||
@ -78,19 +78,19 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("find with object id", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = await store.find("widget", { id: 123 });
|
||||
assert.strictEqual(widget.firstObject.name, "Trout Lure");
|
||||
});
|
||||
|
||||
test("find with query param", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = await store.find("widget", { name: "Trout Lure" });
|
||||
assert.strictEqual(widget.firstObject.id, 123);
|
||||
});
|
||||
|
||||
test("findStale with no stale results", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const stale = store.findStale("widget", { name: "Trout Lure" });
|
||||
|
||||
assert.false(stale.hasResults, "there are no stale results");
|
||||
@ -118,7 +118,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
}
|
||||
});
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const notifications = await store.find("notification", { slug: "souna" });
|
||||
assert.strictEqual(notifications.content[0].slug, "souna");
|
||||
|
||||
@ -131,19 +131,19 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("update", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const result = await store.update("widget", 123, { name: "hello" });
|
||||
assert.strictEqual(result.payload.name, "hello");
|
||||
});
|
||||
|
||||
test("update with a multi world name", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const result = await store.update("cool-thing", 123, { name: "hello" });
|
||||
assert.strictEqual(result.payload.name, "hello");
|
||||
});
|
||||
|
||||
test("findAll", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const result = await store.findAll("widget");
|
||||
assert.strictEqual(result.length, 2);
|
||||
|
||||
@ -153,7 +153,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("destroyRecord", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = await store.find("widget", 123);
|
||||
|
||||
const result = await store.destroyRecord("widget", widget);
|
||||
@ -161,14 +161,14 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("destroyRecord when new", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const widget = store.createRecord("widget", { name: "hello" });
|
||||
|
||||
assert.true(await store.destroyRecord("widget", widget));
|
||||
});
|
||||
|
||||
test("find embedded", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const fruit = await store.find("fruit", 1);
|
||||
|
||||
assert.propContains(
|
||||
@ -182,7 +182,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("embedded records can be cleared", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
let fruit = await store.find("fruit", 4);
|
||||
fruit.set("farmer", { dummy: "object" });
|
||||
|
||||
@ -191,7 +191,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("meta types", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const barn = await store.find("barn", 1);
|
||||
assert.strictEqual(
|
||||
barn.owner.name,
|
||||
@ -201,7 +201,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("findAll embedded", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const fruits = await store.findAll("fruit");
|
||||
assert.strictEqual(fruits.objectAt(0).farmer.name, "Old MacDonald");
|
||||
assert.strictEqual(
|
||||
@ -235,7 +235,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const users = await store.findAll("user");
|
||||
assert.strictEqual(users.objectAt(0).username, "souna");
|
||||
});
|
||||
@ -249,7 +249,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
return response(fixturesByUrl["/c/bug/1/l/latest.json"]);
|
||||
});
|
||||
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const result = await store.findFiltered("topicList", {
|
||||
filter: "topics/created-by/trout",
|
||||
params: {
|
||||
@ -265,7 +265,7 @@ module("Unit | Service | store", function (hooks) {
|
||||
});
|
||||
|
||||
test("Spec incompliant embedded record name", async function (assert) {
|
||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
const fruit = await store.find("fruit", 4);
|
||||
|
||||
assert.propContains(
|
||||
|
@ -1,15 +1,21 @@
|
||||
import { test } from "qunit";
|
||||
import { module, test } from "qunit";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Unit | Service | user-tips", function (needs) {
|
||||
needs.user();
|
||||
module("Unit | Service | user-tips", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("hideUserTipForever() makes a single request", async function (assert) {
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
const currentUser = logIn();
|
||||
this.owner.unregister("service:current-user");
|
||||
this.owner.register("service:current-user", currentUser, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
site.set("user_tips", { first_notification: 1 });
|
||||
const userTips = getOwnerWithFallback(this).lookup("service:user-tips");
|
||||
|
||||
let requestsCount = 0;
|
||||
pretender.put("/u/eviltrout.json", () => {
|
||||
@ -23,6 +29,7 @@ acceptance("Unit | Service | user-tips", function (needs) {
|
||||
});
|
||||
});
|
||||
|
||||
const userTips = getOwner(this).lookup("service:user-tips");
|
||||
await userTips.hideUserTipForever("first_notification");
|
||||
assert.strictEqual(requestsCount, 1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user