]> source.dussan.org Git - redmine.git/commitdiff
Makes versions resource shallow (#7403).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 5 Jul 2011 16:29:06 +0000 (16:29 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 5 Jul 2011 16:29:06 +0000 (16:29 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6183 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/versions_controller.rb
app/views/projects/settings/_versions.rhtml
app/views/versions/_issue_counts.rhtml
app/views/versions/edit.rhtml
app/views/versions/show.rhtml
config/routes.rb
test/integration/api_test/versions_test.rb
test/integration/routing_test.rb

index 9eacc0ca20e6df1b6c855a03cfdaf292ca6a7a24..030f03c7874e9e6107579588075c071fddc6efea 100644 (file)
@@ -102,7 +102,7 @@ class VersionsController < ApplicationController
             }
           end
           format.api do
-            render :action => 'show', :status => :created, :location => project_version_url(@project, @version)
+            render :action => 'show', :status => :created, :location => version_url(@version)
           end
         end
       else
index f00fe5bd22f6096b73f5329a82916c5aa05bbb4e..d4d283f5a1983e89c65063b714dafbce75a44dfd 100644 (file)
@@ -20,8 +20,8 @@
     <td><%= link_to_if_authorized(h(version.wiki_page_title), {:controller => 'wiki', :action => 'show', :project_id => version.project, :id => Wiki.titleize(version.wiki_page_title)}) || h(version.wiki_page_title) unless version.wiki_page_title.blank? || version.project.wiki.nil? %></td>
     <td class="buttons">
        <% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %>
-               <%= link_to l(:button_edit), edit_project_version_path(@project, version), :class => 'icon icon-edit' %>
-               <%= link_to l(:button_delete), project_version_path(@project, version), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %>
+               <%= link_to l(:button_edit), edit_version_path(version), :class => 'icon icon-edit' %>
+               <%= link_to l(:button_delete), version_path(version), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %>
        <% end %>
        </td>
     </tr>
index 7ef8c4bceeb917882eb15e269606182d2c42a5ac..e2e2da6750aa20f5db0fa723f9fa0adbb0bc06b0 100644 (file)
@@ -5,7 +5,7 @@
        select_tag('status_by',
                    status_by_options_for_select(criteria),
                    :id => 'status_by_select',
-                   :onchange => remote_function(:url => status_by_project_version_path(version.project, version),
+                   :onchange => remote_function(:url => status_by_version_path(version),
                                                 :with => "Form.serialize('status_by_form')"))) %>
 </legend>
 <% if counts.empty? %>
index 8724fe62aa54d9efd2e2ebb5a3377ce3462fc66e..8a859626e73f2138be9eef62d800c9ff84928871 100644 (file)
@@ -1,6 +1,6 @@
 <h2><%=l(:label_version)%></h2>
 
-<% labelled_tabular_form_for :version, @version, :url => project_version_path(@project, @version), :html => {:method => :put} do |f| %>
+<% labelled_tabular_form_for :version, @version, :url => version_path(@version), :html => {:method => :put} do |f| %>
 <%= render :partial => 'form', :locals => { :f => f } %>
 <%= submit_tag l(:button_save) %>
 <% end %>
index 72ae8021801984f91580653c41f01f0db430e9b8..52a4bed1790b7e30007e05a710edc64525ab574a 100644 (file)
@@ -1,7 +1,7 @@
 <div class="contextual">
-<%= link_to(l(:button_edit), edit_project_version_path(@version.project, @version), :class => 'icon icon-edit') if User.current.allowed_to?(:manage_versions, @version.project) %>
+<%= link_to(l(:button_edit), edit_version_path(@version), :class => 'icon icon-edit') if User.current.allowed_to?(:manage_versions, @version.project) %>
 <%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :project_id => @version.project, :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @version.project.wiki.nil? %>
-<%= link_to(l(:button_delete), project_version_path(@version.project, @version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)),
+<%= link_to(l(:button_delete), version_path(@version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)),
   :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del') if User.current.allowed_to?(:manage_versions, @version.project) %>
 <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
 </div>
index 059ba19256042b572450bb066d0cdb7b34ec9871..df1b62086240ab9a821caa5ab2fb085050274197 100644 (file)
@@ -152,7 +152,7 @@ ActionController::Routing::Routes.draw do |map|
   } do |project|
     project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
     project.resources :files, :only => [:index, :new, :create]
-    project.resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post}
+    project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
     project.resources :news, :shallow => true
     project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
 
index 3872676aee53807150058666d0df8682b9105289..2ffb74b58af4544a1fbcc363bd24bda003c0ed9a 100644 (file)
@@ -74,10 +74,10 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
     end
   end
   
-  context "/projects/:project_id/versions/:id" do
+  context "/versions/:id" do
     context "GET" do
       should "return the version" do
-        get '/projects/1/versions/2.xml'
+        get '/versions/2.xml'
         
         assert_response :success
         assert_equal 'application/xml', @response.content_type
@@ -95,7 +95,7 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
     
     context "PUT" do
       should "update the version" do
-        put '/projects/1/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith')
+        put '/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith')
         
         assert_response :ok
         assert_equal 'API update', Version.find(2).name
@@ -105,7 +105,7 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
     context "DELETE" do
       should "destroy the version" do
         assert_difference 'Version.count', -1 do
-          delete '/projects/1/versions/3.xml', {}, :authorization => credentials('jsmith')
+          delete '/versions/3.xml', {}, :authorization => credentials('jsmith')
         end
         
         assert_response :ok
index a53c46567dba502c4aca33794150208e13b1c802..199dc1b27334fd69a5e728cbcc794c28d41a6f7e 100644 (file)
@@ -337,22 +337,22 @@ class RoutingTest < ActionController::IntegrationTest
     should_route :post, "/projects/foo/versions.xml", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'xml'
     should_route :post, "/projects/foo/versions.json", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'json'
     
-    should_route :get, "/projects/foo/versions/1", :controller => 'versions', :action => 'show', :project_id => 'foo', :id => '1'
-    should_route :get, "/projects/foo/versions/1.xml", :controller => 'versions', :action => 'show', :project_id => 'foo', :id => '1', :format => 'xml'
-    should_route :get, "/projects/foo/versions/1.json", :controller => 'versions', :action => 'show', :project_id => 'foo', :id => '1', :format => 'json'
+    should_route :get, "/versions/1", :controller => 'versions', :action => 'show', :id => '1'
+    should_route :get, "/versions/1.xml", :controller => 'versions', :action => 'show', :id => '1', :format => 'xml'
+    should_route :get, "/versions/1.json", :controller => 'versions', :action => 'show', :id => '1', :format => 'json'
     
-    should_route :get, "/projects/foo/versions/1/edit", :controller => 'versions', :action => 'edit', :project_id => 'foo', :id => '1'
+    should_route :get, "/versions/1/edit", :controller => 'versions', :action => 'edit', :id => '1'
     
-    should_route :put, "/projects/foo/versions/1", :controller => 'versions', :action => 'update', :project_id => 'foo', :id => '1'
-    should_route :put, "/projects/foo/versions/1.xml", :controller => 'versions', :action => 'update', :project_id => 'foo', :id => '1', :format => 'xml'
-    should_route :put, "/projects/foo/versions/1.json", :controller => 'versions', :action => 'update', :project_id => 'foo', :id => '1', :format => 'json'
+    should_route :put, "/versions/1", :controller => 'versions', :action => 'update', :id => '1'
+    should_route :put, "/versions/1.xml", :controller => 'versions', :action => 'update', :id => '1', :format => 'xml'
+    should_route :put, "/versions/1.json", :controller => 'versions', :action => 'update', :id => '1', :format => 'json'
     
-    should_route :delete, "/projects/foo/versions/1", :controller => 'versions', :action => 'destroy', :project_id => 'foo', :id => '1'
-    should_route :delete, "/projects/foo/versions/1.xml", :controller => 'versions', :action => 'destroy', :project_id => 'foo', :id => '1', :format => 'xml'
-    should_route :delete, "/projects/foo/versions/1.json", :controller => 'versions', :action => 'destroy', :project_id => 'foo', :id => '1', :format => 'json'
+    should_route :delete, "/versions/1", :controller => 'versions', :action => 'destroy', :id => '1'
+    should_route :delete, "/versions/1.xml", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'xml'
+    should_route :delete, "/versions/1.json", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'json'
     
     should_route :put, "/projects/foo/versions/close_completed", :controller => 'versions', :action => 'close_completed', :project_id => 'foo'
-    should_route :post, "/projects/foo/versions/1/status_by", :controller => 'versions', :action => 'status_by', :project_id => 'foo', :id => '1'
+    should_route :post, "/versions/1/status_by", :controller => 'versions', :action => 'status_by', :id => '1'
   end
 
   context "wiki (singular, project's pages)" do