Commit fde96345 authored by Stan Hu's avatar Stan Hu

Fix date-dependent failing spec in export_service_spec.rb

The test used a hard-coded 2021-01-01 as an expiration date, but once
the current date reaches that date this is no longer valid since it's
not in the past. We fix this by using a date always one month from the
current date.
parent e2b0cc80
...@@ -75,9 +75,11 @@ RSpec.describe Groups::Memberships::ExportService do ...@@ -75,9 +75,11 @@ RSpec.describe Groups::Memberships::ExportService do
end end
context 'data verification' do context 'data verification' do
let(:expiry_date) { Date.today + 1.month }
before do before do
create_list(:group_member, 4, group: group) create_list(:group_member, 4, group: group)
create(:group_member, group: group, created_at: '2021-02-01', expires_at: '2022-01-01', user: create(:user, username: 'mwoolf', name: 'Max Woolf')) create(:group_member, group: group, created_at: '2021-02-01', expires_at: expiry_date, user: create(:user, username: 'mwoolf', name: 'Max Woolf'))
create(:group_member, :invited, group: group) create(:group_member, :invited, group: group)
create(:group_member, :ldap, group: group) create(:group_member, :ldap, group: group)
create(:group_member, :blocked, group: group) create(:group_member, :blocked, group: group)
...@@ -100,7 +102,7 @@ RSpec.describe Groups::Memberships::ExportService do ...@@ -100,7 +102,7 @@ RSpec.describe Groups::Memberships::ExportService do
expect(direct_user_row[0]).to eq('mwoolf') expect(direct_user_row[0]).to eq('mwoolf')
expect(direct_user_row[1]).to eq('Max Woolf') expect(direct_user_row[1]).to eq('Max Woolf')
expect(direct_user_row[2]).to eq('2021-02-01 00:00:00') expect(direct_user_row[2]).to eq('2021-02-01 00:00:00')
expect(direct_user_row[3]).to eq('2022-01-01') expect(direct_user_row[3]).to eq(expiry_date.to_s)
expect(direct_user_row[4]).to eq('Owner') expect(direct_user_row[4]).to eq('Owner')
expect(direct_user_row[5]).to eq('Direct member') expect(direct_user_row[5]).to eq('Direct member')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment