diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-15 21:11:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-15 21:11:32 +0000 |
commit | 1c898dc5c10bbedf94386d917259153d73608495 (patch) | |
tree | f939cf185da9e96f7aba2200fa5ac74deffd71f9 /spec/views | |
parent | 22baaecaa84003c554f35752a729331e956d7659 (diff) | |
download | gitlab-ce-1c898dc5c10bbedf94386d917259153d73608495.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/hooks/edit.html.haml_spec.rb | 33 | ||||
-rw-r--r-- | spec/views/projects/hooks/index.html.haml_spec.rb | 36 |
2 files changed, 69 insertions, 0 deletions
diff --git a/spec/views/projects/hooks/edit.html.haml_spec.rb b/spec/views/projects/hooks/edit.html.haml_spec.rb new file mode 100644 index 00000000000..1265334a572 --- /dev/null +++ b/spec/views/projects/hooks/edit.html.haml_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/hooks/edit' do + let(:hook) { create(:project_hook, project: project) } + + let_it_be_with_refind(:project) { create(:project) } + + before do + assign :project, project + assign :hook, hook + end + + it 'renders webhook page with "Recent events"' do + render + + expect(rendered).to have_css('h4', text: _('Webhook')) + expect(rendered).to have_text(_('Recent events')) + end + + context 'webhook is rate limited' do + before do + allow(hook).to receive(:rate_limited?).and_return(true) + end + + it 'renders alert' do + render + + expect(rendered).to have_text(s_('Webhooks|Webhook was automatically disabled')) + end + end +end 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..eb2b7334b98 --- /dev/null +++ b/spec/views/projects/hooks/index.html.haml_spec.rb @@ -0,0 +1,36 @@ +# 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')) + 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 +end |