Commit 9f0e23d6 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Fix tests

parent 4535129e
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
// %a.js-toggle-button // %a.js-toggle-button
// %div.js-toggle-content // %div.js-toggle-content
// //
$('body').on('click', '.js-toggle-button', function(e) { $('body').on('click', '.js-toggle-button', function() {
toggleContainer($(this).closest('.js-toggle-container')); toggleContainer($(this).closest('.js-toggle-container'));
}); });
......
...@@ -5,5 +5,11 @@ module Groups ...@@ -5,5 +5,11 @@ module Groups
def initialize(group, user, params = {}) def initialize(group, user, params = {})
@group, @current_user, @params = group, user, params.dup @group, @current_user, @params = group, user, params.dup
end end
private
def create_chat_team?
@chat_team == "true" && Gitlab.config.mattermost.enabled
end
end end
end end
...@@ -32,11 +32,5 @@ module Groups ...@@ -32,11 +32,5 @@ module Groups
@group.add_owner(current_user) @group.add_owner(current_user)
@group @group
end end
private
def create_chat_team?
@chat_team && Gitlab.config.mattermost.enabled
end
end end
end end
module Groups module Groups
class UpdateService < Groups::BaseService class UpdateService < Groups::BaseService
def execute def execute
if params.delete(:create_chat_team) == '1' @chat_team = params.delete(:create_chat_team)
chat_name = params[:chat_team_name]
options = chat_name ? { name: chat_name } : {}
end
# check that user is allowed to set specified visibility_level # check that user is allowed to set specified visibility_level
new_visibility = params[:visibility_level] new_visibility = params[:visibility_level]
...@@ -19,6 +16,12 @@ module Groups ...@@ -19,6 +16,12 @@ module Groups
group.assign_attributes(params) group.assign_attributes(params)
if create_chat_team?
Mattermost::CreateTeamService.new(group, current_user).execute
return group if group.errors.any?
end
begin begin
group.save group.save
rescue Gitlab::UpdatePathError => e rescue Gitlab::UpdatePathError => e
...@@ -27,5 +30,11 @@ module Groups ...@@ -27,5 +30,11 @@ module Groups
false false
end end
end end
private
def create_chat_team?
super && group.chat_team.nil?
end
end end
end end
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
Team URL: Team URL:
= Settings.mattermost.host = Settings.mattermost.host
%span> / %span> /
%span{ "data-bind-out" => "create_chat_team"} %span{ "data-bind-out" => "create_chat_team" }
class CreateChatTeams < ActiveRecord::Migration class CreateChatTeams < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = true
DOWNTIME_REASON = "Adding a foreign key"
def change def change
create_table :chat_teams do |t| create_table :chat_teams do |t|
...@@ -12,6 +13,6 @@ class CreateChatTeams < ActiveRecord::Migration ...@@ -12,6 +13,6 @@ class CreateChatTeams < ActiveRecord::Migration
t.timestamps null: false t.timestamps null: false
end end
add_foreign_key :chat_teams, :namespaces, on_delete: :cascade add_concurrent_foreign_key :chat_teams, :namespaces, on_delete: :cascade
end end
end end
...@@ -40,9 +40,13 @@ describe Groups::CreateService, '#execute', services: true do ...@@ -40,9 +40,13 @@ describe Groups::CreateService, '#execute', services: true do
end end
describe 'creating a mattermost team' do describe 'creating a mattermost team' do
let!(:params) { group_params.merge(create_chat_team: true) } let!(:params) { group_params.merge(create_chat_team: "true") }
let!(:service) { described_class.new(user, params) } let!(:service) { described_class.new(user, params) }
before do
Settings.mattermost['enabled'] = true
end
it 'triggers the service' do it 'triggers the service' do
expect_any_instance_of(Mattermost::CreateTeamService).to receive(:execute) expect_any_instance_of(Mattermost::CreateTeamService).to receive(:execute)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment