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 Release Tools Bot <delivery-team+release-tools@gitlab.com>2022-01-11 23:54:59 +0300
committerGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2022-01-11 23:54:59 +0300
commit35e8389fe215c9d1dc27eda99fae0a3f0d8eb902 (patch)
treea22bf35a25cf42c235794dce6cfcc7901a092961 /spec/models/integrations/chat_message
parent15995667681000021c37b52f087084db9f3c6048 (diff)
parenta97774c8e1253b4291d085184c681834e3718eb9 (diff)
Merge remote-tracking branch 'dev/14-4-stable' into 14-4-stable14-4-stable
Diffstat (limited to 'spec/models/integrations/chat_message')
-rw-r--r--spec/models/integrations/chat_message/alert_message_spec.rb2
-rw-r--r--spec/models/integrations/chat_message/base_message_spec.rb18
-rw-r--r--spec/models/integrations/chat_message/deployment_message_spec.rb90
-rw-r--r--spec/models/integrations/chat_message/issue_message_spec.rb2
-rw-r--r--spec/models/integrations/chat_message/merge_message_spec.rb2
-rw-r--r--spec/models/integrations/chat_message/note_message_spec.rb15
-rw-r--r--spec/models/integrations/chat_message/pipeline_message_spec.rb2
-rw-r--r--spec/models/integrations/chat_message/push_message_spec.rb2
-rw-r--r--spec/models/integrations/chat_message/wiki_page_message_spec.rb2
9 files changed, 74 insertions, 61 deletions
diff --git a/spec/models/integrations/chat_message/alert_message_spec.rb b/spec/models/integrations/chat_message/alert_message_spec.rb
index 9866b2d9185..162df1a774c 100644
--- a/spec/models/integrations/chat_message/alert_message_spec.rb
+++ b/spec/models/integrations/chat_message/alert_message_spec.rb
@@ -16,6 +16,8 @@ RSpec.describe Integrations::ChatMessage::AlertMessage do
}.merge(Gitlab::DataBuilder::Alert.build(alert))
end
+ it_behaves_like Integrations::ChatMessage
+
describe '#message' do
it 'returns the correct message' do
expect(subject.message).to eq("Alert firing in #{args[:project_name]}")
diff --git a/spec/models/integrations/chat_message/base_message_spec.rb b/spec/models/integrations/chat_message/base_message_spec.rb
index eada5d1031d..0f0ab11f2ac 100644
--- a/spec/models/integrations/chat_message/base_message_spec.rb
+++ b/spec/models/integrations/chat_message/base_message_spec.rb
@@ -31,4 +31,22 @@ RSpec.describe Integrations::ChatMessage::BaseMessage do
it { is_expected.to eq('Check this out https://gitlab-domain.com/uploads/Screenshot1.png. And this https://gitlab-domain.com/uploads/Screenshot2.png') }
end
end
+
+ describe '#strip_markup' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:input, :output) do
+ nil | nil
+ '' | ''
+ '[label](url)' | 'label(url)'
+ '<url|label>' | 'urllabel'
+ '<a href="url">label</a>' | 'a href="url"label/a'
+ end
+
+ with_them do
+ it 'returns the expected output' do
+ expect(base_message.send(:strip_markup, input)).to eq(output)
+ end
+ end
+ end
end
diff --git a/spec/models/integrations/chat_message/deployment_message_spec.rb b/spec/models/integrations/chat_message/deployment_message_spec.rb
index ff255af11a3..6bcd29c0a00 100644
--- a/spec/models/integrations/chat_message/deployment_message_spec.rb
+++ b/spec/models/integrations/chat_message/deployment_message_spec.rb
@@ -3,83 +3,79 @@
require 'spec_helper'
RSpec.describe Integrations::ChatMessage::DeploymentMessage do
- describe '#pretext' do
- it 'returns a message with the data returned by the deployment data builder' do
- environment = create(:environment, name: "myenvironment")
- project = create(:project, :repository)
- commit = project.commit('HEAD')
- deployment = create(:deployment, status: :success, environment: environment, project: project, sha: commit.sha)
- data = Gitlab::DataBuilder::Deployment.build(deployment, Time.current)
+ subject { described_class.new(args) }
+
+ let_it_be(:user) { create(:user, name: 'John Smith', username: 'smith') }
+ let_it_be(:namespace) { create(:namespace, name: 'myspace') }
+ let_it_be(:project) { create(:project, :repository, namespace: namespace, name: 'myproject') }
+ let_it_be(:commit) { project.commit('HEAD') }
+ let_it_be(:ci_build) { create(:ci_build, project: project) }
+ let_it_be(:environment) { create(:environment, name: 'myenvironment', project: project) }
+ let_it_be(:deployment) { create(:deployment, status: :success, deployable: ci_build, environment: environment, project: project, user: user, sha: commit.sha) }
+
+ let(:args) do
+ Gitlab::DataBuilder::Deployment.build(deployment, Time.current)
+ end
- message = described_class.new(data)
+ it_behaves_like Integrations::ChatMessage
- expect(message.pretext).to eq("Deploy to myenvironment succeeded")
+ describe '#pretext' do
+ it 'returns a message with the data returned by the deployment data builder' do
+ expect(subject.pretext).to eq("Deploy to myenvironment succeeded")
end
it 'returns a message for a successful deployment' do
- data = {
+ args.merge!(
status: 'success',
environment: 'production'
- }
+ )
- message = described_class.new(data)
-
- expect(message.pretext).to eq('Deploy to production succeeded')
+ expect(subject.pretext).to eq('Deploy to production succeeded')
end
it 'returns a message for a failed deployment' do
- data = {
+ args.merge!(
status: 'failed',
environment: 'production'
- }
+ )
- message = described_class.new(data)
-
- expect(message.pretext).to eq('Deploy to production failed')
+ expect(subject.pretext).to eq('Deploy to production failed')
end
it 'returns a message for a canceled deployment' do
- data = {
+ args.merge!(
status: 'canceled',
environment: 'production'
- }
-
- message = described_class.new(data)
+ )
- expect(message.pretext).to eq('Deploy to production canceled')
+ expect(subject.pretext).to eq('Deploy to production canceled')
end
it 'returns a message for a deployment to another environment' do
- data = {
+ args.merge!(
status: 'success',
environment: 'staging'
- }
-
- message = described_class.new(data)
+ )
- expect(message.pretext).to eq('Deploy to staging succeeded')
+ expect(subject.pretext).to eq('Deploy to staging succeeded')
end
it 'returns a message for a deployment with any other status' do
- data = {
+ args.merge!(
status: 'unknown',
environment: 'staging'
- }
+ )
- message = described_class.new(data)
-
- expect(message.pretext).to eq('Deploy to staging unknown')
+ expect(subject.pretext).to eq('Deploy to staging unknown')
end
it 'returns a message for a running deployment' do
- data = {
- status: 'running',
- environment: 'production'
- }
-
- message = described_class.new(data)
+ args.merge!(
+ status: 'running',
+ environment: 'production'
+ )
- expect(message.pretext).to eq('Starting deploy to production')
+ expect(subject.pretext).to eq('Starting deploy to production')
end
end
@@ -108,21 +104,11 @@ RSpec.describe Integrations::ChatMessage::DeploymentMessage do
end
it 'returns attachments with the data returned by the deployment data builder' do
- user = create(:user, name: "John Smith", username: "smith")
- namespace = create(:namespace, name: "myspace")
- project = create(:project, :repository, namespace: namespace, name: "myproject")
- commit = project.commit('HEAD')
- environment = create(:environment, name: "myenvironment", project: project)
- ci_build = create(:ci_build, project: project)
- deployment = create(:deployment, :success, deployable: ci_build, environment: environment, project: project, user: user, sha: commit.sha)
job_url = Gitlab::Routing.url_helpers.project_job_url(project, ci_build)
commit_url = Gitlab::UrlBuilder.build(deployment.commit)
user_url = Gitlab::Routing.url_helpers.user_url(user)
- data = Gitlab::DataBuilder::Deployment.build(deployment, Time.current)
- message = described_class.new(data)
-
- expect(message.attachments).to eq([{
+ expect(subject.attachments).to eq([{
text: "[myspace/myproject](#{project.web_url}) with job [##{ci_build.id}](#{job_url}) by [John Smith (smith)](#{user_url})\n[#{deployment.short_sha}](#{commit_url}): #{commit.title}",
color: "good"
}])
diff --git a/spec/models/integrations/chat_message/issue_message_spec.rb b/spec/models/integrations/chat_message/issue_message_spec.rb
index 31b80ad3169..7026a314b78 100644
--- a/spec/models/integrations/chat_message/issue_message_spec.rb
+++ b/spec/models/integrations/chat_message/issue_message_spec.rb
@@ -28,6 +28,8 @@ RSpec.describe Integrations::ChatMessage::IssueMessage do
}
end
+ it_behaves_like Integrations::ChatMessage
+
context 'without markdown' do
let(:color) { '#C95823' }
diff --git a/spec/models/integrations/chat_message/merge_message_spec.rb b/spec/models/integrations/chat_message/merge_message_spec.rb
index ed1ad6837e2..52f15667b03 100644
--- a/spec/models/integrations/chat_message/merge_message_spec.rb
+++ b/spec/models/integrations/chat_message/merge_message_spec.rb
@@ -29,6 +29,8 @@ RSpec.describe Integrations::ChatMessage::MergeMessage do
}
end
+ it_behaves_like Integrations::ChatMessage
+
context 'without markdown' do
let(:color) { '#345' }
diff --git a/spec/models/integrations/chat_message/note_message_spec.rb b/spec/models/integrations/chat_message/note_message_spec.rb
index 668c0da26ae..197df216814 100644
--- a/spec/models/integrations/chat_message/note_message_spec.rb
+++ b/spec/models/integrations/chat_message/note_message_spec.rb
@@ -19,6 +19,10 @@ RSpec.describe Integrations::ChatMessage::NoteMessage do
name: 'project_name',
url: 'http://somewhere.com'
},
+ commit: {
+ id: '5f163b2b95e6f53cbd428f5f0b103702a52b9a23',
+ message: "Added a commit message\ndetails\n123\n"
+ },
object_attributes: {
id: 10,
note: 'comment on a commit',
@@ -28,16 +32,9 @@ RSpec.describe Integrations::ChatMessage::NoteMessage do
}
end
- context 'commit notes' do
- before do
- args[:object_attributes][:note] = 'comment on a commit'
- args[:object_attributes][:noteable_type] = 'Commit'
- args[:commit] = {
- id: '5f163b2b95e6f53cbd428f5f0b103702a52b9a23',
- message: "Added a commit message\ndetails\n123\n"
- }
- end
+ it_behaves_like Integrations::ChatMessage
+ context 'commit notes' do
context 'without markdown' do
it 'returns a message regarding notes on commits' do
expect(subject.pretext).to eq("Test User (test.user) <http://url.com|commented on " \
diff --git a/spec/models/integrations/chat_message/pipeline_message_spec.rb b/spec/models/integrations/chat_message/pipeline_message_spec.rb
index a80d13d7f5d..68ef0ccb2e4 100644
--- a/spec/models/integrations/chat_message/pipeline_message_spec.rb
+++ b/spec/models/integrations/chat_message/pipeline_message_spec.rb
@@ -40,6 +40,8 @@ RSpec.describe Integrations::ChatMessage::PipelineMessage do
let(:has_yaml_errors) { false }
+ it_behaves_like Integrations::ChatMessage
+
before do
test_commit = double("A test commit", committer: args[:user], title: "A test commit message")
test_project = double("A test project", commit_by: test_commit, name: args[:project][:name], web_url: args[:project][:web_url])
diff --git a/spec/models/integrations/chat_message/push_message_spec.rb b/spec/models/integrations/chat_message/push_message_spec.rb
index 167487449c3..8d2d0f9f9a8 100644
--- a/spec/models/integrations/chat_message/push_message_spec.rb
+++ b/spec/models/integrations/chat_message/push_message_spec.rb
@@ -19,6 +19,8 @@ RSpec.describe Integrations::ChatMessage::PushMessage do
let(:color) { '#345' }
+ it_behaves_like Integrations::ChatMessage
+
context 'push' do
before do
args[:commits] = [
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 ded467dc910..4aa96c7e031 100644
--- a/spec/models/integrations/chat_message/wiki_page_message_spec.rb
+++ b/spec/models/integrations/chat_message/wiki_page_message_spec.rb
@@ -33,6 +33,8 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do
}
end
+ it_behaves_like Integrations::ChatMessage
+
context 'without markdown' do
describe '#pretext' do
context 'when :action == "create"' do