2024-09-06 14:58:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe ReportNote do
|
2024-10-24 12:52:38 +00:00
|
|
|
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)
|
2024-09-06 14:58:36 +00:00
|
|
|
|
2024-10-24 12:52:38 +00:00
|
|
|
expect(report.notes.chronological).to eq [note1, note2]
|
|
|
|
end
|
2024-09-06 14:58:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-10-24 12:52:38 +00:00
|
|
|
describe 'Validations' do
|
|
|
|
subject { Fabricate.build :report_note }
|
2024-09-06 14:58:36 +00:00
|
|
|
|
2024-10-24 12:52:38 +00:00
|
|
|
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) }
|
2024-09-06 14:58:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|