Revert "topic fixup" (#11223)

The review queue page fails to load with the error: "TypeError: category is null"

This reverts commit 19b7cdd21f.
This commit is contained in:
Roman Rizzi 2020-11-12 15:15:25 -03:00 committed by GitHub
parent 89fc11e93b
commit ffd1b7c234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View File

@ -225,14 +225,8 @@ const Topic = RestModel.extend({
}, },
@discourseComputed("category_id") @discourseComputed("category_id")
category: { category(categoryId) {
get(categoryId) { return Category.findById(categoryId);
return Category.findById(categoryId);
},
set(category) {
this.set("category_id", category.id);
return category;
},
}, },
categoryClass: fmt("category.fullSlug", "category-%@"), categoryClass: fmt("category.fullSlug", "category-%@"),

View File

@ -4,7 +4,7 @@ import Category from "discourse/models/category";
import Topic from "discourse/models/topic"; import Topic from "discourse/models/topic";
import User from "discourse/models/user"; import User from "discourse/models/user";
import { discourseModule } from "discourse/tests/helpers/qunit-helpers"; import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import createStore from "discourse/tests/helpers/create-store"; import EmberObject from "@ember/object";
discourseModule("Unit | Model | topic", function () { discourseModule("Unit | Model | topic", function () {
test("defaults", function (assert) { test("defaults", function (assert) {
@ -36,9 +36,7 @@ discourseModule("Unit | Model | topic", function () {
}); });
test("lastUnreadUrl", function (assert) { test("lastUnreadUrl", function (assert) {
const store = createStore(); const category = EmberObject.create({
const category = store.createRecord("category", {
id: 1,
navigate_to_first_post_after_read: true, navigate_to_first_post_after_read: true,
}); });
@ -47,9 +45,10 @@ discourseModule("Unit | Model | topic", function () {
highest_post_number: 10, highest_post_number: 10,
last_read_post_number: 10, last_read_post_number: 10,
slug: "hello", slug: "hello",
category_id: category.id,
}); });
topic.set("category", category);
assert.equal(topic.get("lastUnreadUrl"), "/t/hello/101/1"); assert.equal(topic.get("lastUnreadUrl"), "/t/hello/101/1");
}); });