summaryrefslogtreecommitdiff
path: root/spec/workers/remove_expired_group_links_worker_spec.rb
blob: 689bc3d27b4c46e8166478cd99c971bf31cd88d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'spec_helper'

describe RemoveExpiredGroupLinksWorker do
  describe '#perform' do
    let!(:expired_project_group_link) { create(:project_group_link, expires_at: 1.hour.ago) }
    let!(:project_group_link_expiring_in_future) { create(:project_group_link, expires_at: 10.days.from_now) }
    let!(:non_expiring_project_group_link) { create(:project_group_link, expires_at: nil) }

    it 'removes expired group links' do
      expect { subject.perform }.to change { ProjectGroupLink.count }.by(-1)
      expect(ProjectGroupLink.find_by(id: expired_project_group_link.id)).to be_nil
    end

    it 'leaves group links that expire in the future' do
      subject.perform
      expect(project_group_link_expiring_in_future.reload).to be_present
    end

    it 'leaves group links that do not expire at all' do
      subject.perform
      expect(non_expiring_project_group_link.reload).to be_present
    end
  end
end