Merge remote-tracking branch 'parent/main' into upstream-20240926
This commit is contained in:
commit
c905714459
517 changed files with 4284 additions and 3891 deletions
|
@ -12,3 +12,32 @@ RSpec.shared_examples 'localized subject' do |*args, **kwrest|
|
|||
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: I18n.default_locale))
|
||||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :have_thread_headers do
|
||||
match(notify_expectation_failures: true) do |mail|
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_header('In-Reply-To', conversation_header_regex))
|
||||
.and(have_header('References', conversation_header_regex))
|
||||
end
|
||||
|
||||
def conversation_header_regex = /<conversation-\d+.\d\d\d\d-\d\d-\d\d@cb6e6126.ngrok.io>/
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :have_standard_headers do |type|
|
||||
chain :for do |user|
|
||||
@user = user
|
||||
end
|
||||
|
||||
match(notify_expectation_failures: true) do |mail|
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_header('To', "#{@user.account.username} <#{@user.email}>"))
|
||||
.and(have_header('List-ID', "<#{type}.#{@user.account.username}.#{Rails.configuration.x.local_domain}>"))
|
||||
.and(have_header('List-Unsubscribe', %r{<https://#{Rails.configuration.x.local_domain}/unsubscribe\?token=.+>}))
|
||||
.and(have_header('List-Unsubscribe', /&type=#{type}/))
|
||||
.and(have_header('List-Unsubscribe-Post', 'List-Unsubscribe=One-Click'))
|
||||
.and(deliver_to("#{@user.account.username} <#{@user.email}>"))
|
||||
.and(deliver_from(Rails.configuration.action_mailer.default_options[:from]))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,31 @@ RSpec.shared_examples 'Reviewable' do
|
|||
let(:reviewed_at) { nil }
|
||||
let(:requested_review_at) { nil }
|
||||
|
||||
describe 'Scopes' do
|
||||
let!(:reviewed_record) { Fabricate factory_name, reviewed_at: 10.days.ago }
|
||||
let!(:un_reviewed_record) { Fabricate factory_name, reviewed_at: nil }
|
||||
|
||||
describe '.reviewed' do
|
||||
it 'returns reviewed records' do
|
||||
expect(described_class.reviewed)
|
||||
.to include(reviewed_record)
|
||||
.and not_include(un_reviewed_record)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.unreviewed' do
|
||||
it 'returns non reviewed records' do
|
||||
expect(described_class.unreviewed)
|
||||
.to include(un_reviewed_record)
|
||||
.and not_include(reviewed_record)
|
||||
end
|
||||
end
|
||||
|
||||
def factory_name
|
||||
described_class.name.underscore.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
describe '#requires_review?' do
|
||||
it { is_expected.to be_requires_review }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue