Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-04 06:09:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-04 06:09:49 +0300
commitedf27428120b9726e34e577e5b1d3371c74baf1d (patch)
tree3e59d3def1ef3eb3ce5832f8daf6bbcd09acd841 /spec/services/members
parent73fd5a897364c6f91f86a0dd6d4b566c2574ca6e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/members')
-rw-r--r--spec/services/members/invitation_reminder_email_service_spec.rb96
1 files changed, 39 insertions, 57 deletions
diff --git a/spec/services/members/invitation_reminder_email_service_spec.rb b/spec/services/members/invitation_reminder_email_service_spec.rb
index 7cb30662152..768a8719d54 100644
--- a/spec/services/members/invitation_reminder_email_service_spec.rb
+++ b/spec/services/members/invitation_reminder_email_service_spec.rb
@@ -9,67 +9,49 @@ RSpec.describe Members::InvitationReminderEmailService do
let_it_be(:frozen_time) { Date.today.beginning_of_day }
let_it_be(:invitation) { build(:group_member, :invited, created_at: frozen_time) }
- context 'when the experiment is disabled' do
- before do
- allow(Gitlab::Experimentation).to receive(:in_experiment_group?).and_return(false)
- invitation.expires_at = frozen_time + 2.days
- end
-
- it 'does not send an invitation' do
- travel_to(frozen_time + 1.day) do
- expect(invitation).not_to receive(:send_invitation_reminder)
-
- subject
- end
- end
+ before do
+ invitation.expires_at = frozen_time + expires_at_days.days if expires_at_days
end
- context 'when the experiment is enabled' do
- before do
- allow(Gitlab::Experimentation).to receive(:in_experiment_group?).and_return(true)
- invitation.expires_at = frozen_time + expires_at_days.days if expires_at_days
- end
-
- using RSpec::Parameterized::TableSyntax
-
- where(:expires_at_days, :send_reminder_at_days) do
- 0 | []
- 1 | []
- 2 | [1]
- 3 | [1, 2]
- 4 | [1, 2, 3]
- 5 | [1, 2, 4]
- 6 | [1, 3, 5]
- 7 | [1, 3, 5]
- 8 | [2, 3, 6]
- 9 | [2, 4, 7]
- 10 | [2, 4, 8]
- 11 | [2, 4, 8]
- 12 | [2, 5, 9]
- 13 | [2, 5, 10]
- 14 | [2, 5, 10]
- 15 | [2, 5, 10]
- nil | [2, 5, 10]
- end
-
- with_them do
- # Create an invitation today with an expiration date from 0 to 10 days in the future or without an expiration date
- # We chose 10 days here, because we fetch invitations that were created at most 10 days ago.
- (0..10).each do |day|
- it 'sends an invitation reminder only on the expected days' do
- next if day > (expires_at_days || 10) # We don't need to test after the invitation has already expired
-
- # We are traveling in a loop from today to 10 days from now
- travel_to(frozen_time + day.days) do
- # Given an expiration date and the number of days after the creation of the invitation based on the current day in the loop, a reminder may be sent
- if (reminder_index = send_reminder_at_days.index(day))
- expect(invitation).to receive(:send_invitation_reminder).with(reminder_index)
- else
- expect(invitation).not_to receive(:send_invitation_reminder)
- end
+ using RSpec::Parameterized::TableSyntax
+
+ where(:expires_at_days, :send_reminder_at_days) do
+ 0 | []
+ 1 | []
+ 2 | [1]
+ 3 | [1, 2]
+ 4 | [1, 2, 3]
+ 5 | [1, 2, 4]
+ 6 | [1, 3, 5]
+ 7 | [1, 3, 5]
+ 8 | [2, 3, 6]
+ 9 | [2, 4, 7]
+ 10 | [2, 4, 8]
+ 11 | [2, 4, 8]
+ 12 | [2, 5, 9]
+ 13 | [2, 5, 10]
+ 14 | [2, 5, 10]
+ 15 | [2, 5, 10]
+ nil | [2, 5, 10]
+ end
- subject
+ with_them do
+ # Create an invitation today with an expiration date from 0 to 10 days in the future or without an expiration date
+ # We chose 10 days here, because we fetch invitations that were created at most 10 days ago.
+ (0..10).each do |day|
+ it 'sends an invitation reminder only on the expected days' do
+ next if day > (expires_at_days || 10) # We don't need to test after the invitation has already expired
+
+ # We are traveling in a loop from today to 10 days from now
+ travel_to(frozen_time + day.days) do
+ # Given an expiration date and the number of days after the creation of the invitation based on the current day in the loop, a reminder may be sent
+ if (reminder_index = send_reminder_at_days.index(day))
+ expect(invitation).to receive(:send_invitation_reminder).with(reminder_index)
+ else
+ expect(invitation).not_to receive(:send_invitation_reminder)
end
+
+ subject
end
end
end