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:
Diffstat (limited to 'spec/helpers/users/callouts_helper_spec.rb')
-rw-r--r--spec/helpers/users/callouts_helper_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/helpers/users/callouts_helper_spec.rb b/spec/helpers/users/callouts_helper_spec.rb
index 71a8d340b30..2c148aabead 100644
--- a/spec/helpers/users/callouts_helper_spec.rb
+++ b/spec/helpers/users/callouts_helper_spec.rb
@@ -222,4 +222,60 @@ RSpec.describe Users::CalloutsHelper do
it { is_expected.to be true }
end
end
+
+ describe '#web_hook_disabled_dismissed?' do
+ context 'without a project' do
+ it 'is false' do
+ expect(helper).not_to be_web_hook_disabled_dismissed(nil)
+ end
+ end
+
+ context 'with a project' do
+ let_it_be(:project) { create(:project) }
+
+ context 'the web-hook failure callout has never been dismissed' do
+ it 'is false' do
+ expect(helper).not_to be_web_hook_disabled_dismissed(project)
+ end
+ end
+
+ context 'the web-hook failure callout has been dismissed', :freeze_time do
+ before do
+ create(:namespace_callout,
+ feature_name: described_class::WEB_HOOK_DISABLED,
+ user: user,
+ namespace: project.namespace,
+ dismissed_at: 1.week.ago)
+ end
+
+ it 'is true' do
+ expect(helper).to be_web_hook_disabled_dismissed(project)
+ end
+
+ context 'when there was an older failure', :clean_gitlab_redis_shared_state do
+ let(:key) { "web_hooks:last_failure:project-#{project.id}" }
+
+ before do
+ Gitlab::Redis::SharedState.with { |r| r.set(key, 1.month.ago.iso8601) }
+ end
+
+ it 'is true' do
+ expect(helper).to be_web_hook_disabled_dismissed(project)
+ end
+ end
+
+ context 'when there has been a more recent failure', :clean_gitlab_redis_shared_state do
+ let(:key) { "web_hooks:last_failure:project-#{project.id}" }
+
+ before do
+ Gitlab::Redis::SharedState.with { |r| r.set(key, 1.day.ago.iso8601) }
+ end
+
+ it 'is false' do
+ expect(helper).not_to be_web_hook_disabled_dismissed(project)
+ end
+ end
+ end
+ end
+ end
end