summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-16 15:08:10 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-16 17:51:09 +0100
commit0f2776287a7d9b0fde9ff54ef8d9f74e2f844a09 (patch)
treeb619ec2d6758f11fd3bb6ccc682688409e61d436 /spec
parentf9f1a508c6a4bdb2fcee98d18394e28e1cc663c3 (diff)
downloadgitlab-ce-0f2776287a7d9b0fde9ff54ef8d9f74e2f844a09.tar.gz
Use Slack::Notifier::LinkFormatter to convert markdown links to slack compat
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/chat_commands/command_spec.rb14
-rw-r--r--spec/models/project_services/mattermost_notification_service_spec.rb2
-rw-r--r--spec/models/project_services/mattermost_slash_commands_service_spec.rb2
-rw-r--r--spec/models/project_services/slack_notification_service_spec.rb2
-rw-r--r--spec/models/project_services/slack_slash_commands_service.rb35
-rw-r--r--spec/support/chat_slash_commands_shared_examples.rb (renamed from spec/models/project_services/chat_slash_commands_service_spec.rb)8
-rw-r--r--spec/support/slack_mattermost_notifications_shared_examples.rb (renamed from spec/support/slack_mattermost_shared_examples.rb)2
7 files changed, 42 insertions, 23 deletions
diff --git a/spec/lib/gitlab/chat_commands/command_spec.rb b/spec/lib/gitlab/chat_commands/command_spec.rb
index dec98d990b2..a0ec8884635 100644
--- a/spec/lib/gitlab/chat_commands/command_spec.rb
+++ b/spec/lib/gitlab/chat_commands/command_spec.rb
@@ -3,12 +3,10 @@ require 'spec_helper'
describe Gitlab::ChatCommands::Command, service: true do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
- let(:format) { nil }
describe '#execute' do
subject do
- described_class.new(project, user,
- params.merge(presenter_format: format)).execute
+ described_class.new(project, user, params).execute
end
context 'when no command is available' do
@@ -51,14 +49,8 @@ describe Gitlab::ChatCommands::Command, service: true do
expect(subject[:text]).to match("my new issue")
end
- %w(slack mattermost).each do |format|
- context "for #{format}" do
- let(:format) { format }
-
- it 'shows a link to the new issue' do
- expect(subject[:text]).to match(/\/issues\/\d+/)
- end
- end
+ it 'shows a link to the new issue' do
+ expect(subject[:text]).to match(/\/issues\/\d+/)
end
end
diff --git a/spec/models/project_services/mattermost_notification_service_spec.rb b/spec/models/project_services/mattermost_notification_service_spec.rb
index c01e64b4c8e..7832d6f50cf 100644
--- a/spec/models/project_services/mattermost_notification_service_spec.rb
+++ b/spec/models/project_services/mattermost_notification_service_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
describe MattermostNotificationService, models: true do
- it_behaves_like "slack or mattermost"
+ it_behaves_like "slack or mattermost notifications"
end
diff --git a/spec/models/project_services/mattermost_slash_commands_service_spec.rb b/spec/models/project_services/mattermost_slash_commands_service_spec.rb
index b9deb0201e1..5c34cb6b4cf 100644
--- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb
+++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
describe MattermostSlashCommandsService, models: true do
- it { is_expected.to respond_to :presenter_format }
+ it_behaves_like "chat slash commands"
end
diff --git a/spec/models/project_services/slack_notification_service_spec.rb b/spec/models/project_services/slack_notification_service_spec.rb
index 59ddddf7454..110b5bf2115 100644
--- a/spec/models/project_services/slack_notification_service_spec.rb
+++ b/spec/models/project_services/slack_notification_service_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
describe SlackNotificationService, models: true do
- it_behaves_like "slack or mattermost"
+ it_behaves_like "slack or mattermost notifications"
end
diff --git a/spec/models/project_services/slack_slash_commands_service.rb b/spec/models/project_services/slack_slash_commands_service.rb
index 5ef97b9a2ed..c3fa80caebe 100644
--- a/spec/models/project_services/slack_slash_commands_service.rb
+++ b/spec/models/project_services/slack_slash_commands_service.rb
@@ -1,5 +1,38 @@
require 'spec_helper'
describe SlackSlashCommandsService, models: true do
- it { is_expected.to respond_to :presenter_format }
+ it_behaves_like "chat slash commands"
+
+ describe '#trigger' do
+ context 'when an auth url is generated' do
+ let(:project) { create(:empty_project) }
+ let(:params) do
+ {
+ team_domain: 'http://domain.tld',
+ team_id: 'T3423423',
+ user_id: 'U234234',
+ user_name: 'mepmep',
+ token: 'token'
+ }
+ end
+ let(:service) do
+ project.create_slack_slash_commands_service(
+ properties: { token: 'token' }
+ )
+ end
+ let(:authorize_url) do
+ 'http://authorize.example.com/'
+ end
+
+ before do
+ allow(service).to receive(:authorize_chat_name_url).and_return(authorize_url)
+ end
+
+ it 'uses slack compatible links' do
+ response = service.trigger(params)
+
+ expect(response[:text]).to include("<#{authorize_url}|connect your GitLab account>")
+ end
+ end
+ end
end
diff --git a/spec/models/project_services/chat_slash_commands_service_spec.rb b/spec/support/chat_slash_commands_shared_examples.rb
index 64fdd4d570b..96130b45235 100644
--- a/spec/models/project_services/chat_slash_commands_service_spec.rb
+++ b/spec/support/chat_slash_commands_shared_examples.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe ChatSlashCommandsService, models: true do
+RSpec.shared_examples 'chat slash commands' do
describe "Associations" do
it { is_expected.to respond_to :token }
it { is_expected.to have_many :chat_names }
@@ -29,10 +27,6 @@ describe ChatSlashCommandsService, models: true do
describe '#trigger' do
subject { described_class.new }
- before do
- allow(subject).to receive(:presenter_format).and_return('unknown')
- end
-
context 'no token is passed' do
let(:params) { Hash.new }
diff --git a/spec/support/slack_mattermost_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb
index 56d4965f74d..8582aea5fe5 100644
--- a/spec/support/slack_mattermost_shared_examples.rb
+++ b/spec/support/slack_mattermost_notifications_shared_examples.rb
@@ -1,6 +1,6 @@
Dir[Rails.root.join("app/models/project_services/chat_message/*.rb")].each { |f| require f }
-RSpec.shared_examples 'slack or mattermost' do
+RSpec.shared_examples 'slack or mattermost notifications' do
let(:chat_service) { described_class.new }
let(:webhook_url) { 'https://example.gitlab.com/' }