diff options
Diffstat (limited to 'spec/views/projects/hooks/index.html.haml_spec.rb')
-rw-r--r-- | spec/views/projects/hooks/index.html.haml_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/views/projects/hooks/index.html.haml_spec.rb b/spec/views/projects/hooks/index.html.haml_spec.rb new file mode 100644 index 00000000000..0cdc3bcecb2 --- /dev/null +++ b/spec/views/projects/hooks/index.html.haml_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/hooks/index' do + let(:existing_hook) { create(:project_hook, project: project) } + let(:new_hook) { ProjectHook.new } + + let_it_be_with_refind(:project) { create(:project) } + + before do + assign :project, project + assign :hooks, [existing_hook] + assign :hook, new_hook + end + + it 'renders webhooks page with "Project Hooks"' do + render + + expect(rendered).to have_css('h4', text: _('Webhooks')) + expect(rendered).to have_text('Project Hooks') + expect(rendered).not_to have_css('.gl-badge', text: _('Disabled')) + expect(rendered).not_to have_css('.gl-badge', text: s_('Webhooks|Failed to connect')) + expect(rendered).not_to have_css('.gl-badge', text: s_('Webhooks|Fails to connect')) + end + + context 'webhook is rate limited' do + before do + allow(existing_hook).to receive(:rate_limited?).and_return(true) + end + + it 'renders "Disabled" badge' do + render + + expect(rendered).to have_css('.gl-badge', text: _('Disabled')) + end + end + + context 'webhook is permanently disabled' do + before do + allow(existing_hook).to receive(:permanently_disabled?).and_return(true) + end + + it 'renders "Failed to connect" badge' do + render + + expect(rendered).to have_css('.gl-badge', text: s_('Webhooks|Failed to connect')) + end + end + + context 'webhook is temporarily disabled' do + before do + allow(existing_hook).to receive(:temporarily_disabled?).and_return(true) + end + + it 'renders "Fails to connect" badge' do + render + + expect(rendered).to have_css('.gl-badge', text: s_('Webhooks|Fails to connect')) + end + end +end |