DEV: clarify the slow mode specs names (#13962)

This commit is contained in:
Andrei Prigorshnev 2021-08-05 22:07:29 +04:00 committed by GitHub
parent 38199424bc
commit 2ec0a17bef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,9 +171,14 @@ describe PostRevisor do
topic.update!(slow_mode_seconds: 1000)
end
it 'regular edit' do
subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes)
it 'regular edits are not allowed by default' do
subject.revise!(
post.user,
{ raw: 'updated body' },
revised_at: post.updated_at + 1000.minutes
)
post.reload
expect(post.errors.present?).to eq(true)
expect(post.errors.messages[:base].first).to be I18n.t("cannot_edit_on_slow_mode")
end
@ -181,29 +186,38 @@ describe PostRevisor do
it 'grace period editing is allowed' do
SiteSetting.editing_grace_period = 1.minute
subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.seconds)
subject.revise!(
post.user,
{ raw: 'updated body' },
revised_at: post.updated_at + 10.seconds
)
post.reload
expect(post.errors).to be_empty
end
it 'edits are generally allowed' do
it 'regular edits are allowed if it was turned on in settings' do
SiteSetting.slow_mode_prevents_editing = false
subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes)
subject.revise!(
post.user,
{ raw: 'updated body' },
revised_at: post.updated_at + 10.minutes
)
post.reload
expect(post.errors).to be_empty
end
it 'staff is allowed to edit posts even if the topic is in slow mode' do
admin = Fabricate(:admin)
subject.revise!(admin, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes)
subject.revise!(
admin,
{ raw: 'updated body' },
revised_at: post.updated_at + 10.minutes
)
post.reload
expect(post.errors).to be_empty
end
end