BigW Consortium Gitlab

Commit 9f0e23d6 by Z.J. van de Weg

Fix tests

parent 4535129e
......@@ -21,7 +21,7 @@
// %a.js-toggle-button
// %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'));
});
......
......@@ -5,5 +5,11 @@ module Groups
def initialize(group, user, params = {})
@group, @current_user, @params = group, user, params.dup
end
private
def create_chat_team?
@chat_team == "true" && Gitlab.config.mattermost.enabled
end
end
end
......@@ -32,11 +32,5 @@ module Groups
@group.add_owner(current_user)
@group
end
private
def create_chat_team?
@chat_team && Gitlab.config.mattermost.enabled
end
end
end
module Groups
class UpdateService < Groups::BaseService
def execute
if params.delete(:create_chat_team) == '1'
chat_name = params[:chat_team_name]
options = chat_name ? { name: chat_name } : {}
end
@chat_team = params.delete(:create_chat_team)
# check that user is allowed to set specified visibility_level
new_visibility = params[:visibility_level]
......@@ -19,6 +16,12 @@ module Groups
group.assign_attributes(params)
if create_chat_team?
Mattermost::CreateTeamService.new(group, current_user).execute
return group if group.errors.any?
end
begin
group.save
rescue Gitlab::UpdatePathError => e
......@@ -27,5 +30,11 @@ module Groups
false
end
end
private
def create_chat_team?
super && group.chat_team.nil?
end
end
end
......@@ -13,4 +13,4 @@
Team URL:
= Settings.mattermost.host
%span> /
%span{ "data-bind-out" => "create_chat_team"}
%span{ "data-bind-out" => "create_chat_team" }
class CreateChatTeams < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
DOWNTIME = true
DOWNTIME_REASON = "Adding a foreign key"
def change
create_table :chat_teams do |t|
......@@ -12,6 +13,6 @@ class CreateChatTeams < ActiveRecord::Migration
t.timestamps null: false
end
add_foreign_key :chat_teams, :namespaces, on_delete: :cascade
add_concurrent_foreign_key :chat_teams, :namespaces, on_delete: :cascade
end
end
......@@ -40,9 +40,13 @@ describe Groups::CreateService, '#execute', services: true do
end
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) }
before do
Settings.mattermost['enabled'] = true
end
it 'triggers the service' do
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