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:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-20 14:02:37 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-20 14:02:37 +0300
commit0cf23fde7c666b64e6c18a92d29e632f51b00059 (patch)
tree943171ba614758895e88bd1b69d2add1a517da91 /spec/models/project_services
parentd305d15b6dde99b0de7fc78242aaa095fc79b5ca (diff)
Work on tests for mattermost
Diffstat (limited to 'spec/models/project_services')
-rw-r--r--spec/models/project_services/mattermost_slash_commands_service_spec.rb35
1 files changed, 35 insertions, 0 deletions
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 1ae1483e2a4..9fb6132d171 100644
--- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb
+++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb
@@ -2,4 +2,39 @@ require 'spec_helper'
describe MattermostSlashCommandsService, :models do
it_behaves_like "chat slash commands service"
+
+ describe '#configure!' do
+ let(:project) { create(:empty_project) }
+ let(:service) { project.build_mattermost_slash_commands_service }
+ let(:user) { create(:user)}
+
+ before do
+ allow_any_instance_of(Mattermost::Session).to
+ receive(:with_session).and_yield
+ end
+
+ subject do
+ service.configure!(user, team_id: 'abc',
+ trigger: 'gitlab', url: 'http://trigger.url',
+ icon_url: 'http://icon.url/icon.png')
+ end
+
+ context 'the requests succeeds' do
+ it 'saves the service' do
+ expect { subject }.to change { project.services.count }.by(1)
+ end
+
+ it 'saves the token' do
+ subject
+
+ expect(service.reload.token).to eq('mynewtoken')
+ end
+ end
+
+ context 'an error is received' do
+ it 'shows error messages' do
+ expect(subject).to raise_error("Error")
+ end
+ end
+ end
end