~cytrogen/masto-fe

ref: f906e21a4fa2b035ee565ed55eeaa629df48e2e6 masto-fe/spec/lib/mastodon/migration_warning_spec.rb -rw-r--r-- 1.1 KiB
f906e21a — Daniel M Brasil Add test coverage for `Mastodon::CLI::Accounts#refresh` (#25196) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require 'rails_helper'
require 'mastodon/migration_warning'

describe Mastodon::MigrationWarning do
  describe 'migration_duration_warning' do
    before do
      allow(migration).to receive(:valid_environment?).and_return(true)
      allow(migration).to receive(:sleep).with(1)
    end

    let(:migration) { Class.new(ActiveRecord::Migration[6.1]).extend(described_class) }

    context 'with the default message' do
      it 'warns about long migrations' do
        expectation = expect { migration.migration_duration_warning }

        expectation.to output(/interrupt this migration/).to_stdout
        expectation.to output(/Continuing in 5/).to_stdout
      end
    end

    context 'with an additional message' do
      it 'warns about long migrations' do
        expectation = expect { migration.migration_duration_warning('Get ready for it') }

        expectation.to output(/interrupt this migration/).to_stdout
        expectation.to output(/Get ready for it/).to_stdout
        expectation.to output(/Continuing in 5/).to_stdout
      end
    end
  end
end