mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 13:38:49 +08:00
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
|
|
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");
|
|
}); |