Allow updating of project auto devops settings

Updating didn't work, as the project_id was missing to be set for the
project_auto_devops model.

Fixes gitlab-org/gitlab-ce#37893
This commit is contained in:
Zeger-Jan van de Weg 2017-09-15 09:53:28 +02:00
parent ec3b3797e7
commit fb84bec542
No known key found for this signature in database
GPG key ID: 65F6A8D64A88ABAC
3 changed files with 37 additions and 1 deletions

View file

@ -192,7 +192,7 @@ class Project < ActiveRecord::Base
accepts_nested_attributes_for :variables, allow_destroy: true
accepts_nested_attributes_for :project_feature
accepts_nested_attributes_for :import_data
accepts_nested_attributes_for :auto_devops
accepts_nested_attributes_for :auto_devops, update_only: true
delegate :name, to: :owner, allow_nil: true, prefix: true
delegate :members, to: :team, prefix: true

View file

@ -0,0 +1,5 @@
---
title: Allow updating of project auto devops settings
merge_request:
author:
type: fixed

View file

@ -0,0 +1,31 @@
require 'spec_helper'
describe Projects::PipelinesSettingsController do
set(:user) { create(:user) }
set(:project_auto_devops) { create(:project_auto_devops) }
let(:project) { project_auto_devops.project }
before do
project.add_master(user)
sign_in(user)
end
describe 'PATCH update' do
before do
patch :update,
namespace_id: project.namespace.to_param,
project_id: project,
project: {
auto_devops_attributes: { enabled: false, domain: 'mempmep.md' }
}
end
context 'when updating the auto_devops settings' do
it 'redirects to the settings page' do
expect(response).to have_http_status(302)
expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.")
end
end
end
end