diff --git a/app/assets/javascripts/discourse/app/models/topic.js b/app/assets/javascripts/discourse/app/models/topic.js index 2170c0ee4c..ed0d7c2c33 100644 --- a/app/assets/javascripts/discourse/app/models/topic.js +++ b/app/assets/javascripts/discourse/app/models/topic.js @@ -225,14 +225,8 @@ const Topic = RestModel.extend({ }, @discourseComputed("category_id") - category: { - get(categoryId) { - return Category.findById(categoryId); - }, - set(category) { - this.set("category_id", category.id); - return category; - }, + category(categoryId) { + return Category.findById(categoryId); }, categoryClass: fmt("category.fullSlug", "category-%@"), diff --git a/app/assets/javascripts/discourse/tests/unit/models/topic-test.js b/app/assets/javascripts/discourse/tests/unit/models/topic-test.js index 1f466fd164..02fbdbd492 100644 --- a/app/assets/javascripts/discourse/tests/unit/models/topic-test.js +++ b/app/assets/javascripts/discourse/tests/unit/models/topic-test.js @@ -4,7 +4,7 @@ import Category from "discourse/models/category"; import Topic from "discourse/models/topic"; import User from "discourse/models/user"; 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 () { test("defaults", function (assert) { @@ -36,9 +36,7 @@ discourseModule("Unit | Model | topic", function () { }); test("lastUnreadUrl", function (assert) { - const store = createStore(); - const category = store.createRecord("category", { - id: 1, + const category = EmberObject.create({ navigate_to_first_post_after_read: true, }); @@ -47,9 +45,10 @@ discourseModule("Unit | Model | topic", function () { highest_post_number: 10, last_read_post_number: 10, slug: "hello", - category_id: category.id, }); + topic.set("category", category); + assert.equal(topic.get("lastUnreadUrl"), "/t/hello/101/1"); });