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-05-28 00:08:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-28 00:08:05 +0300
commit47579e24f3f9f29d5b8093f54e6958fefd7f2057 (patch)
treee8dedf16ceaa2143ce4e81906527a4670cb9916a /spec/workers
parent88ccc935c04ff0e015be60bac02853770b79d28d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/personal_access_tokens/expiring_worker_spec.rb22
-rw-r--r--spec/workers/post_receive_spec.rb2
2 files changed, 20 insertions, 4 deletions
diff --git a/spec/workers/personal_access_tokens/expiring_worker_spec.rb b/spec/workers/personal_access_tokens/expiring_worker_spec.rb
index fcc09e2705c..c8bdf02f4d3 100644
--- a/spec/workers/personal_access_tokens/expiring_worker_spec.rb
+++ b/spec/workers/personal_access_tokens/expiring_worker_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe PersonalAccessTokens::ExpiringWorker, type: :worker do
describe '#perform' do
context 'when a token needs to be notified' do
- let!(:pat) { create(:personal_access_token, expires_at: 5.days.from_now) }
+ let_it_be(:pat) { create(:personal_access_token, expires_at: 5.days.from_now) }
it 'uses notification service to send the email' do
expect_next_instance_of(NotificationService) do |notification_service|
@@ -23,7 +23,7 @@ RSpec.describe PersonalAccessTokens::ExpiringWorker, type: :worker do
end
context 'when no tokens need to be notified' do
- let!(:pat) { create(:personal_access_token, expires_at: 5.days.from_now, expire_notification_delivered: true) }
+ let_it_be(:pat) { create(:personal_access_token, expires_at: 5.days.from_now, expire_notification_delivered: true) }
it "doesn't use notification service to send the email" do
expect_next_instance_of(NotificationService) do |notification_service|
@@ -33,7 +33,23 @@ RSpec.describe PersonalAccessTokens::ExpiringWorker, type: :worker do
worker.perform
end
- it "doesn't change the notificationd delivered of the token" do
+ it "doesn't change the notification delivered of the token" do
+ expect { worker.perform }.not_to change { pat.reload.expire_notification_delivered }
+ end
+ end
+
+ context 'when a token is an impersonation token' do
+ let_it_be(:pat) { create(:personal_access_token, :impersonation, expires_at: 5.days.from_now) }
+
+ it "doesn't use notification service to send the email" do
+ expect_next_instance_of(NotificationService) do |notification_service|
+ expect(notification_service).not_to receive(:access_token_about_to_expire).with(pat.user)
+ end
+
+ worker.perform
+ end
+
+ it "doesn't change the notification delivered of the token" do
expect { worker.perform }.not_to change { pat.reload.expire_notification_delivered }
end
end
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index aab7a36189a..18e06332eb3 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -355,7 +355,7 @@ describe PostReceive do
context "webhook" do
it "fetches the correct project" do
- expect(Project).to receive(:find_by).with(id: project.id.to_s)
+ expect(Project).to receive(:find_by).with(id: project.id)
perform
end