summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-04-04 14:59:54 -0700
committerStan Hu <stanhu@gmail.com>2016-04-05 11:18:13 -0700
commit934f1e9097485bbaebbe2759e995c77bb4391c5d (patch)
treef2860ed255f4185893d375d977e5046bca99b066
parent353365c7f2646be7ab0efff45980cd781763696d (diff)
downloadgitlab-ce-934f1e9097485bbaebbe2759e995c77bb4391c5d.tar.gz
Fix Error 500 after renaming a project path
Closes #14885
-rw-r--r--CHANGELOG3
-rw-r--r--app/controllers/projects_controller.rb3
-rw-r--r--spec/controllers/projects_controller_spec.rb22
3 files changed, 27 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e1b6b32cff3..7d744a6c49f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,11 +3,12 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.7.0 (unreleased)
- All images in discussions and wikis now link to their source files !3464 (Connor Shea).
- Improved Markdown rendering performance !3389 (Yorick Peterse)
- - Don't attempt to look up an avatar in repo if repo directory does not exist (Stan hu)
+ - Don't attempt to look up an avatar in repo if repo directory does not exist (Stan Hu)
- Preserve time notes/comments have been updated at when moving issue
- Make HTTP(s) label consistent on clone bar (Stan Hu)
- Expose label description in API (Mariusz Jachimowicz)
- Allow back dating on issues when created through the API
+ - Fix Error 500 after renaming a project path (Stan Hu)
- Fix avatar stretching by providing a cropping feature
- Add endpoints to archive or unarchive a project !3372
- Add links to CI setup documentation from project settings and builds pages
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 8c3a74c8236..3cc37e59855 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -40,6 +40,9 @@ class ProjectsController < Projects::ApplicationController
def update
status = ::Projects::UpdateService.new(@project, current_user, project_params).execute
+ # Refresh the repo in case anything changed
+ @repository = project.repository
+
respond_to do |format|
if status
flash[:notice] = "Project '#{@project.name}' was successfully updated."
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 1893e946f5c..069cd917e5a 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -83,6 +83,28 @@ describe ProjectsController do
end
end
+ describe "#update" do
+ render_views
+
+ let(:admin) { create(:admin) }
+
+ it "sets the repository to the right path after a rename" do
+ new_path = 'renamed_path'
+ project_params = { path: new_path }
+ controller.instance_variable_set(:@project, project)
+ sign_in(admin)
+
+ put :update,
+ namespace_id: project.namespace.to_param,
+ id: project.id,
+ project: project_params
+
+ expect(project.repository.path).to include(new_path)
+ expect(assigns(:repository).path).to eq(project.repository.path)
+ expect(response.status).to eq(200)
+ end
+ end
+
describe "#destroy" do
let(:admin) { create(:admin) }