mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
Refactor: Move Topic Details into better objects, identity map, tests, query string filters
This commit is contained in:
parent
d051e35000
commit
5770879472
56 changed files with 1854 additions and 1244 deletions
35
test/javascripts/controllers/topic_controller_test.js
Normal file
35
test/javascripts/controllers/topic_controller_test.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
var topic = Discourse.Topic.create({
|
||||
title: "Qunit Test Topic",
|
||||
participants: [
|
||||
{id: 1234,
|
||||
post_count: 4,
|
||||
username: "eviltrout"}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
module("Discourse.TopicController", {
|
||||
setup: function() {
|
||||
this.topicController = controllerFor('topic', topic);
|
||||
}
|
||||
});
|
||||
|
||||
test("editingMode", function() {
|
||||
var topicController = this.topicController;
|
||||
|
||||
ok(!topicController.get('editingTopic'), "we are not editing by default");
|
||||
|
||||
topicController.set('model.details.can_edit', false);
|
||||
topicController.editTopic();
|
||||
ok(!topicController.get('editingTopic'), "calling editTopic doesn't enable editing unless the user can edit");
|
||||
|
||||
topicController.set('model.details.can_edit', true);
|
||||
topicController.editTopic();
|
||||
ok(topicController.get('editingTopic'), "calling editTopic enables editing if the user can edit");
|
||||
equal(topicController.get('newTitle'), topic.get('title'));
|
||||
equal(topicController.get('newCategoryId'), topic.get('category_id'));
|
||||
|
||||
topicController.cancelEditingTopic();
|
||||
ok(!topicController.get('editingTopic'), "cancelling edit mode reverts the property value");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue