2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-06 11:19:27 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Expirable do
|
2016-10-06 11:19:27 -04:00
|
|
|
describe 'ProjectMember' do
|
2020-10-01 14:10:20 -04:00
|
|
|
let_it_be(:no_expire) { create(:project_member) }
|
|
|
|
let_it_be(:expire_later) { create(:project_member, expires_at: 8.days.from_now) }
|
|
|
|
let_it_be(:expired) { create(:project_member, expires_at: 1.day.from_now) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
travel_to(3.days.from_now)
|
|
|
|
end
|
2016-10-06 11:19:27 -04:00
|
|
|
|
|
|
|
describe '.expired' do
|
|
|
|
it { expect(ProjectMember.expired).to match_array([expired]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#expired?' do
|
|
|
|
it { expect(no_expire.expired?).to eq(false) }
|
|
|
|
it { expect(expire_later.expired?).to eq(false) }
|
|
|
|
it { expect(expired.expired?).to eq(true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#expires?' do
|
|
|
|
it { expect(no_expire.expires?).to eq(false) }
|
|
|
|
it { expect(expire_later.expires?).to eq(true) }
|
|
|
|
it { expect(expired.expires?).to eq(true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#expires_soon?' do
|
|
|
|
it { expect(no_expire.expires_soon?).to eq(false) }
|
|
|
|
it { expect(expire_later.expires_soon?).to eq(true) }
|
|
|
|
it { expect(expired.expires_soon?).to eq(true) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|