From 7696191e330337ab5fac207bf24aa13d211a0ded Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Tue, 18 Apr 2017 10:50:04 +0100 Subject: disables test settings on chat notification services when repository is empty --- .../project_services/chat_notification_service.rb | 2 +- ...settings-on-services-when-repository-is-empty.yml | 4 ++++ .../chat_notification_service_spec.rb | 20 +++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/31009-disable-test-settings-on-services-when-repository-is-empty.yml diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb index fa782c6fbb7..f2dfb87dbda 100644 --- a/app/models/project_services/chat_notification_service.rb +++ b/app/models/project_services/chat_notification_service.rb @@ -22,7 +22,7 @@ class ChatNotificationService < Service end def can_test? - valid? + super && valid? end def self.supported_events diff --git a/changelogs/unreleased/31009-disable-test-settings-on-services-when-repository-is-empty.yml b/changelogs/unreleased/31009-disable-test-settings-on-services-when-repository-is-empty.yml new file mode 100644 index 00000000000..6e43a032f20 --- /dev/null +++ b/changelogs/unreleased/31009-disable-test-settings-on-services-when-repository-is-empty.yml @@ -0,0 +1,4 @@ +--- +title: Disable test settings on chat notification services when repository is empty +merge_request: 10759 +author: diff --git a/spec/models/project_services/chat_notification_service_spec.rb b/spec/models/project_services/chat_notification_service_spec.rb index c98e7ee14fd..592c90cda36 100644 --- a/spec/models/project_services/chat_notification_service_spec.rb +++ b/spec/models/project_services/chat_notification_service_spec.rb @@ -1,11 +1,29 @@ require 'spec_helper' describe ChatNotificationService, models: true do - describe "Associations" do + describe 'Associations' do before do allow(subject).to receive(:activated?).and_return(true) end it { is_expected.to validate_presence_of :webhook } end + + describe '#can_test?' do + context 'with empty repository' do + it 'returns false' do + subject.project = create(:empty_project, :empty_repo) + + expect(subject.can_test?).to be false + end + end + + context 'with repository' do + it 'returns true' do + subject.project = create(:project) + + expect(subject.can_test?).to be true + end + end + end end -- cgit v1.2.1