showing error messages on scm updates

pull/2696/head
Jens Ulferts 10 years ago
parent fce72938e3
commit b37ea687e2
  1. 15
      app/controllers/repositories_controller.rb
  2. 37
      app/views/projects/settings/repository.js.erb
  3. 4
      spec/controllers/repositories_controller_spec.rb

@ -58,11 +58,16 @@ class RepositoriesController < ApplicationController
@repository.attributes = params[:repository]
@repository.save
end
render(:update) do |page|
page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'
if @repository && !@project.repository
@project.reload #needed to reload association
page.replace_html "main-menu", render_main_menu(@project)
menu_reload_required = if @repository.persisted? && !@project.repository
@project.reload # needed to reload association
end
respond_to do |format|
format.js do
render template: '/projects/settings/repository',
locals: { project: @project,
reload_menu: menu_reload_required }
end
end
end

@ -0,0 +1,37 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street Fifth Floor, Boston, MA 02110-1301, USA.
See doc/COPYRIGHT.rdoc for more details.
++#%>
<% partial = escape_javascript render(partial: 'projects/settings/repository') %>
jQuery('#tab-content-repository').html("<%= partial %>");
<% if reload_menu %>
jQuery('#main-menu').html("<%= escape_javascript(render_main_menu(project)) %>");
<% end %>
activateFlashError();

@ -43,7 +43,7 @@ describe RepositoriesController, :type => :controller do
let(:repository) do
allow(Setting).to receive(:enabled_scm).and_return(['Filesystem'])
repo = FactoryGirl.build_stubbed(:repository,
:project => project)
project: project)
allow(repo).to receive(:default_branch).and_return('master')
allow(repo).to receive(:branches).and_return(['master'])
@ -56,7 +56,7 @@ describe RepositoriesController, :type => :controller do
end
describe '#edit' do
let(:role) { FactoryGirl.create(:role, :permissions => [:manage_repository]) }
let(:role) { FactoryGirl.create(:role, permissions: [:manage_repository]) }
before do
# authorization checked in spec/permissions/manage_repositories_spec.rb

Loading…
Cancel
Save