Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 15:08:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 15:08:18 +0300
commitd00cd98a2b1b3f0899677f61257821c94cde8e31 (patch)
tree602dc6d5ca71906ff282d87808c0c1d04b853aeb /spec/models
parentedf0e5b64384499283b406f9087e890ac4fad13f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/integrations/asana_spec.rb14
-rw-r--r--spec/models/integrations/assembla_spec.rb39
-rw-r--r--spec/models/integrations/bamboo_spec.rb19
-rw-r--r--spec/models/integrations/base_chat_notification_spec.rb8
-rw-r--r--spec/models/integrations/base_issue_tracker_spec.rb6
-rw-r--r--spec/models/integrations/base_slack_notification_spec.rb2
-rw-r--r--spec/models/integrations/base_third_party_wiki_spec.rb6
-rw-r--r--spec/models/integrations/bugzilla_spec.rb2
-rw-r--r--spec/models/integrations/buildkite_spec.rb10
-rw-r--r--spec/models/integrations/confluence_spec.rb9
-rw-r--r--spec/models/integrations/custom_issue_tracker_spec.rb2
11 files changed, 61 insertions, 56 deletions
diff --git a/spec/models/integrations/asana_spec.rb b/spec/models/integrations/asana_spec.rb
index 43e876a4f47..376aec1088e 100644
--- a/spec/models/integrations/asana_spec.rb
+++ b/spec/models/integrations/asana_spec.rb
@@ -2,20 +2,24 @@
require 'spec_helper'
-RSpec.describe Integrations::Asana do
+RSpec.describe Integrations::Asana, feature_category: :integrations do
describe 'Validations' do
- context 'active' do
+ context 'when active' do
before do
subject.active = true
end
it { is_expected.to validate_presence_of :api_key }
end
+
+ context 'when inactive' do
+ it { is_expected.not_to validate_presence_of :api_key }
+ end
end
- describe 'Execute' do
- let_it_be(:user) { create(:user) }
- let_it_be(:project) { create(:project) }
+ describe '#execute' do
+ let_it_be(:user) { build(:user) }
+ let_it_be(:project) { build(:project) }
let(:gid) { "123456789ABCD" }
let(:asana_task) { double(::Asana::Resources::Task) }
diff --git a/spec/models/integrations/assembla_spec.rb b/spec/models/integrations/assembla_spec.rb
index e9f4274952d..28cda0a1e75 100644
--- a/spec/models/integrations/assembla_spec.rb
+++ b/spec/models/integrations/assembla_spec.rb
@@ -2,34 +2,49 @@
require 'spec_helper'
-RSpec.describe Integrations::Assembla do
+RSpec.describe Integrations::Assembla, feature_category: :integrations do
include StubRequests
it_behaves_like Integrations::ResetSecretFields do
let(:integration) { described_class.new }
end
- describe "Execute" do
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository) }
+ describe 'Validations' do
+ context 'when active' do
+ before do
+ subject.active = true
+ end
+
+ it { is_expected.to validate_presence_of :token }
+ end
+
+ context 'when inactive' do
+ it { is_expected.not_to validate_presence_of :token }
+ end
+ end
+
+ describe "#execute" do
+ let_it_be(:user) { build(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+
+ let(:assembla_integration) { described_class.new }
+ let(:sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
+ let(:api_url) { 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret' }
before do
- @assembla_integration = described_class.new
- allow(@assembla_integration).to receive_messages(
+ allow(assembla_integration).to receive_messages(
project_id: project.id,
project: project,
token: 'verySecret',
subdomain: 'project_name'
)
- @sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
- @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret'
- stub_full_request(@api_url, method: :post)
+ stub_full_request(api_url, method: :post)
end
it "calls Assembla API" do
- @assembla_integration.execute(@sample_data)
- expect(WebMock).to have_requested(:post, stubbed_hostname(@api_url)).with(
- body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
+ assembla_integration.execute(sample_data)
+ expect(WebMock).to have_requested(:post, stubbed_hostname(api_url)).with(
+ body: /#{sample_data[:before]}.*#{sample_data[:after]}.*#{project.path}/
).once
end
end
diff --git a/spec/models/integrations/bamboo_spec.rb b/spec/models/integrations/bamboo_spec.rb
index 1d2c90dad51..3b459ab9d5b 100644
--- a/spec/models/integrations/bamboo_spec.rb
+++ b/spec/models/integrations/bamboo_spec.rb
@@ -2,26 +2,15 @@
require 'spec_helper'
-RSpec.describe Integrations::Bamboo, :use_clean_rails_memory_store_caching do
+RSpec.describe Integrations::Bamboo, :use_clean_rails_memory_store_caching, feature_category: :integrations do
include ReactiveCachingHelpers
include StubRequests
let(:bamboo_url) { 'http://gitlab.com/bamboo' }
- let_it_be(:project) { create(:project) }
-
- subject(:integration) do
- described_class.create!(
- active: true,
- project: project,
- properties: {
- bamboo_url: bamboo_url,
- username: 'mic',
- password: 'password',
- build_key: 'foo'
- }
- )
- end
+ let_it_be(:project) { build(:project) }
+
+ subject(:integration) { build(:bamboo_integration, project: project, bamboo_url: bamboo_url) }
it_behaves_like Integrations::BaseCi
diff --git a/spec/models/integrations/base_chat_notification_spec.rb b/spec/models/integrations/base_chat_notification_spec.rb
index 13dd9e03ab1..675035095c5 100644
--- a/spec/models/integrations/base_chat_notification_spec.rb
+++ b/spec/models/integrations/base_chat_notification_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Integrations::BaseChatNotification, feature_category: :integratio
it { expect(subject.category).to eq(:chat) }
end
- describe 'validations' do
+ describe 'Validations' do
before do
subject.active = active
@@ -112,9 +112,9 @@ RSpec.describe Integrations::BaseChatNotification, feature_category: :integratio
end
context 'when the data object has a label' do
- let_it_be(:label) { create(:label, project: project, name: 'Bug') }
- let_it_be(:label_2) { create(:label, project: project, name: 'Community contribution') }
- let_it_be(:label_3) { create(:label, project: project, name: 'Backend') }
+ let_it_be(:label) { build(:label, project: project, name: 'Bug') }
+ let_it_be(:label_2) { build(:label, project: project, name: 'Community contribution') }
+ let_it_be(:label_3) { build(:label, project: project, name: 'Backend') }
let_it_be(:issue) { create(:labeled_issue, project: project, labels: [label, label_2, label_3]) }
let_it_be(:note) { create(:note, noteable: issue, project: project) }
diff --git a/spec/models/integrations/base_issue_tracker_spec.rb b/spec/models/integrations/base_issue_tracker_spec.rb
index e1a764cd7cb..1bb24876222 100644
--- a/spec/models/integrations/base_issue_tracker_spec.rb
+++ b/spec/models/integrations/base_issue_tracker_spec.rb
@@ -2,10 +2,10 @@
require 'spec_helper'
-RSpec.describe Integrations::BaseIssueTracker do
- let(:integration) { Integrations::Redmine.new(project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }
+RSpec.describe Integrations::BaseIssueTracker, feature_category: :integrations do
+ let(:integration) { build(:redmine_integration, project: project, active: true, issue_tracker_data: build(:issue_tracker_data)) }
- let_it_be_with_refind(:project) { create :project }
+ let_it_be_with_refind(:project) { create(:project) }
describe 'default values' do
it { expect(subject.category).to eq(:issue_tracker) }
diff --git a/spec/models/integrations/base_slack_notification_spec.rb b/spec/models/integrations/base_slack_notification_spec.rb
index 8f7f4e8858d..ab977ca8fcc 100644
--- a/spec/models/integrations/base_slack_notification_spec.rb
+++ b/spec/models/integrations/base_slack_notification_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::BaseSlackNotification do
+RSpec.describe Integrations::BaseSlackNotification, feature_category: :integrations do
# This spec should only contain tests that cannot be tested through
# `base_slack_notification_shared_examples.rb`.
diff --git a/spec/models/integrations/base_third_party_wiki_spec.rb b/spec/models/integrations/base_third_party_wiki_spec.rb
index dbead636cb9..763f7131b94 100644
--- a/spec/models/integrations/base_third_party_wiki_spec.rb
+++ b/spec/models/integrations/base_third_party_wiki_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::BaseThirdPartyWiki do
+RSpec.describe Integrations::BaseThirdPartyWiki, feature_category: :integrations do
describe 'default values' do
it { expect(subject.category).to eq(:third_party_wiki) }
end
@@ -11,7 +11,7 @@ RSpec.describe Integrations::BaseThirdPartyWiki do
let_it_be_with_reload(:project) { create(:project) }
describe 'only one third party wiki per project' do
- subject(:integration) { create(:shimo_integration, project: project, active: true) }
+ subject(:integration) { build(:shimo_integration, project: project, active: true) }
before_all do
create(:confluence_integration, project: project, active: true)
@@ -35,7 +35,7 @@ RSpec.describe Integrations::BaseThirdPartyWiki do
end
context 'when integration is not on the project level' do
- subject(:integration) { create(:shimo_integration, :instance, active: true) }
+ subject(:integration) { build(:shimo_integration, :instance, active: true) }
it 'executes the validation' do
expect(integration.valid?(:manual_change)).to be_truthy
diff --git a/spec/models/integrations/bugzilla_spec.rb b/spec/models/integrations/bugzilla_spec.rb
index f05bc26d066..cef58589231 100644
--- a/spec/models/integrations/bugzilla_spec.rb
+++ b/spec/models/integrations/bugzilla_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::Bugzilla do
+RSpec.describe Integrations::Bugzilla, feature_category: :integrations do
describe 'Validations' do
context 'when integration is active' do
before do
diff --git a/spec/models/integrations/buildkite_spec.rb b/spec/models/integrations/buildkite_spec.rb
index 29c649af6c6..f3231d50eae 100644
--- a/spec/models/integrations/buildkite_spec.rb
+++ b/spec/models/integrations/buildkite_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
+RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching, feature_category: :integrations do
include ReactiveCachingHelpers
include StubRequests
@@ -71,9 +71,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
describe '#hook_url' do
it 'returns the webhook url' do
- expect(integration.hook_url).to eq(
- 'https://webhook.buildkite.com/deliver/{webhook_token}'
- )
+ expect(integration.hook_url).to eq('https://webhook.buildkite.com/deliver/{webhook_token}')
end
end
@@ -103,9 +101,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
describe '#calculate_reactive_cache' do
describe '#commit_status' do
- let(:buildkite_full_url) do
- 'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=123'
- end
+ let(:buildkite_full_url) { 'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=123' }
subject { integration.calculate_reactive_cache('123', 'unused')[:commit_status] }
diff --git a/spec/models/integrations/confluence_spec.rb b/spec/models/integrations/confluence_spec.rb
index 999a532527d..d267e4a71c2 100644
--- a/spec/models/integrations/confluence_spec.rb
+++ b/spec/models/integrations/confluence_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::Confluence do
+RSpec.describe Integrations::Confluence, feature_category: :integrations do
let_it_be(:project) { create(:project) }
describe 'Validations' do
@@ -49,10 +49,11 @@ RSpec.describe Integrations::Confluence do
end
context 'when the project wiki is not enabled' do
- it 'returns nil when both active or inactive', :aggregate_failures do
- project = create(:project, :wiki_disabled)
- subject.project = project
+ before do
+ allow(project).to receive(:wiki_enabled?).and_return(false)
+ end
+ it 'returns nil when both active or inactive', :aggregate_failures do
[true, false].each do |active|
subject.active = active
diff --git a/spec/models/integrations/custom_issue_tracker_spec.rb b/spec/models/integrations/custom_issue_tracker_spec.rb
index 11f98b99bbe..4be95a25a43 100644
--- a/spec/models/integrations/custom_issue_tracker_spec.rb
+++ b/spec/models/integrations/custom_issue_tracker_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::CustomIssueTracker do
+RSpec.describe Integrations::CustomIssueTracker, feature_category: :integrations do
describe 'Validations' do
context 'when integration is active' do
before do