2017-01-26 21:49:17 -05:00
|
|
|
moduleFor("controller:history");
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("displayEdit", function(assert) {
|
2017-01-26 21:49:17 -05:00
|
|
|
const HistoryController = this.subject();
|
|
|
|
|
|
|
|
HistoryController.setProperties({
|
|
|
|
model: { last_revision: 3, current_revision: 3, can_edit: false }
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2017-01-26 21:49:17 -05:00
|
|
|
HistoryController.get("displayEdit"), false,
|
|
|
|
"it should not display edit button when user cannot edit the post"
|
|
|
|
);
|
|
|
|
|
|
|
|
HistoryController.set("model.can_edit", true);
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2017-01-26 21:49:17 -05:00
|
|
|
HistoryController.get("displayEdit"), true,
|
|
|
|
"it should display edit button when user can edit the post"
|
|
|
|
);
|
|
|
|
|
|
|
|
HistoryController.set("model.current_revision", 2);
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2017-01-26 21:49:17 -05:00
|
|
|
HistoryController.get("displayEdit"), false,
|
|
|
|
"it should only display the edit button on the latest revision"
|
|
|
|
);
|
|
|
|
});
|