diff options
68 files changed, 391 insertions, 225 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e934f7878..44e77bc62 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -176,7 +176,6 @@ class ProjectsController < ApplicationController @issue_category ||= IssueCategory.new @member ||= @project.members.new @trackers = Tracker.all - @repository ||= @project.repository @wiki ||= @project.wiki end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ad7d2df36..0a95c6ade 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -24,44 +24,45 @@ class InvalidRevisionParam < Exception; end class RepositoriesController < ApplicationController menu_item :repository - menu_item :settings, :only => :edit + menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] default_search_scope :changesets - before_filter :find_repository, :except => :edit - before_filter :find_project, :only => :edit + before_filter :find_project_by_project_id, :only => [:new, :create] + before_filter :check_repository_uniqueness, :only => [:new, :create] + before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] + before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers] before_filter :authorize accept_rss_auth :revisions rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed - def edit - @repository = @project.repository - if !@repository && !params[:repository_scm].blank? - @repository = Repository.factory(params[:repository_scm]) - @repository.project = @project if @repository - end - if request.post? && @repository - p1 = params[:repository] - p = {} - p_extra = {} - p1.each do |k, v| - if k =~ /^extra_/ - p_extra[k] = v - else - p[k] = v - end - end - @repository.attributes = p - @repository.merge_extra_info(p_extra) - @repository.save + def new + scm = params[:repository_scm] || Redmine::Scm::Base.all.first + @repository = Repository.factory(scm) + @repository.project = @project + render :layout => !request.xhr? + end + + def create + @repository = Repository.factory(params[:repository_scm], params[:repository]) + @repository.project = @project + if request.post? && @repository.save + redirect_to settings_project_path(@project, :tab => 'repositories') + else + render :action => 'new' 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) - end + end + + def edit + end + + def update + @repository.attributes = params[:repository] + @repository.project = @project + if request.put? && @repository.save + redirect_to settings_project_path(@project, :tab => 'repositories') + else + render :action => 'edit' end end @@ -76,16 +77,13 @@ class RepositoriesController < ApplicationController # Build a hash with repository usernames as keys and corresponding user ids as values @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h} flash[:notice] = l(:notice_successful_update) - redirect_to :action => 'committers', :id => @project + redirect_to settings_project_path(@project, :tab => 'repositories') end end def destroy - @repository.destroy - redirect_to :controller => 'projects', - :action => 'settings', - :id => @project, - :tab => 'repository' + @repository.destroy if request.delete? + redirect_to settings_project_path(@project, :tab => 'repositories') end def show @@ -250,9 +248,23 @@ class RepositoriesController < ApplicationController private + def find_repository + @repository = Repository.find(params[:id]) + @project = @repository.project + rescue ActiveRecord::RecordNotFound + render_404 + end + + # TODO: remove it when multiple SCM support is added + def check_repository_uniqueness + if @project.repository + redirect_to settings_project_path(@project, :tab => 'repositories') + end + end + REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i - def find_repository + def find_project_repository @project = Project.find(params[:id]) @repository = @project.repository (render_404; return false) unless @repository diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 70b12acce..8b7e22fd8 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -30,7 +30,7 @@ module ProjectsHelper {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, - {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, + {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository}, {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} ] diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 2a4e65710..f3b229f2c 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -139,13 +139,10 @@ module RepositoriesHelper options_for_select(scm_options, repository.class.name.demodulize), :disabled => (repository && !repository.new_record?), :onchange => remote_function( - :url => { - :controller => 'repositories', - :action => 'edit', - :id => @project - }, - :method => :get, - :with => "Form.serialize(this.form)") + :url => new_project_repository_path(@project), + :method => :get, + :update => 'content', + :with => "Form.serialize(this.form)") ) end diff --git a/app/models/repository.rb b/app/models/repository.rb index 5130cc220..c231a8724 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -48,6 +48,26 @@ class Repository < ActiveRecord::Base super(attr_name, *args) end + alias :attributes_without_extra_info= :attributes= + def attributes=(new_attributes, guard_protected_attributes = true) + return if new_attributes.nil? + attributes = new_attributes.dup + attributes.stringify_keys! + + p = {} + p_extra = {} + attributes.each do |k, v| + if k =~ /^extra_/ + p_extra[k] = v + else + p[k] = v + end + end + + send :attributes_without_extra_info=, p, guard_protected_attributes + merge_extra_info(p_extra) + end + # Removes leading and trailing whitespace def url=(arg) write_attribute(:url, arg ? arg.to_s.strip : nil) diff --git a/app/views/projects/settings/_repositories.html.erb b/app/views/projects/settings/_repositories.html.erb new file mode 100644 index 000000000..d74220b9e --- /dev/null +++ b/app/views/projects/settings/_repositories.html.erb @@ -0,0 +1,36 @@ +<% if @project.repository %> +<table class="list"> + <thead> + <tr> + <th><%= l(:label_scm) %></th> + <th><%= l(:label_repository) %></th> + <th></th> + </tr> + </thead> + <tbody> + <% repository = @project.repository %> + <tr class="<%= cycle 'odd', 'even' %>"> + <td><%=h repository.scm_name %></td> + <td><%=h repository.url %></td> + <td class="buttons"> + <% if User.current.allowed_to?(:manage_repository, @project) %> + <%= link_to(l(:label_user_plural), committers_repository_path(repository), + :class => 'icon icon-user') %> + <%= link_to(l(:button_edit), edit_repository_path(repository), + :class => 'icon icon-edit') %> + <%= link_to(l(:button_delete), repository_path(repository), + :confirm => l(:text_are_you_sure), + :method => :delete, + :class => 'icon icon-del') %> + <% end %> + </td> + </tr> + </tbody> +</table> +<% else %> +<p class="nodata"><%= l(:label_no_data) %></p> +<% end %> + +<% if @project.repository.nil? && User.current.allowed_to?(:manage_repository, @project) %> + <p><%= link_to l(:label_repository_new), new_project_repository_path(@project), :class => 'icon icon-add' %></p> +<% end %> diff --git a/app/views/repositories/_form.html.erb b/app/views/repositories/_form.html.erb new file mode 100644 index 000000000..bd1f61334 --- /dev/null +++ b/app/views/repositories/_form.html.erb @@ -0,0 +1,22 @@ +<%= error_messages_for 'repository' %> + +<div class="box tabular"> +<p> +<%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %> +<% if @repository && ! @repository.class.scm_available %> + <br /> + <em><%= content_tag 'span', l(:text_scm_command_not_available), :class => 'error' %></em> +<% end %> +</p> + +<% button_disabled = true %> +<% if @repository %> +<% button_disabled = ! @repository.class.scm_available %> +<%= repository_field_tags(f, @repository)%> +<% end %> +</div> + +<p> + <%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save), :disabled => button_disabled) %> + <%= link_to l(:button_cancel), settings_project_path(@project, :tab => 'repositories') %> +</p>
\ No newline at end of file diff --git a/app/views/repositories/edit.html.erb b/app/views/repositories/edit.html.erb new file mode 100644 index 000000000..ffc42f34e --- /dev/null +++ b/app/views/repositories/edit.html.erb @@ -0,0 +1,5 @@ +<h2><%= l(:label_repository) %></h2> + +<% labelled_form_for :repository, @repository, :url => repository_path(@path), :html => {:method => :put} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %>
\ No newline at end of file diff --git a/app/views/repositories/new.html.erb b/app/views/repositories/new.html.erb new file mode 100644 index 000000000..996404229 --- /dev/null +++ b/app/views/repositories/new.html.erb @@ -0,0 +1,5 @@ +<h2><%= l(:label_repository_new) %></h2> + +<% labelled_form_for :repository, @repository, :url => project_repositories_path(@project) do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 93cf9615e..a96f10eee 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1011,3 +1011,4 @@ ar: zero: 0 قضية one: 1 قضية other: "%{count} قضايا" + label_repository_new: New repository diff --git a/config/locales/bg.yml b/config/locales/bg.yml index e3239bda5..06d70e604 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -1009,3 +1009,4 @@ bg: description_date_range_interval: Изберете диапазон чрез задаване на начална и крайна дати description_date_from: Въведете начална дата description_date_to: Въведете крайна дата + label_repository_new: New repository diff --git a/config/locales/bs.yml b/config/locales/bs.yml index eda2d82d3..73e973f0d 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -1025,3 +1025,4 @@ bs: zero: 0 aktivnost one: 1 aktivnost other: "%{count} aktivnosti" + label_repository_new: New repository diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 37fb14fd3..605ca3900 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1013,3 +1013,4 @@ ca: zero: 0 assumpte one: 1 assumpte other: "%{count} assumptes" + label_repository_new: New repository diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 7e07ee384..0c9f9b646 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -1014,3 +1014,4 @@ cs: zero: 0 Úkol one: 1 Úkol other: "%{count} Úkoly" + label_repository_new: New repository diff --git a/config/locales/da.yml b/config/locales/da.yml index 8cfa8a873..c4db5bfe9 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1028,3 +1028,4 @@ da: zero: 0 sag one: 1 sag other: "%{count} sager" + label_repository_new: New repository diff --git a/config/locales/de.yml b/config/locales/de.yml index 6e8ac78d5..b5769d1ca 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1031,3 +1031,4 @@ de: zero: 0 ticket one: 1 ticket other: "%{count} tickets" + label_repository_new: New repository diff --git a/config/locales/el.yml b/config/locales/el.yml index 65fac0b03..f2afb3361 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -1011,3 +1011,4 @@ el: zero: 0 Θέμα one: 1 Θέμα other: "%{count} Θέματα" + label_repository_new: New repository diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index fa5c94581..c13ce907c 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1013,3 +1013,4 @@ en-GB: zero: 0 issue one: 1 issue other: "%{count} issues" + label_repository_new: New repository diff --git a/config/locales/en.yml b/config/locales/en.yml index d7e9b1e3d..489011886 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -650,6 +650,7 @@ en: label_not_contains: doesn't contain label_day_plural: days label_repository: Repository + label_repository_new: New repository label_repository_plural: Repositories label_browse: Browse label_modification: "%{count} change" diff --git a/config/locales/es.yml b/config/locales/es.yml index 83a8db904..8402b2883 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1048,3 +1048,4 @@ es: zero: 0 petición one: 1 petición other: "%{count} peticiones" + label_repository_new: New repository diff --git a/config/locales/eu.yml b/config/locales/eu.yml index fae6cde5c..d00434c46 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1014,3 +1014,4 @@ eu: zero: 0 zeregina one: 1 zeregina other: "%{count} zereginak" + label_repository_new: New repository diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 56e2fdf75..d0b6da590 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -1013,3 +1013,4 @@ fa: zero: 0 پیامد one: 1 پیامد other: "%{count} پیامد" + label_repository_new: New repository diff --git a/config/locales/fi.yml b/config/locales/fi.yml index fff5aa4d4..2de73b69d 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1032,3 +1032,4 @@ fi: zero: 0 tapahtuma one: 1 tapahtuma other: "%{count} tapahtumat" + label_repository_new: New repository diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4388317a6..7f04e5cb6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -640,6 +640,7 @@ fr: label_not_contains: ne contient pas label_day_plural: jours label_repository: Dépôt + label_repository_new: Nouveau dépôt label_repository_plural: Dépôts label_browse: Parcourir label_modification: "%{count} modification" diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 10377c436..ebed2cc83 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1022,3 +1022,4 @@ gl: zero: 0 petición one: 1 petición other: "%{count} peticións" + label_repository_new: New repository diff --git a/config/locales/he.yml b/config/locales/he.yml index 316e688de..c0950a1a6 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1016,3 +1016,4 @@ he: zero: 0 נושא one: 1 נושא other: "%{count} נושאים" + label_repository_new: New repository diff --git a/config/locales/hr.yml b/config/locales/hr.yml index 71c9f7e2d..8a47cc9a5 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -1017,3 +1017,4 @@ hr: zero: 0 predmet one: 1 predmet other: "%{count} predmeti" + label_repository_new: New repository diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 002fcd64b..7916d1f9c 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1030,3 +1030,4 @@ zero: 0 feladat one: 1 feladat other: "%{count} feladatok" + label_repository_new: New repository diff --git a/config/locales/id.yml b/config/locales/id.yml index 79eabb4d8..cf48cf3aa 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -1017,3 +1017,4 @@ id: zero: 0 masalah one: 1 masalah other: "%{count} masalah" + label_repository_new: New repository diff --git a/config/locales/it.yml b/config/locales/it.yml index 6b63a1367..fe5aac4e2 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1012,3 +1012,4 @@ it: zero: 0 segnalazione one: 1 segnalazione other: "%{count} segnalazioni" + label_repository_new: New repository diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 29d2cd1da..ef4d7490c 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1041,3 +1041,4 @@ ja: zero: 0 チケット one: 1 チケット other: "%{count} チケット" + label_repository_new: New repository diff --git a/config/locales/ko.yml b/config/locales/ko.yml index fa9d3347c..c2a9c61dd 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1063,3 +1063,4 @@ ko: zero: 0 일감 one: 1 일감 other: "%{count} 일감" + label_repository_new: New repository diff --git a/config/locales/lt.yml b/config/locales/lt.yml index e435abd06..00c1d6be4 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -1071,3 +1071,4 @@ lt: zero: 0 darbas one: 1 darbas other: "%{count} darbai" + label_repository_new: New repository diff --git a/config/locales/lv.yml b/config/locales/lv.yml index 3a7a8e2e7..6ff0bbd5f 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -1005,3 +1005,4 @@ lv: zero: 0 uzdevums one: 1 uzdevums other: "%{count} uzdevumi" + label_repository_new: New repository diff --git a/config/locales/mk.yml b/config/locales/mk.yml index 6eab875f3..67742839b 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -1011,3 +1011,4 @@ mk: zero: 0 Задача one: 1 Задача other: "%{count} Задачи" + label_repository_new: New repository diff --git a/config/locales/mn.yml b/config/locales/mn.yml index 6477849d4..2352dd407 100644 --- a/config/locales/mn.yml +++ b/config/locales/mn.yml @@ -1011,3 +1011,4 @@ mn: zero: 0 Асуудал one: 1 Асуудал other: "%{count} Асуудлууд" + label_repository_new: New repository diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 547f2877b..6ad9ebcc2 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -993,3 +993,4 @@ nl: zero: 0 issue one: 1 issue other: "%{count} issues" + label_repository_new: New repository diff --git a/config/locales/no.yml b/config/locales/no.yml index ae17d9f04..b0d1d6090 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1001,3 +1001,4 @@ zero: 0 sak one: 1 sak other: "%{count} saker" + label_repository_new: New repository diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 5026294e5..233390890 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1028,3 +1028,4 @@ pl: zero: 0 zagadnienie one: 1 zagadnienie other: "%{count} zagadnienia" + label_repository_new: New repository diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index f4fc9c6ed..907066ae0 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1034,3 +1034,4 @@ pt-BR: zero: 0 tarefa one: 1 tarefa other: "%{count} tarefas" + label_repository_new: New repository diff --git a/config/locales/pt.yml b/config/locales/pt.yml index b1d84893c..839221637 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -1016,3 +1016,4 @@ pt: zero: 0 tarefa one: 1 tarefa other: "%{count} tarefas" + label_repository_new: New repository diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 4f77e2547..e33ab4cd8 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -1003,3 +1003,4 @@ ro: zero: 0 tichet one: 1 tichet other: "%{count} tichete" + label_repository_new: New repository diff --git a/config/locales/ru.yml b/config/locales/ru.yml index ada1264bd..510e25ce9 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1124,3 +1124,4 @@ ru: zero: 0 Задача one: 1 Задача other: "%{count} Задачи" + label_repository_new: New repository diff --git a/config/locales/sk.yml b/config/locales/sk.yml index c96a31e55..2d13ff2d0 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -1006,3 +1006,4 @@ sk: zero: 0 Úloha one: 1 Úloha other: "%{count} Úlohy" + label_repository_new: New repository diff --git a/config/locales/sl.yml b/config/locales/sl.yml index a45f30b20..bb4800542 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -1011,3 +1011,4 @@ sl: zero: 0 zahtevek one: 1 zahtevek other: "%{count} zahtevki" + label_repository_new: New repository diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml index 0a6e10dad..c86a5b26f 100644 --- a/config/locales/sr-YU.yml +++ b/config/locales/sr-YU.yml @@ -1011,3 +1011,4 @@ sr-YU: zero: 0 problem one: 1 problem other: "%{count} problemi" + label_repository_new: New repository diff --git a/config/locales/sr.yml b/config/locales/sr.yml index d558097df..79145ddc9 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1012,3 +1012,4 @@ sr: zero: 0 Проблем one: 1 Проблем other: "%{count} Проблеми" + label_repository_new: New repository diff --git a/config/locales/sv.yml b/config/locales/sv.yml index ca7c00bbf..300ee5be8 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1052,3 +1052,4 @@ sv: zero: 0 Ärende one: 1 Ärende other: "%{count} Ärenden" + label_repository_new: New repository diff --git a/config/locales/th.yml b/config/locales/th.yml index dc91b9e5c..10237220b 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -1008,3 +1008,4 @@ th: zero: 0 ปัญหา one: 1 ปัญหา other: "%{count} ปัญหา" + label_repository_new: New repository diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 946536161..1203b4eef 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1030,3 +1030,4 @@ tr: zero: 0 İş one: 1 İş other: "%{count} İşler" + label_repository_new: New repository diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 7f649f6fa..aedb7a96a 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1008,3 +1008,4 @@ uk: zero: 0 Питання one: 1 Питання other: "%{count} Питання" + label_repository_new: New repository diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 3bad8d750..d7d633909 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1062,3 +1062,4 @@ vi: zero: 0 vấn đề one: 1 vấn đề other: "%{count} vấn đề" + label_repository_new: New repository diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 9229fd3b9..9283a548e 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1091,3 +1091,4 @@ zero: 0 問題 one: 1 問題 other: "%{count} 問題清單" + label_repository_new: New repository diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 407b35748..52a0a8106 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1013,3 +1013,4 @@ zh: zero: 0 问题 one: 1 问题 other: "%{count} 问题" + label_repository_new: New repository diff --git a/config/routes.rb b/config/routes.rb index 42e936c0f..64ba34d2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -176,6 +176,8 @@ ActionController::Routing::Routes.draw do |map| project.resources :issue_categories, :shallow => true project.resources :documents, :shallow => true, :member => {:add_attachment => :post} project.resources :boards + project.resources :repositories, :shallow => true, :except => [:index, :show], + :member => {:committers => [:get, :post]} project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get} project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get} @@ -272,16 +274,6 @@ ActionController::Routing::Routes.draw do |map| repositories.connect 'projects/:id/repository/revision', :action => 'revision', :conditions => {:method => [:get, :post]} - - repositories.connect 'projects/:id/repository/committers', - :action => 'committers', - :conditions => {:method => [:get, :post]} - repositories.connect 'projects/:id/repository/edit', - :action => 'edit', - :conditions => {:method => [:get, :post]} - repositories.connect 'projects/:id/repository/destroy', - :action => 'destroy', - :conditions => {:method => :post} end # additional routes for having the file name at the end of url diff --git a/lib/redmine.rb b/lib/redmine.rb index b33b5847c..b43a53b71 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -124,7 +124,7 @@ Redmine::AccessControl.map do |map| end map.project_module :repository do |map| - map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member + map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] map.permission :view_changesets, :repositories => [:show, :revisions, :revision] map.permission :commit_access, {} diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 933962e10..3d64c6035 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -51,8 +51,8 @@ namespace :test do (supported_scms - [:subversion, :mercurial]).each do |scm| desc "Creates a test #{scm} repository" task scm => :create_dir do - # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" - system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" + system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" + #system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" end end diff --git a/test/fixtures/enabled_modules.yml b/test/fixtures/enabled_modules.yml index 3b4eb7ace..d833c20b8 100644 --- a/test/fixtures/enabled_modules.yml +++ b/test/fixtures/enabled_modules.yml @@ -99,3 +99,7 @@ enabled_modules_025: name: news project_id: 2 id: 25 +enabled_modules_026: + name: repository + project_id: 2 + id: 26 diff --git a/test/functional/repositories_bazaar_controller_test.rb b/test/functional/repositories_bazaar_controller_test.rb index 0273ef8cd..099c05088 100644 --- a/test/functional/repositories_bazaar_controller_test.rb +++ b/test/functional/repositories_bazaar_controller_test.rb @@ -37,15 +37,14 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) - def test_get_edit + def test_get_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Bazaar' + get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Bazaar, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' end def test_browse_root @@ -157,10 +156,11 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase @request.session[:user_id] = 1 # admin assert_equal 0, @repository.changesets.count @repository.fetch_changesets - @project.reload assert @repository.changesets.count > 0 - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -168,26 +168,18 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert @repository.changesets.count > 0 - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Bazaar.create( + @project.repository.destroy + @repository = Repository::Bazaar.create!( :project => @project, :url => "/invalid", :log_encoding => 'UTF-8') - assert @repository @repository.fetch_changesets @repository.reload assert_equal 0, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 5fd82d103..4310c7630 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -22,7 +22,7 @@ require 'repositories_controller' class RepositoriesController; def rescue_action(e) raise e end; end class RepositoriesControllerTest < ActionController::TestCase - fixtures :projects, :users, :roles, :members, :member_roles, + fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers @@ -33,6 +33,82 @@ class RepositoriesControllerTest < ActionController::TestCase User.current = nil end + def test_new + @request.session[:user_id] = 1 + get :new, :project_id => 'subproject1' + assert_response :success + assert_template 'new' + assert_kind_of Repository::Subversion, assigns(:repository) + assert assigns(:repository).new_record? + assert_tag 'input', :attributes => {:name => 'repository[url]'} + end + + # TODO: remove it when multiple SCM support is added + def test_new_with_existing_repository + @request.session[:user_id] = 1 + get :new, :project_id => 'ecookbook' + assert_response 302 + end + + def test_create + @request.session[:user_id] = 1 + assert_difference 'Repository.count' do + post :create, :project_id => 'subproject1', + :repository_scm => 'Subversion', + :repository => {:url => 'file:///test'} + end + assert_response 302 + repository = Repository.first(:order => 'id DESC') + assert_kind_of Repository::Subversion, repository + assert_equal 'file:///test', repository.url + end + + def test_create_with_failure + @request.session[:user_id] = 1 + assert_no_difference 'Repository.count' do + post :create, :project_id => 'subproject1', + :repository_scm => 'Subversion', + :repository => {:url => 'invalid'} + end + assert_response :success + assert_template 'new' + assert_kind_of Repository::Subversion, assigns(:repository) + assert assigns(:repository).new_record? + end + + def test_edit + @request.session[:user_id] = 1 + get :edit, :id => 11 + assert_response :success + assert_template 'edit' + assert_equal Repository.find(11), assigns(:repository) + assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test'} + end + + def test_update + @request.session[:user_id] = 1 + put :update, :id => 11, :repository => {:password => 'test_update'} + assert_response 302 + assert_equal 'test_update', Repository.find(11).password + end + + def test_update_with_failure + @request.session[:user_id] = 1 + put :update, :id => 11, :repository => {:password => 'x'*260} + assert_response :success + assert_template 'edit' + assert_equal Repository.find(11), assigns(:repository) + end + + def test_destroy + @request.session[:user_id] = 1 + assert_difference 'Repository.count', -1 do + delete :destroy, :id => 11 + end + assert_response 302 + assert_nil Repository.find_by_id(11) + end + def test_revisions get :revisions, :id => 1 assert_response :success @@ -71,7 +147,7 @@ class RepositoriesControllerTest < ActionController::TestCase assert_equal 'image/svg+xml', @response.content_type end - def test_committers + def test_get_committers @request.session[:user_id] = 2 # add a commit with an unknown user Changeset.create!( @@ -82,7 +158,7 @@ class RepositoriesControllerTest < ActionController::TestCase :comments => 'Committed by foo.' ) - get :committers, :id => 1 + get :committers, :id => 10 assert_response :success assert_template 'committers' @@ -99,7 +175,7 @@ class RepositoriesControllerTest < ActionController::TestCase :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}} end - def test_map_committers + def test_post_committers @request.session[:user_id] = 2 # add a commit with an unknown user c = Changeset.create!( @@ -110,8 +186,8 @@ class RepositoriesControllerTest < ActionController::TestCase :comments => 'Committed by foo.' ) assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do - post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} - assert_redirected_to '/projects/ecookbook/repository/committers' + post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} + assert_response 302 assert_equal User.find(2), c.reload.user end end diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb index a3de673dc..2ad9b856a 100644 --- a/test/functional/repositories_cvs_controller_test.rb +++ b/test/functional/repositories_cvs_controller_test.rb @@ -43,15 +43,14 @@ class RepositoriesCvsControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) - def test_get_edit + def test_get_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Cvs' + get :new, :project_id => 'subproject1', :repository_scm => 'Cvs' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Cvs, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' end def test_browse_root @@ -247,7 +246,9 @@ class RepositoriesCvsControllerTest < ActionController::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -255,28 +256,20 @@ class RepositoriesCvsControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Cvs.create( + @project.repository.destroy + @repository = Repository::Cvs.create!( :project => Project.find(PRJ_ID), :root_url => "/invalid", :url => MODULE_NAME, :log_encoding => 'UTF-8' ) - assert @repository @repository.fetch_changesets @project.reload assert_equal 0, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb index 07d845a21..64873fc15 100644 --- a/test/functional/repositories_darcs_controller_test.rb +++ b/test/functional/repositories_darcs_controller_test.rb @@ -39,15 +39,14 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) - def test_get_edit + def test_get_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Darcs' + get :new, :project_id => 'subproject1', :repository_scm => 'Darcs' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Darcs, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' end def test_browse_root @@ -130,7 +129,9 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -138,27 +139,19 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Darcs.create( + @project.repository.destroy + @repository = Repository::Darcs.create!( :project => @project, :url => "/invalid", :log_encoding => 'UTF-8' ) - assert @repository @repository.fetch_changesets @project.reload assert_equal 0, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/repositories_filesystem_controller_test.rb b/test/functional/repositories_filesystem_controller_test.rb index 257537893..0b10d8fe3 100644 --- a/test/functional/repositories_filesystem_controller_test.rb +++ b/test/functional/repositories_filesystem_controller_test.rb @@ -41,15 +41,14 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) - def test_get_edit + def test_get_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Filesystem' + get :new, :project_id => 'subproject1', :repository_scm => 'Filesystem' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Filesystem, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' end def test_browse_root @@ -126,7 +125,9 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase def test_destroy_valid_repository @request.session[:user_id] = 1 # admin - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -134,20 +135,16 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Filesystem.create( - :project => Project.find(PRJ_ID), + @project.repository.destroy + @repository = Repository::Filesystem.create!( + :project => @project, :url => "/invalid", :path_encoding => '' ) - assert @repository - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index 094a6e7f1..33984fdf7 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -58,15 +58,14 @@ class RepositoriesGitControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) - def test_get_edit + def test_get_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Git' + get :new, :project_id => 'subproject1', :repository_scm => 'Git' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Git, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' end def test_browse_root @@ -424,7 +423,9 @@ class RepositoriesGitControllerTest < ActionController::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -432,27 +433,19 @@ class RepositoriesGitControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Git.create( + @project.repository.destroy + @repository = Repository::Git.create!( :project => @project, :url => "/invalid", :path_encoding => 'ISO-8859-1' ) - assert @repository @repository.fetch_changesets @repository.reload assert_equal 0, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/repositories_mercurial_controller_test.rb b/test/functional/repositories_mercurial_controller_test.rb index 1a580a62d..2792a3fdb 100644 --- a/test/functional/repositories_mercurial_controller_test.rb +++ b/test/functional/repositories_mercurial_controller_test.rb @@ -60,15 +60,14 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase def test_fake; assert true end elsif File.directory?(REPOSITORY_PATH) - def test_get_edit + def test_get_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Mercurial' + get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Mercurial, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' end def test_show_root @@ -469,10 +468,11 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase @request.session[:user_id] = 1 # admin assert_equal 0, @repository.changesets.count @repository.fetch_changesets - @project.reload assert_equal NUM_REV, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -480,27 +480,18 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Mercurial.create( + @project.repository.destroy + @repository = Repository::Mercurial.create!( :project => Project.find(PRJ_ID), :url => "/invalid", :path_encoding => 'ISO-8859-1' ) - assert @repository @repository.fetch_changesets - @project.reload assert_equal 0, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb index a47e8bc0b..0e0de2e3b 100644 --- a/test/functional/repositories_subversion_controller_test.rb +++ b/test/functional/repositories_subversion_controller_test.rb @@ -38,40 +38,14 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase end if repository_configured?('subversion') - def test_get_edit + def test_new @request.session[:user_id] = 1 @project.repository.destroy - xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Subversion' + get :new, :project_id => 'subproject1', :repository_scm => 'Subversion' assert_response :success - assert_equal 'text/javascript', @response.content_type + assert_template 'new' assert_kind_of Repository::Subversion, assigns(:repository) assert assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' - end - - def test_post_edit - @request.session[:user_id] = 1 - @project.repository.destroy - assert_difference 'Repository.count' do - xhr :post, :edit, :id => 'subproject1', :repository_scm => 'Subversion', :repository => {:url => 'file:///svn/path'} - end - assert_response :success - assert_equal 'text/javascript', @response.content_type - assert_kind_of Repository::Subversion, assigns(:repository) - assert !assigns(:repository).new_record? - assert_select_rjs :replace_html, 'tab-content-repository' - end - - def test_post_edit_existing_repository - @request.session[:user_id] = 1 - assert_no_difference 'Repository.count' do - xhr :post, :edit, :id => 'subproject1', :repository_scm => 'Subversion', :repository => {:password => 'newpassword'} - end - assert_response :success - assert_equal 'text/javascript', @response.content_type - assert_kind_of Repository::Subversion, assigns(:repository) - assert_select_rjs :replace_html, 'tab-content-repository' - assert_equal 'newpassword', Project.find('subproject1').repository.password end def test_show @@ -381,10 +355,11 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase @request.session[:user_id] = 1 # admin assert_equal 0, @repository.changesets.count @repository.fetch_changesets - @project.reload assert_equal NUM_REV, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository @@ -392,25 +367,16 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase def test_destroy_invalid_repository @request.session[:user_id] = 1 # admin - assert_equal 0, @repository.changesets.count - @repository.fetch_changesets - @project.reload - assert_equal NUM_REV, @repository.changesets.count - - get :destroy, :id => PRJ_ID - assert_response 302 - @project.reload - assert_nil @project.repository - - @repository = Repository::Subversion.create( + @project.repository.destroy + @repository = Repository::Subversion.create!( :project => @project, :url => "file:///invalid") - assert @repository @repository.fetch_changesets - @project.reload assert_equal 0, @repository.changesets.count - get :destroy, :id => PRJ_ID + assert_difference 'Repository.count', -1 do + delete :destroy, :id => @repository.id + end assert_response 302 @project.reload assert_nil @project.repository diff --git a/test/functional/sys_controller_test.rb b/test/functional/sys_controller_test.rb index e16c90c1d..97368b200 100644 --- a/test/functional/sys_controller_test.rb +++ b/test/functional/sys_controller_test.rb @@ -84,13 +84,13 @@ class SysControllerTest < ActionController::TestCase end def test_fetch_changesets - Repository::Subversion.any_instance.expects(:fetch_changesets).returns(true) + Repository::Subversion.any_instance.expects(:fetch_changesets).twice.returns(true) get :fetch_changesets assert_response :success end def test_fetch_changesets_one_project - Repository::Subversion.any_instance.expects(:fetch_changesets).returns(true) + Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) get :fetch_changesets, :id => 'ecookbook' assert_response :success end diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb index 9c1d6ff4e..edc49e70b 100644 --- a/test/integration/routing/repositories_test.rb +++ b/test/integration/routing/repositories_test.rb @@ -24,19 +24,47 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest assert_equal %w[path to file.c], @path_hash[:param] end - def test_repositories + def test_repositories_resources assert_routing( { :method => 'get', - :path => "/projects/redmine/repository" }, - { :controller => 'repositories', :action => 'show', :id => 'redmine' } + :path => "/projects/redmine/repositories/new" }, + { :controller => 'repositories', :action => 'new', :project_id => 'redmine' } + ) + assert_routing( + { :method => 'post', + :path => "/projects/redmine/repositories" }, + { :controller => 'repositories', :action => 'create', :project_id => 'redmine' } + ) + assert_routing( + { :method => 'get', + :path => "/repositories/1/edit" }, + { :controller => 'repositories', :action => 'edit', :id => '1' } + ) + assert_routing( + { :method => 'put', + :path => "/repositories/1" }, + { :controller => 'repositories', :action => 'update', :id => '1' } + ) + assert_routing( + { :method => 'delete', + :path => "/repositories/1" }, + { :controller => 'repositories', :action => 'destroy', :id => '1' } ) ["get", "post"].each do |method| assert_routing( { :method => method, - :path => "/projects/redmine/repository/edit" }, - { :controller => 'repositories', :action => 'edit', :id => 'redmine' } + :path => "/repositories/1/committers" }, + { :controller => 'repositories', :action => 'committers', :id => '1' } ) end + end + + def test_repositories + assert_routing( + { :method => 'get', + :path => "/projects/redmine/repository" }, + { :controller => 'repositories', :action => 'show', :id => 'redmine' } + ) assert_routing( { :method => 'get', :path => "/projects/redmine/repository/statistics" }, |