diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-11-06 22:07:07 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-11-06 22:07:07 +1100 |
commit | 762959465c36d6ff119676353ba21bb56fd1609c (patch) | |
tree | 8966dbde5805b518797e20b0d749d5d238f18ac1 /spec/models/project_services | |
parent | a7439b4a90bf0401b60436991bbc9127ea5a6ae7 (diff) | |
download | gitlab-ce-762959465c36d6ff119676353ba21bb56fd1609c.tar.gz |
DRY specs, fix typos in docs
Diffstat (limited to 'spec/models/project_services')
-rw-r--r-- | spec/models/project_services/discord_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/models/project_services/hangouts_chat_service_spec.rb | 35 |
2 files changed, 24 insertions, 43 deletions
diff --git a/spec/models/project_services/discord_service_spec.rb b/spec/models/project_services/discord_service_spec.rb index 695fa96d9c1..99c2ada7ad8 100644 --- a/spec/models/project_services/discord_service_spec.rb +++ b/spec/models/project_services/discord_service_spec.rb @@ -43,20 +43,12 @@ describe DiscordService do WebMock.stub_request(:post, webhook_url) end - shared_examples "Discord service" do - it "calls Discord Webhooks API" do - subject.execute(sample_data) - - expect(WebMock).to have_requested(:post, webhook_url).with { |req| req.body =~ /\A{"content":.+}\Z/ }.once - end - end - context "with push events" do let(:sample_data) do Gitlab::DataBuilder::Push.build_sample(project, user) end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content it "specifies the webhook when it is configured" do expect(Discordrb::Webhooks::Client).to receive(:new).with(url: webhook_url).and_return(double(:discord_service).as_null_object) @@ -86,7 +78,7 @@ describe DiscordService do subject.notify_only_default_branch = false end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end end end @@ -99,7 +91,7 @@ describe DiscordService do service.hook_data(issue, "open") end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with merge events" do @@ -122,7 +114,7 @@ describe DiscordService do project.add_developer(user) end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with wiki page events" do @@ -137,7 +129,7 @@ describe DiscordService do let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: opts) } let(:sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, "create") } - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with note events" do @@ -152,7 +144,7 @@ describe DiscordService do note: "a comment on a commit") end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with merge request comment" do @@ -160,7 +152,7 @@ describe DiscordService do create(:note_on_merge_request, project: project, note: "merge request note") end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with issue comment" do @@ -168,7 +160,7 @@ describe DiscordService do create(:note_on_issue, project: project, note: "issue note") end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with snippet comment" do @@ -176,7 +168,7 @@ describe DiscordService do create(:note_on_project_snippet, project: project, note: "snippet note") end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end end @@ -191,7 +183,7 @@ describe DiscordService do context "with failed pipeline" do let(:status) { "failed" } - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end context "with succeeded pipeline" do @@ -210,7 +202,7 @@ describe DiscordService do subject.notify_only_broken_pipelines = false end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end end @@ -236,7 +228,7 @@ describe DiscordService do subject.notify_only_default_branch = false end - it_behaves_like "Discord service" + it_behaves_like "Interacts with external service", "Discord", content_key: :content end end end diff --git a/spec/models/project_services/hangouts_chat_service_spec.rb b/spec/models/project_services/hangouts_chat_service_spec.rb index cfa55188a64..3557f62fde2 100644 --- a/spec/models/project_services/hangouts_chat_service_spec.rb +++ b/spec/models/project_services/hangouts_chat_service_spec.rb @@ -41,23 +41,12 @@ describe HangoutsChatService do WebMock.stub_request(:post, webhook_url) end - shared_examples 'Hangouts Chat service' do - it 'calls Hangouts Chat API' do - subject.execute(sample_data) - - expect(WebMock) - .to have_requested(:post, webhook_url) - .with { |req| req.body =~ /\A{"text":.+}\Z/ } - .once - end - end - context 'with push events' do let(:sample_data) do Gitlab::DataBuilder::Push.build_sample(project, user) end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text it 'specifies the webhook when it is configured' do expect(HangoutsChat::Sender).to receive(:new).with(webhook_url).and_return(double(:hangouts_chat_service).as_null_object) @@ -87,7 +76,7 @@ describe HangoutsChatService do subject.notify_only_default_branch = false end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end end end @@ -100,7 +89,7 @@ describe HangoutsChatService do service.hook_data(issue, 'open') end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with merge events' do @@ -123,7 +112,7 @@ describe HangoutsChatService do project.add_developer(user) end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with wiki page events' do @@ -138,7 +127,7 @@ describe HangoutsChatService do let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: opts) } let(:sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') } - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with note events' do @@ -152,7 +141,7 @@ describe HangoutsChatService do note: 'a comment on a commit') end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with merge request comment' do @@ -161,7 +150,7 @@ describe HangoutsChatService do note: 'merge request note') end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with issue comment' do @@ -169,7 +158,7 @@ describe HangoutsChatService do create(:note_on_issue, project: project, note: 'issue note') end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with snippet comment' do @@ -178,7 +167,7 @@ describe HangoutsChatService do note: 'snippet note') end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end end @@ -193,7 +182,7 @@ describe HangoutsChatService do context 'with failed pipeline' do let(:status) { 'failed' } - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end context 'with succeeded pipeline' do @@ -212,7 +201,7 @@ describe HangoutsChatService do subject.notify_only_broken_pipelines = false end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end end @@ -238,7 +227,7 @@ describe HangoutsChatService do subject.notify_only_default_branch = false end - it_behaves_like 'Hangouts Chat service' + it_behaves_like "Interacts with external service", "Hangouts Chat", content_key: :text end end end |