mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-21 18:05:23 -05:00
Simplify model validation spec in AccountModerationNote/ReportNote (#31792)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.1) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.1) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.1) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.1, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.1) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.1) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.1) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.1, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
This commit is contained in:
parent
dea6c454fd
commit
37bcbeab4a
|
|
@ -3,29 +3,24 @@
|
|||
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)
|
||||
describe 'Scopes' do
|
||||
describe '.chronological' 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]
|
||||
expect(account.targeted_moderation_notes.chronological).to eq [note1, note2]
|
||||
end
|
||||
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
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :account_moderation_note }
|
||||
|
||||
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)
|
||||
describe 'content' do
|
||||
it { is_expected.to_not allow_value('').for(:content) }
|
||||
it { is_expected.to validate_length_of(:content).is_at_most(described_class::CONTENT_SIZE_LIMIT) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,29 +3,24 @@
|
|||
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)
|
||||
describe 'Scopes' do
|
||||
describe '.chronological' 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]
|
||||
expect(report.notes.chronological).to eq [note1, note2]
|
||||
end
|
||||
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
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :report_note }
|
||||
|
||||
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)
|
||||
describe 'content' do
|
||||
it { is_expected.to_not allow_value('').for(:content) }
|
||||
it { is_expected.to validate_length_of(:content).is_at_most(described_class::CONTENT_SIZE_LIMIT) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user