Commit 4197ebf7 by alisan617

check if general topic exists

parent 59963802
......@@ -186,11 +186,13 @@
};
NewPostView.prototype.resetForm = function() {
var $general;
this.$('.forum-new-post-form')[0].reset();
DiscussionUtil.clearFormErrors(this.$('.post-errors'));
this.$('.wmd-preview p').html('');
if (this.isTabMode()) {
this.topicView.setTopic(this.$('button.topic-title').first());
$general = this.$('.post-topic option:contains(General)');
this.topicView.setTopic($general || this.$('button.topic-title').first());
}
};
......
......@@ -240,6 +240,66 @@
});
});
});
describe('default topic ', function() {
beforeEach(function() {
this.course_settings = new DiscussionCourseSettings({
allow_anonymous_to_peers: true,
allow_anonymous: true,
category_map: {
subcategories: {
'Week 1': {
subcategories: {},
children: [
['Topic-Level Student-Visible Label', 'entry']
],
entries: {
'Topic-Level Student-Visible Label': {
sort_key: null,
is_cohorted: false,
id: '2b3a858d0c884eb4b272dbbe3f2ffddd'
}
}
}
},
children: [
['First topic', 'entry'],
['Week 1', 'subcategory']
],
entries: {
'First topic': {
sort_key: 'First topic',
is_cohorted: false,
id: 'i4x-waqastest-waqastest-course-waqastest'
}
}
}
});
});
it('should be the first topic if General is not found', function() {
var eventSpy, view;
view = new NewPostView({
el: $('#fixture-element'),
collection: this.discussion,
course_settings: this.course_settings,
mode: 'tab'
});
view.render();
eventSpy = jasmine.createSpy('eventSpy');
view.listenTo(view, 'newPost:cancel', eventSpy);
view.$('.post-errors').html("<li class='post-error'>Title can't be empty</li>");
view.$("label[for$='post-type-question']").click();
view.$('.js-post-title').val('Test Title');
view.$('.js-post-body textarea').val('Test body');
view.$('.wmd-preview p').html('Test body');
view.$('input[name=follow]').prop('checked', false);
view.$('input[name=anonymous]').prop('checked', true);
view.$('input[name=anonymous_to_peers]').prop('checked', true);
view.$("a[data-discussion-id='2b3a858d0c884eb4b272dbbe3f2ffddd']").click();
view.$('.cancel').click();
expect(view.$('.post-topic option:selected').text()).toEqual('First topic');
});
});
it('posts to the correct URL', function() {
var topicId, view;
topicId = 'test_topic';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment