FIX: Modal asking where to post was missing

This commit is contained in:
Robin Ward 2015-05-14 18:18:12 -04:00
parent 4451c8802a
commit 8e395a94d4
6 changed files with 36 additions and 8 deletions

View File

@ -191,8 +191,9 @@ export default Ember.ObjectController.extend(Presence, {
// for now handle a very narrow use case
// if we are replying to a topic AND not on the topic pop the window up
if (!force && composer.get('replyingToTopic')) {
const topic = this.get('model.topic');
if (!topic || topic.get('id') !== composer.get('topic.id'))
const currentTopic = this.get('controllers.topic.model');
if (!currentTopic || currentTopic.get('id') !== composer.get('topic.id'))
{
const message = I18n.t("composer.posting_not_on_topic");
@ -202,12 +203,12 @@ export default Ember.ObjectController.extend(Presence, {
"link": true
}];
if (topic) {
if (currentTopic) {
buttons.push({
"label": I18n.t("composer.reply_here") + "<br/><div class='topic-title overflow-ellipsis'>" + Handlebars.Utils.escapeExpression(topic.get('title')) + "</div>",
"label": I18n.t("composer.reply_here") + "<br/><div class='topic-title overflow-ellipsis'>" + Handlebars.Utils.escapeExpression(currentTopic.get('title')) + "</div>",
"class": "btn btn-reply-here",
"callback": function() {
composer.set('topic', topic);
composer.set('topic', currentTopic);
composer.set('post', null);
self.save(true);
}

View File

@ -16,6 +16,7 @@ export default ObjectController.extend(SelectedPostsCount, BufferedContent, {
loadedAllPosts: false,
enteredAt: null,
firstPostExpanded: false,
retrying: false,
maxTitleLength: Discourse.computed.setting('max_topic_title_length'),

View File

@ -128,8 +128,8 @@
{{{model.notFoundHtml}}}
{{else}}
<div class="topic-error">
<div>{{message}}</div>
{{#if noRetry}}
<div>{{model.message}}</div>
{{#if model.noRetry}}
{{#unless currentUser}}
{{d-button action="showLogin" class="btn-primary topic-retry" icon="user" label="log_in"}}
{{/unless}}

View File

@ -119,6 +119,27 @@ test("Create a Reply", () => {
});
});
test("Posting on a different topic", (assert) => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('#wmd-input', 'this is the content for a different topic');
visit("/t/1-3-0beta9-no-rate-limit-popups/28830");
andThen(function() {
assert.equal(currentURL(), "/t/1-3-0beta9-no-rate-limit-popups/28830");
});
click('#reply-control button.create');
andThen(function() {
assert.ok(visible('.reply-where-modal'), 'it pops up a modal');
});
click('.btn-reply-here');
andThen(() => {
assert.equal(find('.cooked:last p').text(), 'this is the content for a different topic');
});
});
test("Create an enqueued Reply", () => {
visit("/t/internationalization-localization/280");

File diff suppressed because one or more lines are too long

View File

@ -103,6 +103,10 @@ export default function() {
return response(fixturesByUrl['/t/280/1.json']);
});
this.get("/t/28830.json", function() {
return response(fixturesByUrl['/t/28830/1.json']);
});
this.get("/t/id_for/:slug", function() {
return response({id: 280, slug: "internationalization-localization", url: "/t/internationalization-localization/280"});
});