From 12d622eb996b6499e5fbd2be01cca27c08a976fa Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Wed, 8 Nov 2017 10:22:24 +0000 Subject: Fix acceptance of username for Mattermost service update via API --- ...ant-set-mattermost-username-channel-from-api.yml | 5 +++++ doc/api/services.md | 2 +- lib/api/services.rb | 6 ++++++ spec/requests/api/services_spec.rb | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/39895-cant-set-mattermost-username-channel-from-api.yml diff --git a/changelogs/unreleased/39895-cant-set-mattermost-username-channel-from-api.yml b/changelogs/unreleased/39895-cant-set-mattermost-username-channel-from-api.yml new file mode 100644 index 00000000000..358c007387e --- /dev/null +++ b/changelogs/unreleased/39895-cant-set-mattermost-username-channel-from-api.yml @@ -0,0 +1,5 @@ +--- +title: Fix acceptance of username for Mattermost service update +merge_request: 15275 +author: +type: fixed diff --git a/doc/api/services.md b/doc/api/services.md index e642ec964de..08a2bee1518 100644 --- a/doc/api/services.md +++ b/doc/api/services.md @@ -572,7 +572,7 @@ Parameters: | Attribute | Type | Required | Description | | --------- | ---- | -------- | ----------- | | `token` | string | yes | The Mattermost token | - +| `username` | string | no | The username to use to post the message | ### Delete Mattermost slash command service diff --git a/lib/api/services.rb b/lib/api/services.rb index 6454e475036..bbcc851d07a 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -522,6 +522,12 @@ module API name: :webhook, type: String, desc: 'The Mattermost webhook. e.g. http://mattermost_host/hooks/...' + }, + { + required: false, + name: :username, + type: String, + desc: 'The username to use to post the message' } ], 'teamcity' => [ diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index dfe48e45d49..ba697e2b305 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -175,4 +175,25 @@ describe API::Services do end end end + + describe 'Mattermost service' do + let(:service_name) { 'mattermost' } + let(:params) do + { webhook: 'https://hook.example.com', username: 'username' } + end + + before do + project.create_mattermost_service( + active: true, + properties: params + ) + end + + it 'accepts a username for update' do + put api("/projects/#{project.id}/services/mattermost", user), params.merge(username: 'new_username') + + expect(response).to have_gitlab_http_status(200) + expect(json_response['properties']['username']).to eq('new_username') + end + end end -- cgit v1.2.1