diff options
Diffstat (limited to 'spec/migrations/orphaned_invite_tokens_cleanup_spec.rb')
-rw-r--r-- | spec/migrations/orphaned_invite_tokens_cleanup_spec.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb b/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb index 889c04700c7..be5e7756514 100644 --- a/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb +++ b/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb @@ -16,7 +16,7 @@ RSpec.describe OrphanedInviteTokensCleanup, :migration do table(:members).create!(defaults.merge(extra_attributes)) end - describe '#up', :aggregate_failures do + shared_examples 'removes orphaned invite tokens' do it 'removes invite tokens for accepted records with invite_accepted_at < created_at' do record1 = create_member(invite_token: 'foo', invite_accepted_at: 1.day.ago, created_at: 1.hour.ago) record2 = create_member(invite_token: 'foo2', invite_accepted_at: nil, created_at: 1.hour.ago) @@ -29,4 +29,22 @@ RSpec.describe OrphanedInviteTokensCleanup, :migration do expect(table(:members).find(record3.id).invite_token).to eq 'foo3' end end + + describe '#up', :aggregate_failures do + it_behaves_like 'removes orphaned invite tokens' + end + + context 'when there is a mix of timestamptz and timestamp types' do + around do |example| + ActiveRecord::Base.connection.execute "ALTER TABLE members alter created_at type timestamp with time zone" + + example.run + + ActiveRecord::Base.connection.execute "ALTER TABLE members alter created_at type timestamp without time zone" + end + + describe '#up', :aggregate_failures do + it_behaves_like 'removes orphaned invite tokens' + end + end end |