mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FEATURE: Allow posting a link with topics
This commit is contained in:
@ -421,14 +421,14 @@ describe Category do
|
||||
describe 'latest' do
|
||||
it 'should be updated correctly' do
|
||||
category = Fabricate(:category)
|
||||
post = create_post(category: category.name)
|
||||
post = create_post(category: category.id)
|
||||
|
||||
category.reload
|
||||
expect(category.latest_post_id).to eq(post.id)
|
||||
expect(category.latest_topic_id).to eq(post.topic_id)
|
||||
|
||||
post2 = create_post(category: category.name)
|
||||
post3 = create_post(topic_id: post.topic_id, category: category.name)
|
||||
post2 = create_post(category: category.id)
|
||||
post3 = create_post(topic_id: post.topic_id, category: category.id)
|
||||
|
||||
category.reload
|
||||
expect(category.latest_post_id).to eq(post3.id)
|
||||
@ -451,7 +451,7 @@ describe Category do
|
||||
|
||||
context 'with regular topics' do
|
||||
before do
|
||||
create_post(user: @category.user, category: @category.name)
|
||||
create_post(user: @category.user, category: @category.id)
|
||||
Category.update_stats
|
||||
@category.reload
|
||||
end
|
||||
@ -491,7 +491,7 @@ describe Category do
|
||||
|
||||
context 'with revised post' do
|
||||
before do
|
||||
post = create_post(user: @category.user, category: @category.name)
|
||||
post = create_post(user: @category.user, category: @category.id)
|
||||
|
||||
SiteSetting.stubs(:editing_grace_period).returns(1.minute.to_i)
|
||||
post.revise(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 2.minutes)
|
||||
|
@ -1725,7 +1725,6 @@ describe Topic do
|
||||
expect(@topic_status_event_triggered).to eq(true)
|
||||
end
|
||||
|
||||
|
||||
it 'allows users to normalize counts' do
|
||||
|
||||
topic = Fabricate(:topic, last_posted_at: 1.year.ago)
|
||||
@ -1741,4 +1740,39 @@ describe Topic do
|
||||
expect(topic.last_posted_at).to be_within(1.second).of (post1.created_at)
|
||||
end
|
||||
|
||||
context 'featured link' do
|
||||
before { SiteSetting.topic_featured_link_enabled = true }
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
|
||||
it 'can validate featured link' do
|
||||
topic.featured_link = ' invalid string'
|
||||
|
||||
expect(topic).not_to be_valid
|
||||
expect(topic.errors[:featured_link]).to be_present
|
||||
end
|
||||
|
||||
it 'can properly save the featured link' do
|
||||
topic.featured_link = ' https://github.com/discourse/discourse'
|
||||
|
||||
expect(topic.save).to be_truthy
|
||||
expect(topic.custom_fields['featured_link']).to eq('https://github.com/discourse/discourse')
|
||||
end
|
||||
|
||||
context 'when category restricts present' do
|
||||
let!(:link_category) { Fabricate(:link_category) }
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let(:link_topic) { Fabricate(:topic, category: link_category) }
|
||||
|
||||
it 'can save the featured link if it belongs to that category' do
|
||||
link_topic.featured_link = 'https://github.com/discourse/discourse'
|
||||
expect(link_topic.save).to be_truthy
|
||||
expect(link_topic.custom_fields['featured_link']).to eq('https://github.com/discourse/discourse')
|
||||
end
|
||||
|
||||
it 'can not save the featured link if it belongs to that category' do
|
||||
topic.featured_link = 'https://github.com/discourse/discourse'
|
||||
expect(topic.save).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user