mirror of https://github.com/mastodon/mastodon
Fix sort order of moderation notes on Reports and Accounts (#31528)
parent
a9d0b48b65
commit
c88ba523ee
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:account_moderation_note) do
|
Fabricator(:account_moderation_note) do
|
||||||
content 'MyText'
|
content { Faker::Lorem.sentences }
|
||||||
account { Fabricate.build(:account) }
|
account { Fabricate.build(:account) }
|
||||||
target_account { Fabricate.build(:account) }
|
target_account { Fabricate.build(:account) }
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe AccountModerationNote do
|
||||||
|
describe 'chronological scope' do
|
||||||
|
it 'returns account moderation notes oldest to newest' do
|
||||||
|
account = Fabricate(:account)
|
||||||
|
note1 = Fabricate(:account_moderation_note, target_account: account)
|
||||||
|
note2 = Fabricate(:account_moderation_note, target_account: account)
|
||||||
|
|
||||||
|
expect(account.targeted_moderation_notes.chronological).to eq [note1, note2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'validations' do
|
||||||
|
it 'is invalid if the content is empty' do
|
||||||
|
report = Fabricate.build(:account_moderation_note, content: '')
|
||||||
|
expect(report.valid?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'is invalid if content is longer than character limit' do
|
||||||
|
report = Fabricate.build(:account_moderation_note, content: comment_over_limit)
|
||||||
|
expect(report.valid?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_over_limit
|
||||||
|
Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,31 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe ReportNote do
|
||||||
|
describe 'chronological scope' do
|
||||||
|
it 'returns report notes oldest to newest' do
|
||||||
|
report = Fabricate(:report)
|
||||||
|
note1 = Fabricate(:report_note, report: report)
|
||||||
|
note2 = Fabricate(:report_note, report: report)
|
||||||
|
|
||||||
|
expect(report.notes.chronological).to eq [note1, note2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'validations' do
|
||||||
|
it 'is invalid if the content is empty' do
|
||||||
|
report = Fabricate.build(:report_note, content: '')
|
||||||
|
expect(report.valid?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'is invalid if content is longer than character limit' do
|
||||||
|
report = Fabricate.build(:report_note, content: comment_over_limit)
|
||||||
|
expect(report.valid?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_over_limit
|
||||||
|
Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue