diff options
Diffstat (limited to 'spec/models/integrations')
-rw-r--r-- | spec/models/integrations/bamboo_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/bugzilla_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/buildkite_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/campfire_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/integrations/chat_message/issue_message_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/integrations/chat_message/wiki_page_message_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/integrations/custom_issue_tracker_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/datadog_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/integrations/drone_ci_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/ewm_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/external_wiki_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/harbor_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/integrations/jira_spec.rb | 22 | ||||
-rw-r--r-- | spec/models/integrations/microsoft_teams_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/integrations/pumble_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/integrations/slack_spec.rb | 17 | ||||
-rw-r--r-- | spec/models/integrations/teamcity_spec.rb | 1 |
17 files changed, 66 insertions, 24 deletions
diff --git a/spec/models/integrations/bamboo_spec.rb b/spec/models/integrations/bamboo_spec.rb index 574b87d6c60..e92226d109f 100644 --- a/spec/models/integrations/bamboo_spec.rb +++ b/spec/models/integrations/bamboo_spec.rb @@ -33,6 +33,7 @@ RSpec.describe Integrations::Bamboo, :use_clean_rails_memory_store_caching do it { is_expected.to validate_presence_of(:build_key) } it { is_expected.to validate_presence_of(:bamboo_url) } + it_behaves_like 'issue tracker integration URL attribute', :bamboo_url describe '#username' do diff --git a/spec/models/integrations/bugzilla_spec.rb b/spec/models/integrations/bugzilla_spec.rb index 432306c8fa8..f05bc26d066 100644 --- a/spec/models/integrations/bugzilla_spec.rb +++ b/spec/models/integrations/bugzilla_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Integrations::Bugzilla do it { is_expected.to validate_presence_of(:project_url) } it { is_expected.to validate_presence_of(:issues_url) } it { is_expected.to validate_presence_of(:new_issue_url) } + it_behaves_like 'issue tracker integration URL attribute', :project_url it_behaves_like 'issue tracker integration URL attribute', :issues_url it_behaves_like 'issue tracker integration URL attribute', :new_issue_url diff --git a/spec/models/integrations/buildkite_spec.rb b/spec/models/integrations/buildkite_spec.rb index af2e587dc7b..38ceb5db49c 100644 --- a/spec/models/integrations/buildkite_spec.rb +++ b/spec/models/integrations/buildkite_spec.rb @@ -30,6 +30,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do it { is_expected.to validate_presence_of(:project_url) } it { is_expected.to validate_presence_of(:token) } + it_behaves_like 'issue tracker integration URL attribute', :project_url end diff --git a/spec/models/integrations/campfire_spec.rb b/spec/models/integrations/campfire_spec.rb index 48e24299bbd..a6bcd22b6f6 100644 --- a/spec/models/integrations/campfire_spec.rb +++ b/spec/models/integrations/campfire_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Integrations::Campfire do describe 'Validations' do it { is_expected.to validate_numericality_of(:room).is_greater_than(0).only_integer } - it { is_expected.to validate_length_of(:subdomain).is_at_most(63) } + it { is_expected.to validate_length_of(:subdomain).is_at_least(1).is_at_most(63).allow_blank } it { is_expected.to allow_value("foo").for(:subdomain) } it { is_expected.not_to allow_value("foo.bar").for(:subdomain) } it { is_expected.not_to allow_value("foo.bar/#").for(:subdomain) } diff --git a/spec/models/integrations/chat_message/issue_message_spec.rb b/spec/models/integrations/chat_message/issue_message_spec.rb index 7026a314b78..4a86322cdaf 100644 --- a/spec/models/integrations/chat_message/issue_message_spec.rb +++ b/spec/models/integrations/chat_message/issue_message_spec.rb @@ -65,7 +65,7 @@ RSpec.describe Integrations::ChatMessage::IssueMessage do end it 'returns a message regarding closing of issues' do - expect(subject.pretext). to eq( + expect(subject.pretext).to eq( '[<http://somewhere.com|project_name>] Issue <http://url.com|#100 Issue title> closed by Test User (test.user)') expect(subject.attachments).to be_empty end @@ -111,7 +111,7 @@ RSpec.describe Integrations::ChatMessage::IssueMessage do end it 'returns a message regarding closing of issues' do - expect(subject.pretext). to eq( + expect(subject.pretext).to eq( '[[project_name](http://somewhere.com)] Issue [#100 Issue title](http://url.com) closed by Test User (test.user)') expect(subject.attachments).to be_empty expect(subject.activity).to eq({ diff --git a/spec/models/integrations/chat_message/wiki_page_message_spec.rb b/spec/models/integrations/chat_message/wiki_page_message_spec.rb index 4aa96c7e031..16659311c52 100644 --- a/spec/models/integrations/chat_message/wiki_page_message_spec.rb +++ b/spec/models/integrations/chat_message/wiki_page_message_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do let(:username) { 'test.user' } let(:avatar_url) { 'http://someavatar.com' } let(:project_name) { 'project_name' } - let(:project_url) {'http://somewhere.com' } + let(:project_url) { 'http://somewhere.com' } let(:url) { 'http://url.com' } let(:diff_url) { 'http://url.com/diff?version_id=1234' } let(:wiki_page_title) { 'Wiki page title' } diff --git a/spec/models/integrations/custom_issue_tracker_spec.rb b/spec/models/integrations/custom_issue_tracker_spec.rb index e1ffe7a74f0..11f98b99bbe 100644 --- a/spec/models/integrations/custom_issue_tracker_spec.rb +++ b/spec/models/integrations/custom_issue_tracker_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Integrations::CustomIssueTracker do it { is_expected.to validate_presence_of(:project_url) } it { is_expected.to validate_presence_of(:issues_url) } it { is_expected.to validate_presence_of(:new_issue_url) } + it_behaves_like 'issue tracker integration URL attribute', :project_url it_behaves_like 'issue tracker integration URL attribute', :issues_url it_behaves_like 'issue tracker integration URL attribute', :new_issue_url diff --git a/spec/models/integrations/datadog_spec.rb b/spec/models/integrations/datadog_spec.rb index 47f916e8457..cfc44b22a84 100644 --- a/spec/models/integrations/datadog_spec.rb +++ b/spec/models/integrations/datadog_spec.rb @@ -240,20 +240,4 @@ RSpec.describe Integrations::Datadog do end end end - - describe '#fields' do - it 'includes the archive_trace_events field' do - expect(instance.fields).to include(have_attributes(name: 'archive_trace_events')) - end - - context 'when the FF :datadog_integration_logs_collection is disabled' do - before do - stub_feature_flags(datadog_integration_logs_collection: false) - end - - it 'does not include the archive_trace_events field' do - expect(instance.fields).not_to include(have_attributes(name: 'archive_trace_events')) - end - end - end end diff --git a/spec/models/integrations/drone_ci_spec.rb b/spec/models/integrations/drone_ci_spec.rb index 5ae4af1a665..8a51f8a0705 100644 --- a/spec/models/integrations/drone_ci_spec.rb +++ b/spec/models/integrations/drone_ci_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do it { is_expected.to validate_presence_of(:token) } it { is_expected.to validate_presence_of(:drone_url) } + it_behaves_like 'issue tracker integration URL attribute', :drone_url end diff --git a/spec/models/integrations/ewm_spec.rb b/spec/models/integrations/ewm_spec.rb index 49681fefe55..dc48a2c982f 100644 --- a/spec/models/integrations/ewm_spec.rb +++ b/spec/models/integrations/ewm_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Integrations::Ewm do it { is_expected.to validate_presence_of(:project_url) } it { is_expected.to validate_presence_of(:issues_url) } it { is_expected.to validate_presence_of(:new_issue_url) } + it_behaves_like 'issue tracker integration URL attribute', :project_url it_behaves_like 'issue tracker integration URL attribute', :issues_url it_behaves_like 'issue tracker integration URL attribute', :new_issue_url diff --git a/spec/models/integrations/external_wiki_spec.rb b/spec/models/integrations/external_wiki_spec.rb index 1621605d39f..8644e20690c 100644 --- a/spec/models/integrations/external_wiki_spec.rb +++ b/spec/models/integrations/external_wiki_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Integrations::ExternalWiki do end it { is_expected.to validate_presence_of(:external_wiki_url) } + it_behaves_like 'issue tracker integration URL attribute', :external_wiki_url end diff --git a/spec/models/integrations/harbor_spec.rb b/spec/models/integrations/harbor_spec.rb index 5d8597969a1..3952495119a 100644 --- a/spec/models/integrations/harbor_spec.rb +++ b/spec/models/integrations/harbor_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Integrations::Harbor do it { is_expected.not_to allow_value('https://192.168.1.1').for(:url) } it { is_expected.not_to allow_value('https://127.0.0.1').for(:url) } - it { is_expected.to allow_value('https://demo.goharbor.io').for(:url)} + it { is_expected.to allow_value('https://demo.goharbor.io').for(:url) } end describe '#fields' do @@ -63,6 +63,8 @@ RSpec.describe Integrations::Harbor do it 'returns vars when harbor_integration is activated' do ci_vars = [ { key: 'HARBOR_URL', value: url }, + { key: 'HARBOR_HOST', value: 'demo.goharbor.io' }, + { key: 'HARBOR_OCI', value: 'oci://demo.goharbor.io' }, { key: 'HARBOR_PROJECT', value: project_name }, { key: 'HARBOR_USERNAME', value: username }, { key: 'HARBOR_PASSWORD', value: password, public: false, masked: true } diff --git a/spec/models/integrations/jira_spec.rb b/spec/models/integrations/jira_spec.rb index 01c08a0948f..a52a4514ebe 100644 --- a/spec/models/integrations/jira_spec.rb +++ b/spec/models/integrations/jira_spec.rb @@ -619,6 +619,18 @@ RSpec.describe Integrations::Jira do close_issue end + it_behaves_like 'Snowplow event tracking' do + subject { close_issue } + + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + let(:category) { 'Integrations::Jira' } + let(:action) { 'perform_integrations_action' } + let(:namespace) { project.namespace } + let(:user) { current_user } + let(:label) { 'redis_hll_counters.ecosystem.ecosystem_total_unique_counts_monthly' } + let(:property) { 'i_ecosystem_jira_service_close_issue' } + end + it 'does not fail if remote_link.all on issue returns nil' do allow(JIRA::Resource::Remotelink).to receive(:all).and_return(nil) @@ -962,6 +974,16 @@ RSpec.describe Integrations::Jira do subject end + + it_behaves_like 'Snowplow event tracking' do + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + let(:category) { 'Integrations::Jira' } + let(:action) { 'perform_integrations_action' } + let(:namespace) { project.namespace } + let(:user) { current_user } + let(:label) { 'redis_hll_counters.ecosystem.ecosystem_total_unique_counts_monthly' } + let(:property) { 'i_ecosystem_jira_service_cross_reference' } + end end context 'for commits' do diff --git a/spec/models/integrations/microsoft_teams_spec.rb b/spec/models/integrations/microsoft_teams_spec.rb index af6c142525c..b1b3e42b5e9 100644 --- a/spec/models/integrations/microsoft_teams_spec.rb +++ b/spec/models/integrations/microsoft_teams_spec.rb @@ -24,6 +24,7 @@ RSpec.describe Integrations::MicrosoftTeams do end it { is_expected.to validate_presence_of(:webhook) } + it_behaves_like 'issue tracker integration URL attribute', :webhook end diff --git a/spec/models/integrations/pumble_spec.rb b/spec/models/integrations/pumble_spec.rb new file mode 100644 index 00000000000..8b9b5d214c6 --- /dev/null +++ b/spec/models/integrations/pumble_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Integrations::Pumble do + it_behaves_like "chat integration", "Pumble" do + let(:client_arguments) { webhook_url } + let(:payload) do + { + text: be_present + } + end + end +end diff --git a/spec/models/integrations/slack_spec.rb b/spec/models/integrations/slack_spec.rb index 5801a4c3749..ed282f1d39d 100644 --- a/spec/models/integrations/slack_spec.rb +++ b/spec/models/integrations/slack_spec.rb @@ -6,7 +6,8 @@ RSpec.describe Integrations::Slack do it_behaves_like Integrations::SlackMattermostNotifier, "Slack" describe '#execute' do - let_it_be(:slack_integration) { create(:integrations_slack, branches_to_be_notified: 'all') } + let(:slack_integration) { create(:integrations_slack, branches_to_be_notified: 'all', project_id: project.id) } + let(:project) { create_default(:project, :repository, :wiki_repo) } before do stub_request(:post, slack_integration.webhook) @@ -20,13 +21,23 @@ RSpec.describe Integrations::Slack do context 'hook data includes a user object' do let_it_be(:user) { create_default(:user) } - let_it_be(:project) { create_default(:project, :repository, :wiki_repo) } shared_examples 'increases the usage data counter' do |event_name| + subject(:execute) { slack_integration.execute(data) } + it 'increases the usage data counter' do expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: user.id).and_call_original - slack_integration.execute(data) + execute + end + + it_behaves_like 'Snowplow event tracking' do + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + let(:category) { 'Integrations::Slack' } + let(:action) { 'perform_integrations_action' } + let(:namespace) { project.namespace } + let(:label) { 'redis_hll_counters.ecosystem.ecosystem_total_unique_counts_monthly' } + let(:property) { event_name } end end diff --git a/spec/models/integrations/teamcity_spec.rb b/spec/models/integrations/teamcity_spec.rb index 046476225a6..da559264c1e 100644 --- a/spec/models/integrations/teamcity_spec.rb +++ b/spec/models/integrations/teamcity_spec.rb @@ -76,6 +76,7 @@ RSpec.describe Integrations::Teamcity, :use_clean_rails_memory_store_caching do it { is_expected.to validate_presence_of(:build_type) } it { is_expected.to validate_presence_of(:teamcity_url) } + it_behaves_like 'issue tracker integration URL attribute', :teamcity_url describe '#username' do |