Project

General

Profile

Actions

Defect #24

closed

SVN Repository attributes aren't saved if modified after creation

Added by Antonio Salazar over 17 years ago. Updated over 17 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

If one changes the SVN repository path after one has created and set it already, the path is not updated. This seems
to be because of this bit in projects_controller.rb:

if params[:repository_enabled]
case params[:repository_enabled]
when "0"
@project.repository = nil
when "1"
@project.repository ||= Repository.new
@project.repository.attributes = params[:repository]
end
end

This seems to be fixed in trunk, but the fix is:

if params[:repository_enabled] && params[:repository_enabled] == "1" 
@project.repository = Repository.new
@project.repository.attributes = params[:repository]
end

Which would generate a new Repository every time a modification was made. It seems like a better solution would be:

if params[:repository_enabled]
case params[:repository_enabled]
when "0"
@project.repository = nil
when "1"
@project.repository ||= Repository.new
@project.repository.update_attributes params[:repository] # use update_attributes
end
end

If the update were to fail, then the save of the project would also fail due to the validate_associated validation in
the Project model. Otherwise, whether it was or was not a new Repository, it would update the attributes and save, and
only generate a new Repository once, when there was no previous one to update.

A similar solution would probably work for the wiki.

Actions #1

Updated by Jean-Philippe Lang over 17 years ago

As you it's fixed in the repository.

This code is what there is in trunk, but for the ADD action (that
means called when you CREATE a project, so a new repository has
to be created):

if params[:repository_enabled] && params[:repository_enabled] == "1"
@project.repository = Repository.new
@project.repository.attributes = params[:repository]
end

The last code you "propose" is exactly what there is
in the trunk but in the EDIT method of the projects controller.

Actions #2

Updated by Antonio Salazar over 17 years ago

There's me not paying enough attention to the code late at
night :-) Sorry!

Actions

Also available in: Atom PDF