mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 13:36:39 +08:00
FIX: featured link topics shouldn't require the same min post length
This commit is contained in:
parent
5da52780e4
commit
fb2633366a
@ -286,7 +286,7 @@ const Composer = RestModel.extend({
|
|||||||
@computed('minimumPostLength', 'replyLength', 'canEditTopicFeaturedLink')
|
@computed('minimumPostLength', 'replyLength', 'canEditTopicFeaturedLink')
|
||||||
missingReplyCharacters(minimumPostLength, replyLength, canEditTopicFeaturedLink) {
|
missingReplyCharacters(minimumPostLength, replyLength, canEditTopicFeaturedLink) {
|
||||||
if (this.get('post.post_type') === this.site.get('post_types.small_action') ||
|
if (this.get('post.post_type') === this.site.get('post_types.small_action') ||
|
||||||
canEditTopicFeaturedLink && this.siteSettings.topic_featured_link_onebox) { return 0; }
|
canEditTopicFeaturedLink && this.get('featuredLink')) { return 0; }
|
||||||
return minimumPostLength - replyLength;
|
return minimumPostLength - replyLength;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -509,9 +509,7 @@ const Composer = RestModel.extend({
|
|||||||
if (!this.get('cantSubmitPost')) {
|
if (!this.get('cantSubmitPost')) {
|
||||||
|
|
||||||
// change category may result in some effect for topic featured link
|
// change category may result in some effect for topic featured link
|
||||||
if (this.get('canEditTopicFeaturedLink')) {
|
if (!this.get('canEditTopicFeaturedLink')) {
|
||||||
if (this.siteSettings.topic_featured_link_onebox) { this.set('reply', null); }
|
|
||||||
} else {
|
|
||||||
this.set('featuredLink', null);
|
this.set('featuredLink', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Validators::PostValidator < ActiveModel::Validator
|
|||||||
SiteSetting.private_message_post_length
|
SiteSetting.private_message_post_length
|
||||||
elsif post.is_first_post? || (post.topic.present? && post.topic.posts_count == 0)
|
elsif post.is_first_post? || (post.topic.present? && post.topic.posts_count == 0)
|
||||||
# creating/editing first post
|
# creating/editing first post
|
||||||
SiteSetting.first_post_length
|
post.topic&.featured_link&.present? ? (0..SiteSetting.max_post_length) : SiteSetting.first_post_length
|
||||||
else
|
else
|
||||||
# regular post
|
# regular post
|
||||||
SiteSetting.post_length
|
SiteSetting.post_length
|
||||||
|
@ -246,8 +246,10 @@ describe PostCreator do
|
|||||||
|
|
||||||
it 'creates a post with featured link' do
|
it 'creates a post with featured link' do
|
||||||
SiteSetting.topic_featured_link_enabled = true
|
SiteSetting.topic_featured_link_enabled = true
|
||||||
|
SiteSetting.min_first_post_length = 100
|
||||||
post = creator_with_featured_link.create
|
post = creator_with_featured_link.create
|
||||||
expect(post.topic.featured_link).to eq('http://www.discourse.org')
|
expect(post.topic.featured_link).to eq('http://www.discourse.org')
|
||||||
|
expect(post.valid?).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "topic's auto close" do
|
describe "topic's auto close" do
|
||||||
|
@ -41,9 +41,10 @@ test('missingReplyCharacters', function() {
|
|||||||
missingReplyCharacters('hi', false, true, Discourse.SiteSettings.min_first_post_length - 2, 'too short first post');
|
missingReplyCharacters('hi', false, true, Discourse.SiteSettings.min_first_post_length - 2, 'too short first post');
|
||||||
missingReplyCharacters('hi', true, false, Discourse.SiteSettings.min_private_message_post_length - 2, 'too short private message');
|
missingReplyCharacters('hi', true, false, Discourse.SiteSettings.min_private_message_post_length - 2, 'too short private message');
|
||||||
|
|
||||||
// TODO: test that presence of featured link makes this test pass
|
const link = "http://imgur.com/gallery/grxX8";
|
||||||
// const composer = createComposer({ canEditTopicFeaturedLink: true });
|
const composer = createComposer({ canEditTopicFeaturedLink: true, title: link, featuredLink: link, reply: link });
|
||||||
// equal(composer.get('missingReplyCharacters'), 0, "don't require any post content");
|
|
||||||
|
equal(composer.get('missingReplyCharacters'), 0, "don't require any post content");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('missingTitleCharacters', function() {
|
test('missingTitleCharacters', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user