From d4f62c79379810cb3e2d48dfc26c29ff238aac95 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 8 Aug 2012 14:07:41 +0200 Subject: [PATCH 01/17] fixes projects api test by adapting to altered authorization headers --- test/integration/api_test/projects_test.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb index 6590a37cc0..f0dc276bd2 100644 --- a/test/integration/api_test/projects_test.rb +++ b/test/integration/api_test/projects_test.rb @@ -129,7 +129,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest should "create a project with the attributes" do assert_difference('Project.count') do - post '/projects.xml', @parameters, :authorization => credentials('admin') + post '/projects.xml', @parameters, credentials('admin') end project = Project.first(:order => 'id DESC') @@ -147,7 +147,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}) assert_difference('Project.count') do - post '/projects.xml', @parameters, :authorization => credentials('admin') + post '/projects.xml', @parameters, credentials('admin') end project = Project.first(:order => 'id DESC') @@ -158,7 +158,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest @parameters[:project].merge!({:tracker_ids => [1, 3]}) assert_difference('Project.count') do - post '/projects.xml', @parameters, :authorization => credentials('admin') + post '/projects.xml', @parameters, credentials('admin') end project = Project.first(:order => 'id DESC') @@ -175,7 +175,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest context ".xml" do should "return errors" do assert_no_difference('Project.count') do - post '/projects.xml', @parameters, :authorization => credentials('admin') + post '/projects.xml', @parameters, credentials('admin') end assert_response :unprocessable_entity @@ -200,7 +200,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest should "update the project" do assert_no_difference 'Project.count' do - put '/projects/2.xml', @parameters, :authorization => credentials('jsmith') + put '/projects/2.xml', @parameters, credentials('jsmith') end assert_response :ok assert_equal 'application/xml', @response.content_type @@ -212,7 +212,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}) assert_no_difference 'Project.count' do - put '/projects/2.xml', @parameters, :authorization => credentials('admin') + put '/projects/2.xml', @parameters, credentials('admin') end assert_response :ok project = Project.find(2) @@ -223,7 +223,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest @parameters[:project].merge!({:tracker_ids => [1, 3]}) assert_no_difference 'Project.count' do - put '/projects/2.xml', @parameters, :authorization => credentials('admin') + put '/projects/2.xml', @parameters, credentials('admin') end assert_response :ok project = Project.find(2) @@ -240,7 +240,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest context ".xml" do should "return errors" do assert_no_difference('Project.count') do - put '/projects/2.xml', @parameters, :authorization => credentials('admin') + put '/projects/2.xml', @parameters, credentials('admin') end assert_response :unprocessable_entity @@ -260,7 +260,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest should "delete the project" do assert_difference('Project.count',-1) do - delete '/projects/2.xml', {}, :authorization => credentials('admin') + delete '/projects/2.xml', {}, credentials('admin') end assert_response :ok assert_nil Project.find_by_id(2) From bfda92f7d32d55177716ef7fd510f0a383509976 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 8 Aug 2012 15:40:47 +0200 Subject: [PATCH 02/17] adapts application integration tests to changed accept headers --- test/integration/application_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb index 57aa1441b2..147b93f4e3 100644 --- a/test/integration/application_test.rb +++ b/test/integration/application_test.rb @@ -23,19 +23,19 @@ class ApplicationTest < ActionController::IntegrationTest Setting.default_language = 'en' # a french user - get 'projects', { }, 'Accept-Language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' + get 'projects', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'} assert_response :success assert_tag :tag => 'h2', :content => 'Projets' assert_equal :fr, current_language # then an italien user - get 'projects', { }, 'Accept-Language' => 'it;q=0.8,en-us;q=0.5,en;q=0.3' + get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3' assert_response :success assert_tag :tag => 'h2', :content => 'Progetti' assert_equal :it, current_language # not a supported language: default language should be used - get 'projects', { }, 'Accept-Language' => 'zz' + get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz' assert_response :success assert_tag :tag => 'h2', :content => 'Projects' end From 3a098875609e4de5412223b8c5d0b3ed4b40bc38 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 8 Aug 2012 15:41:12 +0200 Subject: [PATCH 03/17] adapts users integration tests to changed credential headers --- test/integration/api_test/users_test.rb | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb index 4d26c9a677..f958d57679 100644 --- a/test/integration/api_test/users_test.rb +++ b/test/integration/api_test/users_test.rb @@ -12,7 +12,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ require File.expand_path('../../../test_helper', __FILE__) -require 'pp' + class ApiTest::UsersTest < ActionController::IntegrationTest fixtures :users @@ -28,7 +28,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest context "GET /users/2" do context ".xml" do should "return requested user" do - get '/users/2.xml' + get '/users/2.xml', {}, credentials('admin') assert_tag :tag => 'user', :child => {:tag => 'id', :content => '2'} @@ -37,9 +37,9 @@ class ApiTest::UsersTest < ActionController::IntegrationTest context ".json" do should "return requested user" do - get '/users/2.json' + get '/users/2.json', {}, credentials('admin') - json = ActiveSupport::JSON.decode(response.body) + json = ActiveSupport::JSON.decode(@response.body) assert_kind_of Hash, json assert_kind_of Hash, json['user'] assert_equal 2, json['user']['id'] @@ -56,7 +56,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest end should "return current user" do - get '/users/current.xml', {}, :authorization => credentials('jsmith') + get '/users/current.xml', {}, credentials('jsmith') assert_tag :tag => 'user', :child => {:tag => 'id', :content => '2'} @@ -78,7 +78,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest should "create a user with the attributes" do assert_difference('User.count') do - post '/users.xml', @parameters, :authorization => credentials('admin') + post '/users.xml', @parameters, credentials('admin') end user = User.first(:order => 'id DESC') @@ -104,7 +104,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest should "create a user with the attributes" do assert_difference('User.count') do - post '/users.json', @parameters, :authorization => credentials('admin') + post '/users.json', @parameters, credentials('admin') end user = User.first(:order => 'id DESC') @@ -132,7 +132,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest context ".xml" do should "return errors" do assert_no_difference('User.count') do - post '/users.xml', @parameters, :authorization => credentials('admin') + post '/users.xml', @parameters, credentials('admin') end assert_response :unprocessable_entity @@ -144,7 +144,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest context ".json" do should "return errors" do assert_no_difference('User.count') do - post '/users.json', @parameters, :authorization => credentials('admin') + post '/users.json', @parameters, credentials('admin') end assert_response :unprocessable_entity @@ -152,7 +152,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest json = ActiveSupport::JSON.decode(response.body) assert_kind_of Hash, json assert json.has_key?('errors') - assert_kind_of Array, json['errors'] + assert_equal({ "firstname" => ["can't be blank"], "mail" => ["is invalid"] }, json['errors']) end end end @@ -172,7 +172,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest should "update user with the attributes" do assert_no_difference('User.count') do - put '/users/2.xml', @parameters, :authorization => credentials('admin') + put '/users/2.xml', @parameters, credentials('admin') end user = User.find(2) @@ -194,7 +194,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest should "update user with the attributes" do assert_no_difference('User.count') do - put '/users/2.json', @parameters, :authorization => credentials('admin') + put '/users/2.json', @parameters, credentials('admin') end user = User.find(2) @@ -217,7 +217,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest context ".xml" do should "return errors" do assert_no_difference('User.count') do - put '/users/2.xml', @parameters, :authorization => credentials('admin') + put '/users/2.xml', @parameters, credentials('admin') end assert_response :unprocessable_entity @@ -229,7 +229,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest context ".json" do should "return errors" do assert_no_difference('User.count') do - put '/users/2.json', @parameters, :authorization => credentials('admin') + put '/users/2.json', @parameters, credentials('admin') end assert_response :unprocessable_entity @@ -237,7 +237,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest json = ActiveSupport::JSON.decode(response.body) assert_kind_of Hash, json assert json.has_key?('errors') - assert_kind_of Array, json['errors'] + assert_equal({ "firstname" => ["can't be blank"], "mail" => ["is invalid"] }, json['errors']) end end end @@ -261,7 +261,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest should "delete user" do assert_difference('User.count', -1) do - delete '/users/2.xml', {}, :authorization => credentials('admin') + delete '/users/2.xml', {}, credentials('admin') end assert_response :ok @@ -278,7 +278,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest should "delete user" do assert_difference('User.count', -1) do - delete '/users/2.json', {}, :authorization => credentials('admin') + delete '/users/2.json', {}, credentials('admin') end assert_response :ok From f57b372807d220a152be3efbd1f3e6ca036436a1 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 08:13:45 +0200 Subject: [PATCH 04/17] fixes time entry api tests by using correct authorization header --- test/integration/api_test/time_entries_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb index e9f01eb7ab..b94f71bfb2 100644 --- a/test/integration/api_test/time_entries_test.rb +++ b/test/integration/api_test/time_entries_test.rb @@ -22,7 +22,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "GET /time_entries.xml" do should "return time entries" do - get '/time_entries.xml', {}, :authorization => credentials('jsmith') + get '/time_entries.xml', {}, credentials('jsmith') assert_response :success assert_equal 'application/xml', @response.content_type assert_tag :tag => 'time_entries', @@ -32,7 +32,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "GET /time_entries/2.xml" do should "return requested time entry" do - get '/time_entries/2.xml', {}, :authorization => credentials('jsmith') + get '/time_entries/2.xml', {}, credentials('jsmith') assert_response :success assert_equal 'application/xml', @response.content_type assert_tag :tag => 'time_entry', @@ -44,7 +44,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "with issue_id" do should "return create time entry" do assert_difference 'TimeEntry.count' do - post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, :authorization => credentials('jsmith') + post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith') end assert_response :created assert_equal 'application/xml', @response.content_type @@ -62,7 +62,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "with project_id" do should "return create time entry" do assert_difference 'TimeEntry.count' do - post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, :authorization => credentials('jsmith') + post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith') end assert_response :created assert_equal 'application/xml', @response.content_type @@ -80,7 +80,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "with invalid parameters" do should "return errors" do assert_no_difference 'TimeEntry.count' do - post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}}, :authorization => credentials('jsmith') + post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}}, credentials('jsmith') end assert_response :unprocessable_entity assert_equal 'application/xml', @response.content_type @@ -94,7 +94,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "with valid parameters" do should "update time entry" do assert_no_difference 'TimeEntry.count' do - put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, :authorization => credentials('jsmith') + put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, credentials('jsmith') end assert_response :ok assert_equal 'API Update', TimeEntry.find(2).comments @@ -104,7 +104,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "with invalid parameters" do should "return errors" do assert_no_difference 'TimeEntry.count' do - put '/time_entries/2.xml', {:time_entry => {:hours => '', :comments => 'API Update'}}, :authorization => credentials('jsmith') + put '/time_entries/2.xml', {:time_entry => {:hours => '', :comments => 'API Update'}}, credentials('jsmith') end assert_response :unprocessable_entity assert_equal 'application/xml', @response.content_type @@ -117,7 +117,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest context "DELETE /time_entries/2.xml" do should "destroy time entry" do assert_difference 'TimeEntry.count', -1 do - delete '/time_entries/2.xml', {}, :authorization => credentials('jsmith') + delete '/time_entries/2.xml', {}, credentials('jsmith') end assert_response :ok assert_nil TimeEntry.find_by_id(2) From 81e03169e3234ff743ba1f316bea8ab081aae568 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 08:14:37 +0200 Subject: [PATCH 05/17] removes post issues#index route * just use get --- app/views/issues/index.html.erb | 1 + config/routes.rb | 8 -------- test/integration/issues_test.rb | 9 +++++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 3da5ab0f36..92c39cbdfb 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -47,6 +47,7 @@ { :url => { :set_filter => 1 }, :before => 'selectAllOptions("selected_columns");', :update => "content", + :method => :get, :complete => "apply_filters_observer()", :with => "Form.serialize('query_form')" }, :class => 'icon icon-checked' %> diff --git a/config/routes.rb b/config/routes.rb index 7d51059395..497c8e1ec3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,12 +133,8 @@ OpenProject::Application.routes.draw do # get a preview of a new issue (i.e. one without an ID) match '/new/preview' => 'previews#issue', :as => 'preview_new', :via => :post - # issues#index is right now used with get and post - # defining an extra route prevents confusion with create - match '/query' => 'issues#index', :via => :post end end - end # TODO: nest under issues resources @@ -169,9 +165,6 @@ OpenProject::Application.routes.draw do resources :issues do collection do - # issues#index is right now used with get and post - # defining an extra route prevents confusion with create - match '/query' => 'issues#index', :via => :post end resources :time_entries, :controller => 'timelog' @@ -186,7 +179,6 @@ OpenProject::Application.routes.draw do match '/projects/:id/members/new' => 'members#new' - resources :users, :member => { :edit_membership => :post, :destroy_membership => :post, diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 8814d0c0f9..5b8274c4f7 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -106,13 +106,14 @@ class IssuesTest < ActionController::IntegrationTest end end - def test_other_formats_links_on_post_index_without_project_id_in_url + def test_other_formats_links_on_get_index_without_project_id_in_url Role.anonymous.add_permission!(:export_issues) - post '/issues', :project_id => 'ecookbook' + get '/issues', :project_id => 'ecookbook' %w(Atom PDF CSV).each do |format| assert_tag :a, :content => format, :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}", + :class => format.downcase, :rel => 'nofollow' } end end @@ -126,9 +127,9 @@ class IssuesTest < ActionController::IntegrationTest end - def test_pagination_links_on_post_index_without_project_id_in_url + def test_pagination_links_on_get_index_without_project_id_in_url Setting.per_page_options = '2' - post '/issues', :project_id => 'ecookbook' + get '/issues', :project_id => 'ecookbook' assert_tag :a, :content => '2', :attributes => { :href => '/projects/ecookbook/issues?page=2' } From 80d225943184531f0cb0fe4ad5ca4d34ed32a34e Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 08:39:56 +0200 Subject: [PATCH 06/17] shows export links on global issues#index page again that where wrongfully hidden --- app/views/issues/index.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 92c39cbdfb..7cea5c1c7b 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -77,10 +77,10 @@ <% end %> <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => { :project_id => @project, :query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key } %> - <%= f.link_to 'CSV', :url => { :project_id => @project } %> - <%= f.link_to 'PDF', :url => { :project_id => @project } %> -<% end if User.current.allowed_to? :export_issues, @project %> + <%= f.link_to 'Atom', :url => { :project_id => @project, :query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key } %> + <%= f.link_to 'CSV', :url => { :project_id => @project } %> + <%= f.link_to 'PDF', :url => { :project_id => @project } %> +<% end if User.current.allowed_to? :export_issues, @project, :global => @project.nil? %> <% end %> <%= call_hook(:view_issues_index_bottom, { :issues => @issues, :project => @project, :query => @query }) %> From 2a804a0c7cd37f14b5e2600e92ab5cf2e7a2a261 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 08:47:10 +0200 Subject: [PATCH 07/17] removes deprecated verify declarations from issues_controller --- app/controllers/issues_controller.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 569dc169db..3ad5011843 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -46,14 +46,6 @@ class IssuesController < ApplicationController include IssuesHelper include Redmine::Export::PDF - verify :method => [:post, :delete], - :only => :destroy, - :render => { :nothing => true, :status => :method_not_allowed } - - verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } - verify :method => :post, :only => :bulk_update, :render => {:nothing => true, :status => :method_not_allowed } - verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } - def index sort_init(@query.sort_criteria.empty? ? [['parent', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns) From 55b4dd4842d651d5479048b13365d2e45e0c49cc Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 09:33:59 +0200 Subject: [PATCH 08/17] fixes menu_manager integration tests by explicitly using HTTP_ACCEPT_LANGUAGE header --- test/integration/lib/redmine/menu_manager_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/lib/redmine/menu_manager_test.rb b/test/integration/lib/redmine/menu_manager_test.rb index ba776c9ef2..beb641356f 100644 --- a/test/integration/lib/redmine/menu_manager_test.rb +++ b/test/integration/lib/redmine/menu_manager_test.rb @@ -20,7 +20,7 @@ class MenuManagerTest < ActionController::IntegrationTest def test_project_menu_with_specific_locale Setting.available_languages = [:fr, :en] - get 'projects/ecookbook/issues', { }, 'Accept-Language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' + get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' assert_tag :div, :attributes => { :id => 'main-menu' }, :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity), From 5dca73c8358b30c7b8b6a783a9effdb6b30779c3 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 09:35:36 +0200 Subject: [PATCH 09/17] uses content_for instead of yield to have a consistent usage --- app/views/layouts/base.html.erb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 22dba7b8f8..971b5f5a63 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -32,10 +32,10 @@ <% heads_for_wiki_formatter %> <%= call_hook :view_layouts_base_html_head %> -<%= yield :header_tags -%> +<%= content_for :header_tags -%> - +
@@ -95,14 +95,14 @@ <%= render_flash_messages %> - <% if @content_for_action_menu_main %> + <% if content_for?(:action_menu_main) %>
    - <%= yield :action_menu_main %> - <% if @content_for_action_menu_more %> + <%= content_for :action_menu_main %> + <% if content_for?(:action_menu_more) %> <% end %> @@ -116,9 +116,11 @@
From 050ea349f260839918385795e242073ac38010d4 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 09:35:54 +0200 Subject: [PATCH 10/17] removes unnecessary require --- test/integration/api_test/news_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb index 2a32c59b5e..24abbc750a 100644 --- a/test/integration/api_test/news_test.rb +++ b/test/integration/api_test/news_test.rb @@ -12,8 +12,8 @@ # See doc/COPYRIGHT.rdoc for more details. #++ require File.expand_path('../../../test_helper', __FILE__) -require 'pp' -class ApiTest::NewsTest < ActionController::IntegrationTest + +class ApiTest::NewsTest < ActionDispatch::IntegrationTest fixtures :all def setup From 5ec77ab57be8bddc68448b22420edd0146a38499 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 11:28:37 +0200 Subject: [PATCH 11/17] makes activities a resource * only index supported * is declared twice, once nested under projects * declares activities and activity to be synonyms with activity having precedence --- app/controllers/activities_controller.rb | 7 ++++--- config/routes.rb | 12 +++++------- test/integration/routing_test.rb | 20 ++++++++++++++++++-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index 2265284ed0..0108d92396 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -61,10 +61,11 @@ class ActivitiesController < ApplicationController private - # TODO: refactor, duplicated in projects_controller + # TODO: this should now be functionally identical to the implementation in application_controller + # double check and remove def find_optional_project - return true unless params[:id] - @project = Project.find(params[:id]) + return true unless params[:project_id] + @project = Project.find(params[:project_id]) authorize rescue ActiveRecord::RecordNotFound render_404 diff --git a/config/routes.rb b/config/routes.rb index 497c8e1ec3..75a470dd01 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -124,7 +124,7 @@ OpenProject::Application.routes.draw do # should probably belong to :member, but requires :copy_from instead # of the default :id get ':copy_from/copy', :action => "new", :on => :collection, :as => "copy" - + collection do get :all get :bulk_edit @@ -135,6 +135,8 @@ OpenProject::Application.routes.draw do end end + + resources :activity, :activities, :only => :index, :controller => 'activities' end # TODO: nest under issues resources @@ -172,6 +174,8 @@ OpenProject::Application.routes.draw do post :edit, :on => :member end + resources :activity, :activities, :only => :index, :controller => 'activities' + scope :controller => 'issue_relations', :via => :post do match '/issues/:issue_id/relations/:id', :action => :new match '/issues/:issue_id/relations/:id/destroy', :action => :destroy @@ -207,12 +211,6 @@ OpenProject::Application.routes.draw do # Destroy uses a get request to prompt the user before the actual DELETE request match '/projects/:id/destroy' => 'project#destroy', :via => :get, :as => 'project_destroy_confirm' - scope :controller => 'activities', :action => 'index', :via => :get do - match '/projects/:id/activity(.:format)' - match '/activity(.:format)' - end - - scope :controller => 'issue_categories' do match '/projects/:project_id/issue_categories/new', :action => :new end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 6ae25c4799..3dbee2c07c 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -15,8 +15,24 @@ require File.expand_path('../../test_helper', __FILE__) class RoutingTest < ActionController::IntegrationTest context "activities" do - should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil - should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom' + should route(:get, "/activity").to(:controller => 'activities', :action => 'index') + should route(:get, "/activity.atom").to(:controller => 'activities', :action => 'index', :format => 'atom') + should "route /activities to activities#index" do + assert_recognizes({ :controller => 'activities', :action => 'index' }, "/activities") + end + should "route /activites.atom to activities#index" do + assert_recognizes({ :controller => 'activities', :action => 'index', :format => 'atom' }, "/activities.atom") + end + + should route(:get, "projects/eCookbook/activity").to(:controller => 'activities', :action => 'index', :project_id => "eCookbook") + should route(:get, "projects/eCookbook/activity.atom").to(:controller => 'activities', :action => 'index', :project_id => "eCookbook", :format => 'atom') + + should "route project/eCookbook/activities to activities#index" do + assert_recognizes({ :controller => 'activities', :action => 'index', :project_id => "eCookbook" }, "/projects/eCookbook/activities") + end + should "route project/eCookbook/activites.atom to activities#index" do + assert_recognizes({ :controller => 'activities', :action => 'index', :format => 'atom', :project_id => "eCookbook" }, "/projects/eCookbook/activities.atom") + end end context "attachments" do From df9fbdfcfafe285b2100007d9b0eb779a3f1fd2f Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 13:57:49 +0200 Subject: [PATCH 12/17] lets attachments be resourceful * still way to much code for the route, even more than when using match but I hope that using resources will pay of * should allow the id to be the filename * redirects old routes to new ones --- config/routes.rb | 16 +++++++++++++--- test/integration/routing_test.rb | 27 +++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 75a470dd01..864316bb39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -236,9 +236,19 @@ OpenProject::Application.routes.draw do match '/projects/:id/repository/:action', :via => :post end - match '/attachments/:id' => 'attachments#show', :id => /\d+/ - match '/attachments/:id/:filename' => 'attachments#show', :id => /\d+/, :filename => /.*/ - match '/attachments/download/:id/:filename' => 'attachments#download', :id => /\d+/, :filename => /.*/ + resources :attachments, :only => [:show], :format => false do + member do + scope :via => :get, :constraints => { :id => /\d+/, :filename => /[^\/]*/ } do + match 'download(/:filename)' => 'attachments#download', :as => 'download' + match ':filename' => 'attachments#show' + end + end + end + # redirect for backwards compatibility + scope :constraints => { :id => /\d+/, :filename => /[^\/]*/ } do + match "/attachments/download/:id/:filename" => redirect("/attachments/%{id}/download/%{filename}"), :format => false + match "/attachments/download/:id" => redirect("/attachments/%{id}/download"), :format => false + end resources :groups diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 3dbee2c07c..2a04420fcd 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -36,10 +36,29 @@ class RoutingTest < ActionController::IntegrationTest end context "attachments" do - should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1' - should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext' - should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1' - should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext' + should route(:get, "/attachments/1").to( :controller => 'attachments', + :action => 'show', + :id => '1') + should route(:get, "/attachments/1/filename.ext").to( :controller => 'attachments', + :action => 'show', + :id => '1', + :filename => 'filename.ext' ) + should route(:get, "/attachments/1/download").to( :controller => 'attachments', + :action => 'download', + :id => '1' ) + should route(:get, "/attachments/1/download/filename.ext").to( :controller => 'attachments', + :action => 'download', + :id => '1', + :filename => 'filename.ext' ) + should "redirect /atttachments/download/1 to /attachments/1/download" do + get '/attachments/download/1' + assert_redirected_to '/attachments/1/download' + end + + should "redirect /atttachments/download/1/filename.ext to /attachments/1/download/filename.ext" do + get '/attachments/download/1/filename.ext' + assert_redirected_to '/attachments/1/download/filename.ext' + end end context "boards" do From 293400a890970134c6d6c0991995bcf05abd0941 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 16:28:57 +0200 Subject: [PATCH 13/17] rewrites labelled_tablular_form_for to work with resources --- app/helpers/application_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0141255ad3..885cc8a579 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -879,10 +879,11 @@ module ApplicationHelper content_tag("label", label_text) end - def labelled_tabular_form_for(name, object, options, &proc) + def labelled_tabular_form_for(record_or_name_or_array, *args, &proc) + options = args.extract_options! options[:html] ||= {} options[:html][:class] = 'tabular' unless options[:html].has_key?(:class) - form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc) + form_for(record_or_name_or_array, *(args << options.merge({:builder => TabularFormBuilder, :lang => current_language})), &proc) end def back_url_hidden_field_tag From 9cd5d4f26a97148683dbf6d7f5089c296ad7d5c2 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 9 Aug 2012 16:41:00 +0200 Subject: [PATCH 14/17] resourcified boards --- app/controllers/boards_controller.rb | 12 ++++-- app/views/boards/edit.html.erb | 2 +- app/views/boards/new.html.erb | 2 +- app/views/projects/settings/_boards.html.erb | 2 +- config/routes.rb | 16 +------- lib/redmine.rb | 2 +- test/functional/boards_controller_test.rb | 8 ++-- test/integration/routing_test.rb | 39 +++++++++++++++----- 8 files changed, 48 insertions(+), 35 deletions(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 04553d7abf..8600f436ea 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -57,19 +57,23 @@ class BoardsController < ApplicationController end end - verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } - def new + end + + def create @board = Board.new(params[:board]) @board.project = @project - if request.post? && @board.save + if @board.save flash[:notice] = l(:notice_successful_create) redirect_to_settings_in_projects end end def edit - if request.post? && @board.update_attributes(params[:board]) + end + + def update + if @board.update_attributes(params[:board]) redirect_to_settings_in_projects end end diff --git a/app/views/boards/edit.html.erb b/app/views/boards/edit.html.erb index ba4c8b5ac4..70d9f4b10b 100644 --- a/app/views/boards/edit.html.erb +++ b/app/views/boards/edit.html.erb @@ -1,6 +1,6 @@

<%= l(:label_board) %>

-<% labelled_tabular_form_for :board, @board, :url => {:action => 'edit', :id => @board} do |f| %> +<% labelled_tabular_form_for [@project, @board] do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <%= submit_tag l(:button_save) %> <% end %> diff --git a/app/views/boards/new.html.erb b/app/views/boards/new.html.erb index b89121880c..802984441f 100644 --- a/app/views/boards/new.html.erb +++ b/app/views/boards/new.html.erb @@ -1,6 +1,6 @@

<%= l(:label_board_new) %>

-<% labelled_tabular_form_for :board, @board, :url => {:action => 'new'} do |f| %> +<% labelled_tabular_form_for [@project, Board.new] do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <%= submit_tag l(:button_create) %> <% end %> diff --git a/app/views/projects/settings/_boards.html.erb b/app/views/projects/settings/_boards.html.erb index dd219c001e..b09d70afaf 100644 --- a/app/views/projects/settings/_boards.html.erb +++ b/app/views/projects/settings/_boards.html.erb @@ -19,7 +19,7 @@ <%= link_to_if_authorized l(:button_edit), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}, :class => 'icon icon-edit' %> - <%= link_to_if_authorized l(:button_delete), {:controller => 'boards', :action => 'destroy', :project_id => @project, :id => board}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> + <%= link_to_if_authorized l(:button_delete), {:controller => 'boards', :action => 'destroy', :project_id => @project, :id => board}, :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 864316bb39..1c04691a8d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,20 +52,6 @@ OpenProject::Application.routes.draw do end end - scope :controller => 'boards' do - scope :via => :get do - match '/projects/:project_id/boards', :action => :index - match '/projects/:project_id/boards/new', :action => :new - match '/projects/:project_id/boards/:id', :action => :show - match '/projects/:project_id/boards/:id.:format', :action => :show - match '/projects/:project_id/boards/:id/edit', :action => :edit - end - scope :via => :post do - match '/projects/:project_id/boards', :action => :new - match '/projects/:project_id/boards/:id/:action', :action => /edit|destroy/ - end - end - scope :controller => 'documents' do scope :via => :get do match '/projects/:project_id/documents', :action => :index @@ -137,6 +123,8 @@ OpenProject::Application.routes.draw do end resources :activity, :activities, :only => :index, :controller => 'activities' + + resources :boards end # TODO: nest under issues resources diff --git a/lib/redmine.rb b/lib/redmine.rb index a4863a8b8c..7083e09943 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -146,7 +146,7 @@ Redmine::AccessControl.map do |map| end map.project_module :boards do |map| - map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member + map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true map.permission :add_messages, {:messages => [:new, :reply, :quote]} map.permission :edit_messages, {:messages => :edit}, :require => :member diff --git a/test/functional/boards_controller_test.rb b/test/functional/boards_controller_test.rb index 07dfd106e9..808c3742bd 100644 --- a/test/functional/boards_controller_test.rb +++ b/test/functional/boards_controller_test.rb @@ -49,10 +49,10 @@ class BoardsControllerTest < ActionController::TestCase assert_not_nil assigns(:topics) end - def test_post_new + def test_create @request.session[:user_id] = 2 assert_difference 'Board.count' do - post :new, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} + post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'} end assert_redirected_to '/projects/ecookbook/settings/boards' end @@ -75,10 +75,10 @@ class BoardsControllerTest < ActionController::TestCase assert_not_nil assigns(:messages) end - def test_post_edit + def test_update @request.session[:user_id] = 2 assert_no_difference 'Board.count' do - post :edit, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} + put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'} end assert_redirected_to '/projects/ecookbook/settings/boards' assert_equal 'Testing', Board.find(2).name diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 2a04420fcd..1369d511c6 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -62,15 +62,36 @@ class RoutingTest < ActionController::IntegrationTest end context "boards" do - should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination' - should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination' - should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44' - should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom' - should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44' - - should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination' - should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44' - should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44' + should route(:get, "/projects/world_domination/boards").to( :controller => 'boards', + :action => 'index', + :project_id => 'world_domination') + should route(:get, "/projects/world_domination/boards/new").to( :controller => 'boards', + :action => 'new', + :project_id => 'world_domination') + should route(:post, "/projects/world_domination/boards").to( :controller => 'boards', + :action => 'create', + :project_id => 'world_domination') + should route(:get, "/projects/world_domination/boards/44").to( :controller => 'boards', + :action => 'show', + :project_id => 'world_domination', + :id => '44') + should route(:get, "/projects/world_domination/boards/44.atom").to( :controller => 'boards', + :action => 'show', + :project_id => 'world_domination', + :id => '44', + :format => 'atom') + should route(:get, "/projects/world_domination/boards/44/edit").to( :controller => 'boards', + :action => 'edit', + :project_id => 'world_domination', + :id => '44') + should route(:put, "/projects/world_domination/boards/44").to( :controller => 'boards', + :action => 'update', + :project_id => 'world_domination', + :id => '44') + should route(:delete, "/projects/world_domination/boards/44").to( :controller => 'boards', + :action => 'destroy', + :project_id => 'world_domination', + :id => '44') end From 0d597b5363b81ee174a4985c802495caeae6c7da Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Mon, 13 Aug 2012 10:41:28 +0200 Subject: [PATCH 15/17] rewrites routes for issues and associated resources * controllers only used by issue (calendar, gantt, auto_complete, context_menu, moves) are relocated into the issues namespace * changed a lot of actions to use the appropriate http-verb * uses named_routes where possible * cleaned up context_menu code --- .../{ => issues}/auto_completes_controller.rb | 2 +- .../{ => issues}/calendars_controller.rb | 11 +- .../{ => issues}/context_menus_controller.rb | 3 +- .../{ => issues}/gantts_controller.rb | 9 +- .../moves_controller.rb} | 8 +- app/controllers/issues_controller.rb | 2 +- app/controllers/journals_controller.rb | 38 +- app/controllers/watchers_controller.rb | 22 +- app/helpers/application_helper.rb | 33 +- app/helpers/journals_helper.rb | 9 +- app/helpers/watchers_helper.rb | 38 +- app/models/journal.rb | 11 + app/views/attachments/_links.html.erb | 4 +- app/views/common/_calendar.html.erb | 2 +- app/views/context_menus/issues.html.erb | 131 ---- app/views/issue_relations/_form.html.erb | 2 +- app/views/issues/_action_menu.html.erb | 10 +- app/views/issues/_form.html.erb | 3 +- app/views/issues/_subissue_row.html.erb | 4 +- .../auto_completes/issues.html.erb | 0 app/views/issues/bulk_edit.html.erb | 2 +- .../calendars/index.html.erb} | 5 +- .../issues/context_menus/issues.html.erb | 127 ++++ app/views/{ => issues}/gantts/show.html.erb | 13 +- .../moves}/new.html.erb | 0 app/views/journals/_notes_form.html.erb | 2 +- app/views/queries/_filters.html.erb | 2 +- app/views/watchers/_watchers.html.erb | 11 +- config/routes.rb | 91 ++- lib/redmine.rb | 12 +- lib/redmine/helpers/gantt.rb | 2 +- .../functional/attachments_controller_test.rb | 4 +- .../auto_completes_controller_test.rb | 4 +- .../{ => issues}/calendars_controller_test.rb | 14 +- .../context_menus_controller_test.rb | 34 +- .../{ => issues}/gantts_controller_test.rb | 20 +- .../moves_controller_test.rb} | 16 +- test/functional/issues_controller_test.rb | 38 +- test/functional/users_controller_test.rb | 2 +- test/functional/watchers_controller_test.rb | 2 +- test/functional/wiki_controller_test.rb | 2 +- test/integration/routing_test.rb | 659 ++++++++++-------- 42 files changed, 771 insertions(+), 633 deletions(-) rename app/controllers/{ => issues}/auto_completes_controller.rb (95%) rename app/controllers/{ => issues}/calendars_controller.rb (91%) rename app/controllers/{ => issues}/context_menus_controller.rb (97%) rename app/controllers/{ => issues}/gantts_controller.rb (93%) rename app/controllers/{issue_moves_controller.rb => issues/moves_controller.rb} (88%) delete mode 100644 app/views/context_menus/issues.html.erb rename app/views/{ => issues}/auto_completes/issues.html.erb (100%) rename app/views/{calendars/show.html.erb => issues/calendars/index.html.erb} (92%) create mode 100644 app/views/issues/context_menus/issues.html.erb rename app/views/{ => issues}/gantts/show.html.erb (91%) rename app/views/{issue_moves => issues/moves}/new.html.erb (100%) rename test/functional/{ => issues}/auto_completes_controller_test.rb (94%) rename test/functional/{ => issues}/calendars_controller_test.rb (89%) rename test/functional/{ => issues}/context_menus_controller_test.rb (85%) rename test/functional/{ => issues}/gantts_controller_test.rb (86%) rename test/functional/{issue_moves_controller_test.rb => issues/moves_controller_test.rb} (87%) diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/issues/auto_completes_controller.rb similarity index 95% rename from app/controllers/auto_completes_controller.rb rename to app/controllers/issues/auto_completes_controller.rb index becc957d17..bfc3c42c6f 100644 --- a/app/controllers/auto_completes_controller.rb +++ b/app/controllers/issues/auto_completes_controller.rb @@ -12,7 +12,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -class AutoCompletesController < ApplicationController +class Issues::AutoCompletesController < ApplicationController before_filter :find_project def issues diff --git a/app/controllers/calendars_controller.rb b/app/controllers/issues/calendars_controller.rb similarity index 91% rename from app/controllers/calendars_controller.rb rename to app/controllers/issues/calendars_controller.rb index cb16e7380f..a20444b40d 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/issues/calendars_controller.rb @@ -12,7 +12,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -class CalendarsController < ApplicationController +class Issues::CalendarsController < ApplicationController menu_item :calendar before_filter :find_optional_project @@ -21,7 +21,7 @@ class CalendarsController < ApplicationController include QueriesHelper include SortHelper - def show + def index if params[:year] and params[:year].to_i > 1900 @year = params[:year].to_i if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 @@ -44,11 +44,6 @@ class CalendarsController < ApplicationController @calendar.events = events end - render :action => 'show', :layout => false if request.xhr? + render :layout => !request.xhr? end - - def update - show - end - end diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/issues/context_menus_controller.rb similarity index 97% rename from app/controllers/context_menus_controller.rb rename to app/controllers/issues/context_menus_controller.rb index 628212a2c1..d0f22439c1 100644 --- a/app/controllers/context_menus_controller.rb +++ b/app/controllers/issues/context_menus_controller.rb @@ -12,7 +12,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -class ContextMenusController < ApplicationController +class Issues::ContextMenusController < ApplicationController def issues @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) @@ -53,5 +53,4 @@ class ContextMenusController < ApplicationController render :layout => false end - end diff --git a/app/controllers/gantts_controller.rb b/app/controllers/issues/gantts_controller.rb similarity index 93% rename from app/controllers/gantts_controller.rb rename to app/controllers/issues/gantts_controller.rb index b5404fc475..1eb4110ab4 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/issues/gantts_controller.rb @@ -12,7 +12,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -class GanttsController < ApplicationController +class Issues::GanttsController < ApplicationController menu_item :gantt before_filter :find_optional_project @@ -22,7 +22,7 @@ class GanttsController < ApplicationController include SortHelper include Redmine::Export::PDF - def show + def index @gantt = Redmine::Helpers::Gantt.new(params) @gantt.project = @project retrieve_query @@ -37,9 +37,4 @@ class GanttsController < ApplicationController format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") } end end - - def update - show - end - end diff --git a/app/controllers/issue_moves_controller.rb b/app/controllers/issues/moves_controller.rb similarity index 88% rename from app/controllers/issue_moves_controller.rb rename to app/controllers/issues/moves_controller.rb index 70a0ea04c2..d3c5ff5172 100644 --- a/app/controllers/issue_moves_controller.rb +++ b/app/controllers/issues/moves_controller.rb @@ -12,7 +12,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -class IssueMovesController < ApplicationController +class Issues::MovesController < ApplicationController default_search_scope :issues before_filter :find_issues, :check_project_uniqueness before_filter :authorize @@ -43,12 +43,12 @@ class IssueMovesController < ApplicationController if params[:follow] if @issues.size == 1 && moved_issues.size == 1 - redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first + redirect_to issue_path(moved_issues.first) else - redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project) + redirect_to project_issues_path(@target_project || @project) end else - redirect_to :controller => 'issues', :action => 'index', :project_id => @project + redirect_to project_issues_path(@project) end return end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 3ad5011843..2b3ade80dd 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -93,7 +93,7 @@ class IssuesController < ApplicationController end def show - @journals = @issue.journals.changing.find(:all, :include => [:user], :order => "#{Journal.table_name}.created_at ASC") + @journals = @issue.journals.changing.find(:all, :include => [:user, :journaled], :order => "#{Journal.table_name}.created_at ASC") @journals.reverse! if User.current.wants_comments_in_reverse_order? @changesets = @issue.changesets.visible.all @changesets.reverse! if User.current.wants_comments_in_reverse_order? diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index bf217aa650..e7710fca74 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -13,10 +13,10 @@ #++ class JournalsController < ApplicationController - before_filter :find_journal, :only => [:edit, :diff] + before_filter :find_journal, :only => [:edit, :update] before_filter :find_issue, :only => [:new] before_filter :find_optional_project, :only => [:index] - before_filter :authorize, :only => [:new, :edit, :diff] + before_filter :authorize, :only => [:new, :edit, :update ] accept_key_auth :index menu_item :issues @@ -64,23 +64,23 @@ class JournalsController < ApplicationController def edit (render_403; return false) unless @journal.editable_by?(User.current) - if request.post? - @journal.update_attribute(:notes, params[:notes]) if params[:notes] - @journal.destroy if @journal.details.empty? && @journal.notes.blank? - call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) - respond_to do |format| - format.html { redirect_to :controller => @journal.journaled.class.name.pluralize.downcase, - :action => 'show', :id => @journal.journaled_id } - format.js { render :action => 'update' } - end - else - respond_to do |format| - format.html { - # TODO: implement non-JS journal update - render :nothing => true - } - format.js - end + respond_to do |format| + format.html { + # TODO: implement non-JS journal update + render :nothing => true + } + format.js + end + end + + def update + @journal.update_attribute(:notes, params[:notes]) if params[:notes] + @journal.destroy if @journal.details.empty? && @journal.notes.blank? + call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) + respond_to do |format| + format.html { redirect_to :controller => @journal.journaled.class.name.pluralize.downcase, + :action => 'show', :id => @journal.journaled_id } + format.js { render :action => 'update' } end end diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 52e2b8b503..110c092214 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -13,14 +13,12 @@ #++ class WatchersController < ApplicationController + before_filter :find_watched_by_object, :except => [:destroy] + before_filter :find_watched_by_id, :only => [:destroy] before_filter :find_project before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch] before_filter :authorize, :only => [:new, :destroy] - verify :method => :post, - :only => [ :watch, :unwatch ], - :render => { :nothing => true, :status => :method_not_allowed } - def watch if @watched.respond_to?(:visible?) && !@watched.visible?(User.current) render_403 @@ -50,7 +48,7 @@ class WatchersController < ApplicationController end def destroy - @watched.set_watcher(User.find(params[:user_id]), false) if request.post? + @watched.set_watcher(@watch.user, false) respond_to do |format| format.html { redirect_to :back } format.js do @@ -62,15 +60,23 @@ class WatchersController < ApplicationController end private - def find_project - klass = params[:object_type].camelcase.constantize + def find_watched_by_object + klass = params[:object_type].singularize.camelcase.constantize return false unless klass.respond_to?('watched_by') @watched = klass.find(params[:object_id]) - @project = @watched.project rescue render_404 end + def find_watched_by_id + @watch = Watcher.find(params[:id], :include => { :watchable => [:project] } ) + @watched = @watch.watchable + end + + def find_project + @project = @watched.project + end + def set_watcher(user, watching) @watched.set_watcher(user, watching) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 885cc8a579..5e131a47a5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -123,9 +123,10 @@ module ApplicationHelper end end closed = issue.closed? ? content_tag(:span, l(:label_closed_issues), :class => "hidden-for-sighted") : "" - s = link_to closed + options[:before_text].to_s + "#{h(issue.tracker)} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, - :class => issue.css_classes, - :title => title + s = link_to "#{closed}#{h(options[:before_text].to_s)}#{h(issue.tracker)} ##{issue.id}".html_safe, + issue, + :class => issue.css_classes, + :title => h(title) s << ": #{h subject}" if subject s = "#{h issue.project} - " + s if options[:project] s @@ -969,6 +970,32 @@ module ApplicationHelper link_to h(name), url, options end + # TODO: need a decorator to clean this up + def context_menu_entry(args) + db_attribute = args[:db_attribute] || "#{args[:attribute]}_id" + + content_tag :li, :class => "folder #{args[:attribute]}" do + ret = link_to((args[:title] || l(:"field_#{args[:attribute]}")), "#", :class => "context_item") + + ret += content_tag :ul do + args[:collection].collect do |(s, name)| + content_tag :li do + context_menu_link (name || s), bulk_update_issues_path(:ids => args[:updated_object_ids], + :issue => { db_attribute => s }, + :back_url => args[:back_url]), + :method => :put, + :selected => args[:selected].call(s), + :disabled => args[:disabled].call(s) + end + end.join.html_safe + end + + ret += content_tag :div, '', :class => "submenu" + + ret + end + end + def calendar_for(field_id) include_calendar_headers_tags image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger", :alt => l(:label_calendar_show)}) + diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index f43fa18e5d..1ff30a21c7 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -76,8 +76,13 @@ module JournalsHelper unless journal.notes.blank? links = [].tap do |l| if reply_links - l << link_to_remote(image_tag('comment.png', :alt => l(:button_quote), :title => l(:button_quote)), - :url => {:controller => controller, :action => action, :id => model, :journal_id => journal}) + l << link_to(image_tag('comment.png', :alt => l(:button_quote), :title => l(:button_quote)), + { :controller => controller, + :action => action, + :id => model, + :journal_id => journal }, + :method => :get, + :remote => true) end if editable l << link_to_in_place_notes_editor(image_tag('edit.png', :alt => l(:button_edit), :title => l(:button_edit)), "journal-#{journal.id}-notes", diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index ba29e8d770..e8014144d5 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -30,41 +30,39 @@ module WatchersHelper # Create a link to watch/unwatch object # # * :replace - a string or array of strings with css selectors that will be updated, whenever the watcher status is changed - def watcher_link(object, user, options = {:replace => '.watcher_link', :class => 'watcher_link'}) + def watcher_link(object, user, options = { :replace => '.watcher_link', :class => 'watcher_link' }) options = options.with_indifferent_access raise ArgumentError, 'Missing :replace option in options hash' if options['replace'].blank? return '' unless user && user.logged? && object.respond_to?('watched_by?') watched = object.watched_by?(user) - url = {:controller => 'watchers', - :action => (watched ? 'unwatch' : 'watch'), - :object_type => object.class.to_s.underscore, - :object_id => object.id, - :replace => options.delete('replace')} - url_options = {:url => url} - - html_options = options.merge(:href => url_for(url)) + html_options = options + path = send(:"#{(watched ? 'unwatch' : 'watch')}_path", :object_type => object.class.to_s.underscore.pluralize, + :object_id => object.id, + :replace => options.delete('replace') ) html_options[:class] = html_options[:class].to_s + (watched ? ' icon icon-fav' : ' icon icon-fav-off') - link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)), url_options, html_options) + method = watched ? + :delete : + :post + + label = watched ? + l(:button_unwatch) : + l(:button_watch) + + link_to(label, path, html_options.merge(:remote => true, :method => method)) end # Returns a comma separated list of users watching the given object def watchers_list(object) remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) - lis = object.watcher_users.collect do |user| - s = avatar(user, :size => "16").to_s + link_to_user(user, :class => 'user').to_s + lis = object.watchers.collect do |watch| + s = avatar(watch.user, :size => "16").to_s + link_to_user(watch.user, :class => 'user').to_s if remove_allowed - url = {:controller => 'watchers', - :action => 'destroy', - :object_type => object.class.to_s.underscore, - :object_id => object.id, - :user_id => user} - s += ' ' + link_to_remote(image_tag('delete.png', :alt => l(:button_delete), :title => l(:button_delete)), - {:url => url}, - :href => url_for(url), + s += ' ' + link_to(image_tag('delete.png', :alt => l(:button_delete), :title => l(:button_delete)), + watcher_path(watch), :method => :delete, :remote => true, :style => "vertical-align: middle", :class => "delete") end diff --git a/app/models/journal.rb b/app/models/journal.rb index fc09049266..70a8018c01 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -48,6 +48,17 @@ class Journal < ActiveRecord::Base # logs like the history on issue#show scope "changing", :conditions => ["version > 1"] + # let all child classes have Journal as it's model name + # used to not having to create another route for every subclass of Journal + def self.inherited(child) + child.instance_eval do + def model_name + Journal.model_name + end + end + super + end + def touch_journaled_after_creation journaled.touch end diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 31e18d9388..6c15a41bf2 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -5,9 +5,9 @@ (<%= number_to_human_size attachment.filesize %>) <% if options[:deletable] %> <%= link_to image_tag('delete.png', :alt => l(:button_delete), :title => l(:button_delete)), - { :controller => 'attachments', :action => 'destroy', :id => attachment }, + attachment_path(attachment), { :confirm => l(:text_are_you_sure), - :method => :post, + :method => :delete, :class => 'delete', :title => l(:button_delete) } %> <% end %> diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 842812fd88..4b162afc97 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -13,7 +13,7 @@ while day <= calendar.enddt %> <% if i.is_a? Issue %>
<%= h("#{i.project} -") unless @project && @project == i.project %> - <% date_img = '' %> + <%# date_img = '' %> <% if day == i.start_date and day == i.due_date %> <% date_img = image_tag("bullet_diamond.png", :title => l(:text_tip_issue_begin_end_day), :alt => l(:text_tip_issue_begin_end_day), :class => "imgtag-icon") %> diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb deleted file mode 100644 index ca549998ba..0000000000 --- a/app/views/context_menus/issues.html.erb +++ /dev/null @@ -1,131 +0,0 @@ - diff --git a/app/views/issue_relations/_form.html.erb b/app/views/issue_relations/_form.html.erb index 4f955ac4df..e6c6efab9c 100644 --- a/app/views/issue_relations/_form.html.erb +++ b/app/views/issue_relations/_form.html.erb @@ -3,7 +3,7 @@

<%= f.select :relation_type, collection_for_relation_type_select, {}, :onchange => "setPredecessorFieldsVisibility();" %> <%= l(:label_issue) %> #<%= f.text_field :issue_to_id, :size => 10 %>

-<%= javascript_tag "observeRelatedIssueField('#{auto_complete_issues_path(:id => @issue, :project_id => @project, :escape => false) }')" %> +<%= javascript_tag "observeRelatedIssueField('#{issues_auto_complete_path(:id => @issue, :project_id => @project, :escape => false) }')" %> diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb index 1993b29727..5cbb66dd92 100644 --- a/app/views/issues/_action_menu.html.erb +++ b/app/views/issues/_action_menu.html.erb @@ -10,5 +10,11 @@ <%= li_unless_nil(link_to_if_authorized l(:button_duplicate), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-duplicate') %> <%= li_unless_nil(link_to_if_authorized l(:button_copy), {:controller => 'issue_moves', :action => 'new', :id => @issue, :copy_options => {:copy => 't'}}, :class => 'icon icon-copy') %> <%= li_unless_nil(link_to_if_authorized l(:button_move), {:controller => 'issue_moves', :action => 'new', :id => @issue}, :class => 'icon icon-move') %> - <%= li_unless_nil(link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => (@issue.leaf? ? l(:text_are_you_sure) : l(:text_are_you_sure_with_children)), :method => :post, :class => 'icon icon-del') %> -<% end %> \ No newline at end of file + <%= li_unless_nil(link_to_if_authorized l(:button_delete), { :controller => 'issues', + :action => 'destroy', + :id => @issue }, + :confirm => (@issue.leaf? ? l(:text_are_you_sure) : l(:text_are_you_sure_with_children)), + :remote => true, + :method => :delete , + :class => 'icon icon-del' ) %> +<% end %> diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index f0734c42a7..80c13fcae8 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -4,6 +4,7 @@

<%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %>

<%= observe_field :issue_tracker_id, :url => { :action => :new, :project_id => @project, :id => @issue }, :update => :attributes, + :method => :get, :with => "Form.serialize('issue-form')" %>

<%= f.text_field :subject, :size => 80, :required => true %>

@@ -11,7 +12,7 @@ <% if User.current.allowed_to?(:manage_subtasks, @project) %>

<%= f.text_field :parent_issue_id, :size => 10, :title => l(:description_autocomplete) %>

-<%= javascript_tag "observeParentIssueField('#{auto_complete_issues_path(:id => @issue, :project_id => @project, :escape => false) }')" %> +<%= javascript_tag "observeParentIssueField('#{issues_auto_complete_path(:id => @issue, :project_id => @project, :escape => false) }')" %> <% end %>

<%= f.text_area :description, diff --git a/app/views/issues/_subissue_row.html.erb b/app/views/issues/_subissue_row.html.erb index 6942f5b0f8..58bc75fdc5 100644 --- a/app/views/issues/_subissue_row.html.erb +++ b/app/views/issues/_subissue_row.html.erb @@ -18,7 +18,7 @@ end title << " #{h(issue.tracker.name)} ##{issue.id}" - issue_text = link_to(title, issue, :class => issue.css_classes) + issue_text = link_to(title.html_safe, issue, :class => issue.css_classes) end issue_text << ": " issue_text << truncate(issue.subject, :length => 60) @@ -30,7 +30,7 @@ content_tag('td', h(issue.status)), content_tag('td', link_to_user(issue.assigned_to)), content_tag('td', link_to_version(issue.fixed_version)) - ].join, + ].join.html_safe, :class => css_classes.join(' ') ) %> diff --git a/app/views/auto_completes/issues.html.erb b/app/views/issues/auto_completes/issues.html.erb similarity index 100% rename from app/views/auto_completes/issues.html.erb rename to app/views/issues/auto_completes/issues.html.erb diff --git a/app/views/issues/bulk_edit.html.erb b/app/views/issues/bulk_edit.html.erb index d0f04e24a0..113d68f5c6 100644 --- a/app/views/issues/bulk_edit.html.erb +++ b/app/views/issues/bulk_edit.html.erb @@ -64,7 +64,7 @@ <%= text_field_tag 'issue[parent_issue_id]', '', :size => 10 %>

-<%= javascript_tag "observeParentIssueField('#{auto_complete_issues_path(:project_id => @project) }')" %> +<%= javascript_tag "observeParentIssueField('#{issues_auto_complete_path }')" %> <% end %>

diff --git a/app/views/calendars/show.html.erb b/app/views/issues/calendars/index.html.erb similarity index 92% rename from app/views/calendars/show.html.erb rename to app/views/issues/calendars/index.html.erb index c6ef73a5bd..39af006f63 100644 --- a/app/views/calendars/show.html.erb +++ b/app/views/issues/calendars/index.html.erb @@ -1,6 +1,6 @@

<%= @query.new_record? ? l(:label_calendar) : h(@query.name) %>

-<% form_tag(calendar_path, :method => :put, :id => 'query_form') do %> +<% form_tag(issues_calendar_index_path, :method => :get, :id => 'query_form') do %> <%= hidden_field_tag('project_id', @project.to_param) if @project%>
"> <%= l(:label_filter_plural) %> @@ -21,13 +21,14 @@ <%= link_to_remote l(:button_apply), { :url => { :set_filter => 1 }, + :method => :get, :update => "content", :with => "Form.serialize('query_form')" }, :class => 'icon icon-checked' %> <%= link_to_remote l(:button_clear), { :url => { :project_id => @project, :set_filter => 1 }, - :method => :put, + :method => :get, :update => "content", }, :class => 'icon icon-reload' %>

diff --git a/app/views/issues/context_menus/issues.html.erb b/app/views/issues/context_menus/issues.html.erb new file mode 100644 index 0000000000..8fdcba6af9 --- /dev/null +++ b/app/views/issues/context_menus/issues.html.erb @@ -0,0 +1,127 @@ + diff --git a/app/views/gantts/show.html.erb b/app/views/issues/gantts/show.html.erb similarity index 91% rename from app/views/gantts/show.html.erb rename to app/views/issues/gantts/show.html.erb index fb592a5b3c..44b3a6a84b 100644 --- a/app/views/gantts/show.html.erb +++ b/app/views/issues/gantts/show.html.erb @@ -1,7 +1,7 @@ <% @gantt.view = self %>

<%= @query.new_record? ? l(:label_gantt) : h(@query.name) %>

-<% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %> +<% form_tag(issues_gantt_index_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :get, :id => 'query_form') do %> <%= hidden_field_tag('project_id', @project.to_param) if @project%>
"> <%= l(:label_filter_plural) %> @@ -24,13 +24,14 @@ <%= link_to_remote l(:button_apply), { :url => { :set_filter => 1 }, + :method => :get, :update => "content", :with => "Form.serialize('query_form')" }, :class => 'icon icon-checked' %> <%= link_to_remote l(:button_clear), { :url => { :project_id => @project, :set_filter => 1 }, - :method => :put, + :method => :get, :update => "content", }, :class => 'icon icon-reload' %>

@@ -178,8 +179,12 @@ if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %> - - + +
<%= link_to_content_update(l(:label_previous), params.merge(@gantt.params_previous), :class => 'navigate-left') %><%= link_to_content_update(l(:label_next), params.merge(@gantt.params_next), :class => 'navigate-right') %> + <%= link_to(l(:label_previous), params.merge(@gantt.params_previous), { :class => 'navigate-left', :method => :get } ) %> + + <%= link_to(l(:label_next), params.merge(@gantt.params_next), :class => 'navigate-right') %> +
diff --git a/app/views/issue_moves/new.html.erb b/app/views/issues/moves/new.html.erb similarity index 100% rename from app/views/issue_moves/new.html.erb rename to app/views/issues/moves/new.html.erb diff --git a/app/views/journals/_notes_form.html.erb b/app/views/journals/_notes_form.html.erb index 196045109f..67bf1c0932 100644 --- a/app/views/journals/_notes_form.html.erb +++ b/app/views/journals/_notes_form.html.erb @@ -1,4 +1,4 @@ -<% form_remote_tag(:url => {}, :html => { :id => "journal-#{@journal.id}-form" }) do %> +<% form_for(@journal, { :html => { :id => "journal-#{@journal.id}-form" } , :remote => true } ) do %> <%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted" %> <%= text_area_tag :notes, @journal.notes, :class => 'wiki-edit', diff --git a/app/views/queries/_filters.html.erb b/app/views/queries/_filters.html.erb index 8501de916a..06b39ff1dc 100644 --- a/app/views/queries/_filters.html.erb +++ b/app/views/queries/_filters.html.erb @@ -79,7 +79,7 @@ Event.observe(document,"dom:loaded", apply_filters_observer); <% query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.each do |filter| %> <% field = filter[0] options = filter[1] %> - id="tr_<%= field %>" class="filter"> + id="tr_<%= field %>" class="filter"> <%= check_box_tag 'f[]', field, query.has_filter?(field), :onclick => "toggle_filter('#{field}');", :id => "cb_#{field}" %> diff --git a/app/views/watchers/_watchers.html.erb b/app/views/watchers/_watchers.html.erb index 9d4748cbbd..23f0e9582a 100644 --- a/app/views/watchers/_watchers.html.erb +++ b/app/views/watchers/_watchers.html.erb @@ -1,10 +1,9 @@ <%= l(:label_issue_watchers) %> (<%= watched.watcher_users.size %>) -(<%= link_to_remote(l(:button_add_watcher), - :url => {:controller => 'watchers', - :action => 'new', - :object_type => watched.class.name.underscore, - :object_id => watched}, - :method => :get) if User.current.allowed_to?(:add_issue_watchers, @project) +(<%= link_to(l(:button_add_watcher), new_watcher_path(:object_type => watched.class.name.underscore.pluralize, + :object_id => watched), + :method => :get, + :remote => true + ) if User.current.allowed_to?(:add_issue_watchers, @project) %>) <% unless @watcher.nil? %> <% remote_form_for(:watcher, @watcher, diff --git a/config/routes.rb b/config/routes.rb index 1c04691a8d..93a86793a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,6 +65,30 @@ OpenProject::Application.routes.draw do end end + # only providing routes for journals when there are multiple subclasses of journals + # all subclasses will look for the journals routes + resources :journals, :only => [:edit, :update] + + namespace :issues do + end + + # generic route for adding/removing watchers + # looks to be ressourceful + scope ':object_type/:object_id', :constraints => { :object_type => /issues/, + :object_id => /\d+/ } do + resources :watchers, :only => [:new] + + match '/watch' => 'watchers#watch', :via => :post + match '/unwatch' => 'watchers#unwatch', :via => :delete + end + + resources :watchers, :only => [:destroy] + + # TODO: remove + scope "issues" do + match 'changes' => 'journals#index', :as => 'changes' + end + resources :projects do member do # this route let's you access the project specific settings (by tab) @@ -106,19 +130,21 @@ OpenProject::Application.routes.draw do :date_index => :get } - resources :issues do + namespace :issues do + resources :gantt, :controller => 'gantts', :only => [:index] + resources :calendar, :controller => 'calendars', :only => [:index] + end + + resources :issues, :except => [:show, :edit, :update, :destroy] do # should probably belong to :member, but requires :copy_from instead # of the default :id get ':copy_from/copy', :action => "new", :on => :collection, :as => "copy" collection do get :all - get :bulk_edit - post :bulk_update # get a preview of a new issue (i.e. one without an ID) match '/new/preview' => 'previews#issue', :as => 'preview_new', :via => :post - end end @@ -127,45 +153,53 @@ OpenProject::Application.routes.draw do resources :boards end - # TODO: nest under issues resources - scope 'issues' do - match '/move' => "issue_moves#create", :via => :post - match '/move/new' => "issue_moves#new", :via => :get, :as => "new_issue_move" + # this is to support global actions on issues and + # for backwards compatibility + namespace :issues do + resources :gantt, :controller => 'gantts', :only => [:index] + resources :calendar, :controller => 'calendars', :only => [:index] + + # have a global autocompleter for issues + # TODO: make this ressourceful + match 'auto_complete' => 'auto_completes#issues', :via => [:get, :post], :format => false + + # TODO: separate routes and action for get and post + match 'context_menu' => 'context_menus#issues', :via => [:get, :post], :format => false + + resource :move, :controller => 'moves', :only => [:new, :create] + end + + # TODO: remove create as issues should be created scoped under project + resources :issues, :only => [:create, :show, :edit, :update, :destroy] do + resources :time_entries, :controller => 'timelog' + + member do + # this route is defined so that it has precedence of the one defined on the collection + delete :destroy + end + + collection do + get :bulk_edit, :format => false + put :bulk_update, :format => false + + delete :destroy + end end # Misc issue routes. TODO: move into resources - match '/issues/auto_complete' => 'autoCompletes#issues', :as => 'auto_complete_issues' match '/issues/preview/:id' => 'previews#issue', :as => 'preview_issue' # TODO: would look nicer as /issues/:id/preview - match '/issues/context_menu' => 'issues#context_menu', :as => 'issues_context_menu' - match '/issues/changes' => 'journals#index', :as => 'issue_changes' - match '/issues/bulk_edit' => 'issues#bulk_edit', :via => :get, :as => 'bulk_edit_issue' - match '/issues/bulk_edit' => 'issues#bulk_udpate', :via => :post, :as => 'bulk_update_issue' match '/issues/:id/quoted' => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue' match '/issues/:id/destroy' => 'issues#destroy', :via => :post # legacy - resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update] - resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update] - resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update] - resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update] - scope :controller => 'reports', :via => :get do match '/projects/:id/issues/report', :action => :issue_report match '/projects/:id/issues/report/:detail', :action => :issue_report_details end - resources :issues do - collection do - end - - resources :time_entries, :controller => 'timelog' - - post :edit, :on => :member - end - resources :activity, :activities, :only => :index, :controller => 'activities' scope :controller => 'issue_relations', :via => :post do - match '/issues/:issue_id/relations/:id', :action => :new + match '/issues/:issue_id/relations(/:id)', :action => :new match '/issues/:issue_id/relations/:id/destroy', :action => :destroy end @@ -241,7 +275,6 @@ OpenProject::Application.routes.draw do resources :groups #left old routes at the bottom for backwards compat - match '/projects/:project_id/issues(/:action)', :controller => 'issues' match '/projects/:project_id/documents/:action', :controller => 'documents' match '/projects/:project_id/boards/:action/:id', :controller => 'boards' match '/boards/:board_id/topics/:action/:id', :controller => 'messages' diff --git a/lib/redmine.rb b/lib/redmine.rb index 7083e09943..0d56ba9c2f 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -89,9 +89,9 @@ Redmine::AccessControl.map do |map| map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} map.permission :manage_subtasks, {} map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} - map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin - map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin - map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin + map.permission :edit_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin + map.permission :edit_own_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin + map.permission :move_issues, {:'issues/moves' => [:new, :create]}, :require => :loggedin map.permission :delete_issues, {:issues => :destroy}, :require => :member # Queries map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member @@ -156,11 +156,11 @@ Redmine::AccessControl.map do |map| end map.project_module :calendar do |map| - map.permission :view_calendar, :calendars => [:show, :update] + map.permission :view_calendar, :'issues/calendars' => [:index] end map.project_module :gantt do |map| - map.permission :view_gantt, :gantts => [:show, :update] + map.permission :view_gantt, :'issues/gantts' => [:index] end end @@ -220,7 +220,7 @@ Redmine::MenuManager.map :project_menu do |menu| :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } menu.push :view_all_issues, { :controller => 'issues', :action => 'all' }, :param => :project_id, :caption => :label_issue_view_all, :parent => :issues menu.push :summary_field, {:controller => 'reports', :action => 'issue_report'}, :param => :id, :caption => :field_summary, :parent => :issues - menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt + menu.push :gantt, { :controller => 'issues/gantts', :action => 'index' }, :param => :project_id, :caption => :label_gantt menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural menu.push :new_news, { :controller => 'news', :action => 'new' }, :param => :project_id, :caption => :label_news_new, :parent => :news, diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index f565199596..2098ab6ef3 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -80,7 +80,7 @@ module Redmine end def common_params - { :controller => 'gantts', :action => 'show', :project_id => @project } + { :controller => 'gantts', :action => 'index', :project_id => @project } end def params diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 71e464ceed..0a7288ed4e 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -102,7 +102,7 @@ class AttachmentsControllerTest < ActionController::TestCase def test_anonymous_on_private_private get :download, :id => 7 - assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7' + assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F7%2Fdownload' end def test_destroy_issue_attachment @@ -146,7 +146,7 @@ class AttachmentsControllerTest < ActionController::TestCase def test_destroy_without_permission post :destroy, :id => 3 - assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3' + assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F3' assert Attachment.find_by_id(3) end end diff --git a/test/functional/auto_completes_controller_test.rb b/test/functional/issues/auto_completes_controller_test.rb similarity index 94% rename from test/functional/auto_completes_controller_test.rb rename to test/functional/issues/auto_completes_controller_test.rb index 88ed0f1e44..792da52fac 100644 --- a/test/functional/auto_completes_controller_test.rb +++ b/test/functional/issues/auto_completes_controller_test.rb @@ -12,9 +12,9 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require File.expand_path('../../test_helper', __FILE__) +require File.expand_path('../../../test_helper', __FILE__) -class AutoCompletesControllerTest < ActionController::TestCase +class Issues::AutoCompletesControllerTest < ActionController::TestCase fixtures :all def test_issues_should_not_be_case_sensitive diff --git a/test/functional/calendars_controller_test.rb b/test/functional/issues/calendars_controller_test.rb similarity index 89% rename from test/functional/calendars_controller_test.rb rename to test/functional/issues/calendars_controller_test.rb index 2e3b77230d..04f8cc7804 100644 --- a/test/functional/calendars_controller_test.rb +++ b/test/functional/issues/calendars_controller_test.rb @@ -12,20 +12,20 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require File.expand_path('../../test_helper', __FILE__) +require File.expand_path('../../../test_helper', __FILE__) -class CalendarsControllerTest < ActionController::TestCase +class Issues::CalendarsControllerTest < ActionController::TestCase fixtures :all def test_calendar - get :show, :project_id => 1 + get :index, :project_id => 1 assert_response :success assert_template 'calendar' assert_not_nil assigns(:calendar) end def test_cross_project_calendar - get :show + get :index assert_response :success assert_template 'calendar' assert_not_nil assigns(:calendar) @@ -35,7 +35,7 @@ class CalendarsControllerTest < ActionController::TestCase should "run custom queries" do @query = Query.generate_default! - get :show, :query_id => @query.id + get :index, :query_id => @query.id assert_response :success end @@ -44,7 +44,7 @@ class CalendarsControllerTest < ActionController::TestCase def test_week_number_calculation Setting.start_of_week = 7 - get :show, :month => '1', :year => '2010' + get :index, :month => '1', :year => '2010' assert_response :success assert_tag :tag => 'tr', @@ -65,7 +65,7 @@ class CalendarsControllerTest < ActionController::TestCase Setting.start_of_week = 1 - get :show, :month => '1', :year => '2010' + get :index, :month => '1', :year => '2010' assert_response :success assert_tag :tag => 'tr', diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/issues/context_menus_controller_test.rb similarity index 85% rename from test/functional/context_menus_controller_test.rb rename to test/functional/issues/context_menus_controller_test.rb index 304f0b9dee..85d08bb6c8 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/issues/context_menus_controller_test.rb @@ -12,9 +12,9 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require File.expand_path('../../test_helper', __FILE__) +require File.expand_path('../../../test_helper', __FILE__) -class ContextMenusControllerTest < ActionController::TestCase +class Issues::ContextMenusControllerTest < ActionController::TestCase fixtures :all def test_context_menu_one_issue @@ -26,31 +26,31 @@ class ContextMenusControllerTest < ActionController::TestCase :attributes => { :href => '/issues/1/edit', :class => 'icon-edit' } assert_tag :tag => 'a', :content => 'Closed', - :attributes => { :href => '/issues/bulk_edit?ids[]=1&issue[status_id]=5', + :attributes => { :href => '/issues/bulk_update?ids[]=1&issue[status_id]=5', :class => '' } assert_tag :tag => 'a', :content => 'Immediate', - :attributes => { :href => '/issues/bulk_edit?ids[]=1&issue[priority_id]=8', + :attributes => { :href => '/issues/bulk_update?ids[]=1&issue[priority_id]=8', :class => '' } # Versions assert_tag :tag => 'a', :content => '2.0', - :attributes => { :href => '/issues/bulk_edit?ids[]=1&issue[fixed_version_id]=3', + :attributes => { :href => '/issues/bulk_update?ids[]=1&issue[fixed_version_id]=3', :class => '' } assert_tag :tag => 'a', :content => 'eCookbook Subproject 1 - 2.0', - :attributes => { :href => '/issues/bulk_edit?ids[]=1&issue[fixed_version_id]=4', + :attributes => { :href => '/issues/bulk_update?ids[]=1&issue[fixed_version_id]=4', :class => '' } assert_tag :tag => 'a', :content => 'Dave Lopper', - :attributes => { :href => '/issues/bulk_edit?ids[]=1&issue[assigned_to_id]=3', + :attributes => { :href => '/issues/bulk_update?ids[]=1&issue[assigned_to_id]=3', :class => '' } assert_tag :tag => 'a', :content => 'Duplicate', - :attributes => { :href => '/projects/ecookbook/issues/1/copy', + :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1', :class => 'icon-duplicate' } assert_tag :tag => 'a', :content => 'Copy', :attributes => { :href => '/issues/move/new?copy_options[copy]=t&ids[]=1' } assert_tag :tag => 'a', :content => 'Move', :attributes => { :href => '/issues/move/new?ids[]=1'} assert_tag :tag => 'a', :content => 'Delete', - :attributes => { :href => '/issues/destroy?ids[]=1' } + :attributes => { :href => '/issues?ids[]=1' } end def test_context_menu_one_issue_by_anonymous @@ -73,20 +73,20 @@ class ContextMenusControllerTest < ActionController::TestCase :attributes => { :href => "/issues/bulk_edit?#{ids}", :class => 'icon-edit' } assert_tag :tag => 'a', :content => 'Closed', - :attributes => { :href => "/issues/bulk_edit?#{ids}&issue[status_id]=5", + :attributes => { :href => "/issues/bulk_update?#{ids}&issue[status_id]=5", :class => '' } assert_tag :tag => 'a', :content => 'Immediate', - :attributes => { :href => "/issues/bulk_edit?#{ids}&issue[priority_id]=8", + :attributes => { :href => "/issues/bulk_update?#{ids}&issue[priority_id]=8", :class => '' } assert_tag :tag => 'a', :content => 'Dave Lopper', - :attributes => { :href => "/issues/bulk_edit?#{ids}&issue[assigned_to_id]=3", + :attributes => { :href => "/issues/bulk_update?#{ids}&issue[assigned_to_id]=3", :class => '' } assert_tag :tag => 'a', :content => 'Copy', :attributes => { :href => "/issues/move/new?copy_options[copy]=t&#{ids}"} assert_tag :tag => 'a', :content => 'Move', :attributes => { :href => "/issues/move/new?#{ids}"} assert_tag :tag => 'a', :content => 'Delete', - :attributes => { :href => "/issues/destroy?#{ids}"} + :attributes => { :href => "/issues?#{ids}"} end def test_context_menu_multiple_issues_of_different_projects @@ -102,16 +102,16 @@ class ContextMenusControllerTest < ActionController::TestCase :attributes => { :href => "/issues/bulk_edit?#{ids}", :class => 'icon-edit' } assert_tag :tag => 'a', :content => 'Closed', - :attributes => { :href => "/issues/bulk_edit?#{ids}&issue[status_id]=5", + :attributes => { :href => "/issues/bulk_update?#{ids}&issue[status_id]=5", :class => '' } assert_tag :tag => 'a', :content => 'Immediate', - :attributes => { :href => "/issues/bulk_edit?#{ids}&issue[priority_id]=8", + :attributes => { :href => "/issues/bulk_update?#{ids}&issue[priority_id]=8", :class => '' } assert_tag :tag => 'a', :content => 'John Smith', - :attributes => { :href => "/issues/bulk_edit?#{ids}&issue[assigned_to_id]=2", + :attributes => { :href => "/issues/bulk_update?#{ids}&issue[assigned_to_id]=2", :class => '' } assert_tag :tag => 'a', :content => 'Delete', - :attributes => { :href => "/issues/destroy?#{ids}"} + :attributes => { :href => "/issues?#{ids}"} end def test_context_menu_issue_visibility diff --git a/test/functional/gantts_controller_test.rb b/test/functional/issues/gantts_controller_test.rb similarity index 86% rename from test/functional/gantts_controller_test.rb rename to test/functional/issues/gantts_controller_test.rb index 3f72463b87..8c60569be1 100644 --- a/test/functional/gantts_controller_test.rb +++ b/test/functional/issues/gantts_controller_test.rb @@ -12,9 +12,9 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require File.expand_path('../../test_helper', __FILE__) +require File.expand_path('../../../test_helper', __FILE__) -class GanttsControllerTest < ActionController::TestCase +class Issues::GanttsControllerTest < ActionController::TestCase fixtures :all context "#gantt" do @@ -22,7 +22,7 @@ class GanttsControllerTest < ActionController::TestCase i2 = Issue.find(2) i2.update_attribute(:due_date, 1.month.from_now) - get :show, :project_id => 1 + get :index, :project_id => 1 assert_response :success assert_template 'show' assert_not_nil assigns(:gantt) @@ -38,7 +38,7 @@ class GanttsControllerTest < ActionController::TestCase should "work without issue due dates" do Issue.update_all("due_date = NULL") - get :show, :project_id => 1 + get :index, :project_id => 1 assert_response :success assert_template 'show' assert_not_nil assigns(:gantt) @@ -48,14 +48,14 @@ class GanttsControllerTest < ActionController::TestCase Issue.update_all("due_date = NULL") Version.update_all("effective_date = NULL") - get :show, :project_id => 1 + get :index, :project_id => 1 assert_response :success assert_template 'show' assert_not_nil assigns(:gantt) end should "work cross project" do - get :show + get :index assert_response :success assert_template 'show' assert_not_nil assigns(:gantt) @@ -64,7 +64,7 @@ class GanttsControllerTest < ActionController::TestCase end should "not disclose private projects" do - get :show + get :index assert_response :success assert_template 'show' @@ -76,7 +76,7 @@ class GanttsControllerTest < ActionController::TestCase end should "export to pdf" do - get :show, :project_id => 1, :format => 'pdf' + get :index, :project_id => 1, :format => 'pdf' assert_response :success assert_equal 'application/pdf', @response.content_type assert @response.body.starts_with?('%PDF') @@ -84,7 +84,7 @@ class GanttsControllerTest < ActionController::TestCase end should "export to pdf cross project" do - get :show, :format => 'pdf' + get :index, :format => 'pdf' assert_response :success assert_equal 'application/pdf', @response.content_type assert @response.body.starts_with?('%PDF') @@ -92,7 +92,7 @@ class GanttsControllerTest < ActionController::TestCase end should "export to png" do - get :show, :project_id => 1, :format => 'png' + get :index, :project_id => 1, :format => 'png' assert_response :success assert_equal 'image/png', @response.content_type end if Object.const_defined?(:Magick) diff --git a/test/functional/issue_moves_controller_test.rb b/test/functional/issues/moves_controller_test.rb similarity index 87% rename from test/functional/issue_moves_controller_test.rb rename to test/functional/issues/moves_controller_test.rb index e2dece9e3e..aab9671eeb 100644 --- a/test/functional/issue_moves_controller_test.rb +++ b/test/functional/issues/moves_controller_test.rb @@ -12,9 +12,9 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require File.expand_path('../../test_helper', __FILE__) +require File.expand_path('../../../test_helper', __FILE__) -class IssueMovesControllerTest < ActionController::TestCase +class Issues::MovesControllerTest < ActionController::TestCase fixtures :all def setup @@ -24,7 +24,7 @@ class IssueMovesControllerTest < ActionController::TestCase def test_create_one_issue_to_another_project @request.session[:user_id] = 2 post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' - assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_redirected_to project_issues_path(:project_id => 'ecookbook') assert_equal 2, Issue.find(1).project_id end @@ -37,7 +37,7 @@ class IssueMovesControllerTest < ActionController::TestCase def test_bulk_create_to_another_project @request.session[:user_id] = 2 post :create, :ids => [1, 2], :new_project_id => 2 - assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_redirected_to project_issues_path(:project_id => 'ecookbook') # Issues moved to project 2 assert_equal 2, Issue.find(1).project_id assert_equal 2, Issue.find(2).project_id @@ -49,7 +49,7 @@ class IssueMovesControllerTest < ActionController::TestCase def test_bulk_create_to_another_tracker @request.session[:user_id] = 2 post :create, :ids => [1, 2], :new_tracker_id => 2 - assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_redirected_to project_issues_path(:project_id => 'ecookbook') assert_equal 2, Issue.find(1).tracker_id assert_equal 2, Issue.find(2).tracker_id end @@ -62,7 +62,7 @@ class IssueMovesControllerTest < ActionController::TestCase should "allow changing the issue priority" do post :create, :ids => [1, 2], :priority_id => 6 - assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_redirected_to project_issues_path(:project_id => 'ecookbook') assert_equal 6, Issue.find(1).priority_id assert_equal 6, Issue.find(2).priority_id @@ -71,7 +71,7 @@ class IssueMovesControllerTest < ActionController::TestCase should "allow adding a note when moving" do post :create, :ids => [1, 2], :notes => 'Moving two issues' - assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_redirected_to project_issues_path(:project_id => 'ecookbook') assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes @@ -132,7 +132,7 @@ class IssueMovesControllerTest < ActionController::TestCase @request.session[:user_id] = 2 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1' issue = Issue.first(:order => 'id DESC') - assert_redirected_to :controller => 'issues', :action => 'show', :id => issue + assert_redirected_to issue_path(issue) end end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index c785dcc157..f46a8d2adf 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -195,13 +195,13 @@ class IssuesControllerTest < ActionController::TestCase get :index, :format => 'csv' assert_response :success assert_not_nil assigns(:issues) - assert_equal 'text/csv', @response.content_type + assert_equal 'text/csv; header=present', @response.content_type assert @response.body.starts_with?("#,") get :index, :project_id => 1, :format => 'csv' assert_response :success assert_not_nil assigns(:issues) - assert_equal 'text/csv', @response.content_type + assert_equal 'text/csv; header=present', @response.content_type end def test_index_pdf @@ -1145,17 +1145,17 @@ class IssuesControllerTest < ActionController::TestCase def test_bulk_update @request.session[:user_id] = 2 # update issues priority - post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing', - :issue => {:priority_id => 7, - :assigned_to_id => '', - :custom_field_values => {'2' => ''}} + put :bulk_update, :ids => [1, 2], :notes => 'Bulk editing', + :issue => { :priority_id => 7, + :assigned_to_id => '', + :custom_field_values => {'2' => ''} } assert_response 302 # check that the issues were updated assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} issue = Issue.find(1) - journal = issue.journals.find(:first, :order => 'created_at DESC') + journal = issue.journals.reorder('created_at DESC').first assert_equal '125', issue.custom_value_for(2).value assert_equal 'Bulk editing', journal.notes assert_equal 1, journal.details.size @@ -1164,7 +1164,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bullk_update_should_not_send_a_notification_if_send_notification_is_off @request.session[:user_id] = 2 ActionMailer::Base.deliveries.clear - post(:bulk_update, + put(:bulk_update, { :ids => [1, 2], :issue => { @@ -1183,7 +1183,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bulk_update_on_different_projects @request.session[:user_id] = 2 # update issues priority - post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing', + put :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing', :issue => {:priority_id => 7, :assigned_to_id => '', :custom_field_values => {'2' => ''}} @@ -1193,7 +1193,7 @@ class IssuesControllerTest < ActionController::TestCase assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id) issue = Issue.find(1) - journal = issue.journals.find(:first, :order => 'created_at DESC') + journal = issue.journals.reorder('created_at DESC').first assert_equal '125', issue.custom_value_for(2).value assert_equal 'Bulk editing', journal.notes assert_equal 1, journal.details.size @@ -1205,7 +1205,7 @@ class IssuesControllerTest < ActionController::TestCase action = { :controller => "issues", :action => "bulk_update" } assert user.allowed_to?(action, Issue.find(1).project) assert ! user.allowed_to?(action, Issue.find(6).project) - post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail', + put :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail', :issue => {:priority_id => 7, :assigned_to_id => '', :custom_field_values => {'2' => ''}} @@ -1216,7 +1216,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bullk_update_should_send_a_notification @request.session[:user_id] = 2 ActionMailer::Base.deliveries.clear - post(:bulk_update, + put(:bulk_update, { :ids => [1, 2], :notes => 'Bulk editing', @@ -1234,7 +1234,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bulk_update_status @request.session[:user_id] = 2 # update issues priority - post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status', + put :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status', :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '5'} @@ -1246,7 +1246,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bulk_update_parent_id @request.session[:user_id] = 2 - post :bulk_update, :ids => [1, 3], + put :bulk_update, :ids => [1, 3], :notes => 'Bulk editing parent', :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'} @@ -1260,7 +1260,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bulk_update_custom_field @request.session[:user_id] = 2 # update issues priority - post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field', + put :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field', :issue => {:priority_id => '', :assigned_to_id => '', :custom_field_values => {'2' => '777'}} @@ -1279,7 +1279,7 @@ class IssuesControllerTest < ActionController::TestCase assert_not_nil Issue.find(2).assigned_to @request.session[:user_id] = 2 # unassign issues - post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'} + put :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'} assert_response 302 # check that the issues were updated assert_nil Issue.find(2).assigned_to @@ -1288,7 +1288,7 @@ class IssuesControllerTest < ActionController::TestCase def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject @request.session[:user_id] = 2 - post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4} + put :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4} assert_response :redirect issues = Issue.find([1,2]) @@ -1300,7 +1300,7 @@ class IssuesControllerTest < ActionController::TestCase def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter @request.session[:user_id] = 2 - post :bulk_update, :ids => [1,2], :back_url => '/issues' + put :bulk_update, :ids => [1,2], :back_url => '/issues' assert_response :redirect assert_redirected_to '/issues' @@ -1308,7 +1308,7 @@ class IssuesControllerTest < ActionController::TestCase def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host @request.session[:user_id] = 2 - post :bulk_update, :ids => [1,2], :back_url => 'http://google.com' + put :bulk_update, :ids => [1,2], :back_url => 'http://google.com' assert_response :redirect assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 24f45e6b48..da9e3716b4 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -177,7 +177,7 @@ class UsersControllerTest < ActionController::TestCase end user = User.first(:order => 'id DESC') - assert_redirected_to :controller => 'users', :action => 'edit', :id => user.id + assert_redirected_to edit_user_path(user) assert_equal 'John', user.firstname assert_equal 'Doe', user.lastname diff --git a/test/functional/watchers_controller_test.rb b/test/functional/watchers_controller_test.rb index e65ebbed98..45ca2b5e4a 100644 --- a/test/functional/watchers_controller_test.rb +++ b/test/functional/watchers_controller_test.rb @@ -125,7 +125,7 @@ class WatchersControllerTest < ActionController::TestCase def test_remove_watcher @request.session[:user_id] = 2 assert_difference('Watcher.count', -1) do - xhr :post, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3' + xhr :delete, :destroy, :id => Watcher.find_by_user_id_and_watchable_id(3, 2).id assert_response :success assert_select_rjs :replace_html, 'watchers' end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 507fe424a2..6eeeb3bbc9 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -47,7 +47,7 @@ class WikiControllerTest < ActionController::TestCase assert_tag :tag => 'h1', :content => /Another page/ # Included page with an inline image assert_tag :tag => 'p', :content => /This is an inline image/ - assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', + assert_tag :tag => 'img', :attributes => { :src => '/attachments/3/download', :alt => 'This is a logo' } end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 1369d511c6..e33c420832 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -96,310 +96,371 @@ class RoutingTest < ActionController::IntegrationTest end context "documents" do - should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567' - should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567' - should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22' - should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22' - - should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567' - should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567' - should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567' + should route(:get, "/projects/567/documents").to( :controller => 'documents', :action => 'index', :project_id => '567') + should route(:get, "/projects/567/documents/new").to( :controller => 'documents', :action => 'new', :project_id => '567') + should route(:get, "/documents/22").to( :controller => 'documents', :action => 'show', :id => '22') + should route(:get, "/documents/22/edit").to( :controller => 'documents', :action => 'edit', :id => '22') + + should route(:post, "/projects/567/documents/new").to( :controller => 'documents', :action => 'new', :project_id => '567') + should route(:post, "/documents/567/edit").to( :controller => 'documents', :action => 'edit', :id => '567') + should route(:post, "/documents/567/destroy").to( :controller => 'documents', :action => 'destroy', :id => '567') end context "issues" do # REST actions - should_route :get, "/issues", :controller => 'issues', :action => 'index' - should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf' - should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom' - should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml' - should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23' - should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf' - should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom' - should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml' - should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64' - should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf' - should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom' - should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml' - - should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23' - should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23' - should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml' - - should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' - # TODO: Should use PUT - should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' - should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml' - - # TODO: Should use DELETE - should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64' - should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml' + should route(:get, "/issues").to( :controller => 'issues', + :action => 'index') + should route(:get, "/issues.pdf").to( :controller => 'issues', + :action => 'index', + :format => 'pdf') + should route(:get, "/issues.atom").to( :controller => 'issues', + :action => 'index', + :format => 'atom') + should route(:get, "/issues.xml").to( :controller => 'issues', + :action => 'index', + :format => 'xml') + should route(:get, "/projects/23/issues").to( :controller => 'issues', + :action => 'index', + :project_id => '23') + should route(:get, "/projects/23/issues.pdf").to( :controller => 'issues', + :action => 'index', + :project_id => '23', + :format => 'pdf') + should route(:get, "/projects/23/issues.atom").to( :controller => 'issues', + :action => 'index', + :project_id => '23', + :format => 'atom') + should route(:get, "/projects/23/issues.xml").to( :controller => 'issues', + :action => 'index', + :project_id => '23', + :format => 'xml') + should route(:get, "/issues/64").to( :controller => 'issues', + :action => 'show', + :id => '64') + should route(:get, "/issues/64.pdf").to( :controller => 'issues', + :action => 'show', + :id => '64', + :format => 'pdf') + should route(:get, "/issues/64.atom").to( :controller => 'issues', + :action => 'show', + :id => '64', + :format => 'atom') + should route(:get, "/issues/64.xml").to( :controller => 'issues', + :action => 'show', + :id => '64', + :format => 'xml') + should route(:get, "/projects/23/issues/new").to( :controller => 'issues', + :action => 'new', + :project_id => '23') + should route(:post, "/projects/23/issues").to( :controller => 'issues', + :action => 'create', + :project_id => '23') + # TODO: remove as issues should be created scoped under project + should route(:post, "/issues.xml").to( :controller => 'issues', + :action => 'create', + :format => 'xml') + + should route(:get, "/issues/64/edit").to( :controller => 'issues', + :action => 'edit', + :id => '64') + should route(:put, "/issues/1.xml").to( :controller => 'issues', + :action => 'update', + :id => '1', + :format => 'xml') + + should route(:delete, "/issues/1.xml").to( :controller => 'issues', + :action => 'destroy', + :id => '1', + :format => 'xml') # Extra actions - should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64' - - should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' - should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' - - should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1' - - should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show' - should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update' - should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name' - should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name' - - should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show' - should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update' - should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name' - should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name' - - should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues' - - should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123' - should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123' - should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues' - should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues' - - should_route :get, "/issues/changes", :controller => 'journals', :action => 'index' - - should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit' - should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update' - end - - context "issue categories" do - should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test' - - should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test' - end - - context "issue relations" do - should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1' - should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23' - end - - context "issue reports" do - should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567' - should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to' - end - - context "members" do - should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234' - end - - context "messages" do - should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22' - should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala' - should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala' - - should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala' - should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala' - should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22' - should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22' - end - - context "news" do - should_route :get, "/news", :controller => 'news', :action => 'index' - should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom' - should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml' - should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json' - should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567' - should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567' - should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567' - should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567' - should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2' - should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567' - should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234' - should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567' - should_route :get, "/news/preview", :controller => 'previews', :action => 'news' - - should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567' - should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567' - - should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567' - - should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567' - should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15' - end - - context "projects" do - should_route :get, "/projects", :controller => 'projects', :action => 'index' - should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom' - should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml' - should_route :get, "/projects/new", :controller => 'projects', :action => 'new' - should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test' - should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' - should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' - should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' - should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33' - should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33' - should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33' - should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33' - should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom' - - should_route :post, "/projects", :controller => 'projects', :action => 'create' - should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml' - should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33' - should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' - should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' - - should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64' - should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223' - should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml' - - should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64' - should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' - should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64' - end - - context "repositories" do - should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine' - should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' - should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine' - should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom' - should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457' - should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457' - should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff' - should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c] - should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2' - should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c] - should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c] - should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2' - should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw' - should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw' - should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c] - should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c] - should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine' - - - should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' - end - - context "timelogs (global)" do - should_route :get, "/time_entries", :controller => 'timelog', :action => 'index' - should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv' - should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom' - should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new' - should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' - - should_route :post, "/time_entries", :controller => 'timelog', :action => 'create' - - should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22' - - should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55' - end - - context "timelogs (scoped under project)" do - should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567' - should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv' - should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom' - should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567' - should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567' - - should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567' - - should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567' - - should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567' - end - - context "timelogs (scoped under issues)" do - should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234' - should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv' - should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom' - should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234' - should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234' - - should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234' - - should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234' - - should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234' - end - - context "timelogs (scoped under project and issues)" do - should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook' - should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv' - should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom' - should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook' - should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook' - - should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook' - - should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook' - - should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook' - end - - context "time_entry_reports" do - should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report' - should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567' - should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv' - end - - context "users" do - should_route :get, "/users", :controller => 'users', :action => 'index' - should_route :get, "/users.xml", :controller => 'users', :action => 'index', :format => 'xml' - should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44' - should_route :get, "/users/44.xml", :controller => 'users', :action => 'show', :id => '44', :format => 'xml' - should_route :get, "/users/current", :controller => 'users', :action => 'show', :id => 'current' - should_route :get, "/users/current.xml", :controller => 'users', :action => 'show', :id => 'current', :format => 'xml' - should_route :get, "/users/new", :controller => 'users', :action => 'new' - should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' - should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership' - - should_route :post, "/users", :controller => 'users', :action => 'create' - should_route :post, "/users.xml", :controller => 'users', :action => 'create', :format => 'xml' - should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123' - should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55' - should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12' - - should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444' - should_route :put, "/users/444.xml", :controller => 'users', :action => 'update', :id => '444', :format => 'xml' - end - - # TODO: should they all be scoped under /projects/:project_id ? - context "versions" do - should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' - should_route :get, "/versions/show/1", :controller => 'versions', :action => 'show', :id => '1' - should_route :get, "/versions/edit/1", :controller => 'versions', :action => 'edit', :id => '1' - - should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo' - should_route :post, "/versions/update/1", :controller => 'versions', :action => 'update', :id => '1' - - should_route :delete, "/versions/destroy/1", :controller => 'versions', :action => 'destroy', :id => '1' - end - - context "wiki (singular, project's pages)" do - should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567' - should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :id => 'lalala' - should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :id => 'my_page' - should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :id => 'CookBook_documentation' - should_route :get, "/projects/1/wiki/CookBook_documentation/diff", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation' - should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2' - should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2', :version_from => '1' - should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :id => 'CookBook_documentation', :version => '2' - should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida' - should_route :get, "/projects/567/wiki/index", :controller => 'wiki', :action => 'index', :project_id => '567' - should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567' - should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567' - - should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation' - should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida' - should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida' - should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida' - - should_route :put, "/projects/567/wiki/my_page", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page' - - should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida' - end - - context "wikis (plural, admin setup)" do - should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' - - should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida' - should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' - end - - context "administration panel" do - should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects' + should route(:get, "/projects/23/issues/64/copy").to( :controller => 'issues', + :action => 'new', + :project_id => '23', + :copy_from => '64') + + should route(:get, "/issues/move/new").to( :controller => 'issues/moves', + :action => 'new') + should route(:post, "/issues/move").to( :controller => 'issues/moves', + :action => 'create') + + should route(:post, "/issues/1/quoted").to( :controller => 'journals', + :action => 'new', + :id => '1') + + should route(:get, "/issues/calendar").to( :controller => 'issues/calendars', + :action => 'index') + should route(:get, "/projects/project-name/issues/calendar").to( :controller => 'issues/calendars', + :action => 'index', + :project_id => 'project-name' ) + + should route(:get, "/issues/gantt").to( :controller => 'issues/gantts', + :action => 'index') + should route(:get, "/projects/project-name/issues/gantt").to( :controller => 'issues/gantts', + :action => 'index', + :project_id => 'project-name') + + should route(:get, "/issues/auto_complete").to( :controller => 'issues/auto_completes', + :action => 'issues') + should route(:post, "/issues/auto_complete").to( :controller => 'issues/auto_completes', + :action => 'issues') + + should route(:get, "/issues/preview/123").to( :controller => 'previews', + :action => 'issue', + :id => '123') + should route(:post, "/issues/preview/123").to( :controller => 'previews', + :action => 'issue', + :id => '123') + should route(:get, "/issues/context_menu").to( :controller => 'issues/context_menus', + :action => 'issues') + should route(:post, "/issues/context_menu").to( :controller => 'issues/context_menus', + :action => 'issues') + + should route(:get, "/issues/changes").to( :controller => 'journals', + :action => 'index') + + should route(:get, "/issues/bulk_edit").to( :controller => 'issues', + :action => 'bulk_edit') + should route(:put, "/issues/bulk_update").to( :controller => 'issues', + :action => 'bulk_update') end end + +# context "issue categories" do +# should route(:get, "/projects/test/issue_categories/new").to( :controller => 'issue_categories', :action => 'new', :project_id => 'test') +# +# should route(:post, "/projects/test/issue_categories/new").to( :controller => 'issue_categories', :action => 'new', :project_id => 'test') +# end +# +# context "issue relations" do +# should route(:post, "/issues/1/relations").to( :controller => 'issue_relations', :action => 'new', :issue_id => '1') +# should route(:post, "/issues/1/relations/23/destroy").to( :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23') +# end +# +# context "issue reports" do +# should route(:get, "/projects/567/issues/report").to( :controller => 'reports', :action => 'issue_report', :id => '567') +# should route(:get, "/projects/567/issues/report/assigned_to").to( :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to') +# end +# +# context "members" do +# should route(:post, "/projects/5234/members/new").to( :controller => 'members', :action => 'new', :id => '5234') +# end +# +# context "messages" do +# should route(:get, "/boards/22/topics/2").to( :controller => 'messages', :action => 'show', :id => '2', :board_id => '22') +# should route(:get, "/boards/lala/topics/new").to( :controller => 'messages', :action => 'new', :board_id => 'lala') +# should route(:get, "/boards/lala/topics/22/edit").to( :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala') +# +# should route(:post, "/boards/lala/topics/new").to( :controller => 'messages', :action => 'new', :board_id => 'lala') +# should route(:post, "/boards/lala/topics/22/edit").to( :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala') +# should route(:post, "/boards/22/topics/555/replies").to( :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22') +# should route(:post, "/boards/22/topics/555/destroy").to( :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22') +# end +# +# context "news" do +# should route(:get, "/news").to( :controller => 'news', :action => 'index') +# should route(:get, "/news.atom").to( :controller => 'news', :action => 'index', :format => 'atom') +# should route(:get, "/news.xml").to( :controller => 'news', :action => 'index', :format => 'xml') +# should route(:get, "/news.json").to( :controller => 'news', :action => 'index', :format => 'json') +# should route(:get, "/projects/567/news").to( :controller => 'news', :action => 'index', :project_id => '567') +# should route(:get, "/projects/567/news.atom").to( :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567') +# should route(:get, "/projects/567/news.xml").to( :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567') +# should route(:get, "/projects/567/news.json").to( :controller => 'news', :action => 'index', :format => 'json', :project_id => '567') +# should route(:get, "/news/2").to( :controller => 'news', :action => 'show', :id => '2') +# should route(:get, "/projects/567/news/new").to( :controller => 'news', :action => 'new', :project_id => '567') +# should route(:get, "/news/234").to( :controller => 'news', :action => 'show', :id => '234') +# should route(:get, "/news/567/edit").to( :controller => 'news', :action => 'edit', :id => '567') +# should route(:get, "/news/preview").to( :controller => 'previews', :action => 'news') +# +# should route(:post, "/projects/567/news").to( :controller => 'news', :action => 'create', :project_id => '567') +# should route(:post, "/news/567/comments").to( :controller => 'comments', :action => 'create', :id => '567') +# +# should route(:put, "/news/567").to( :controller => 'news', :action => 'update', :id => '567') +# +# should route(:delete, "/news/567").to( :controller => 'news', :action => 'destroy', :id => '567') +# should route(:delete, "/news/567/comments/15").to( :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15') +# end +# +# context "projects" do +# should route(:get, "/projects").to( :controller => 'projects', :action => 'index') +# should route(:get, "/projects.atom").to( :controller => 'projects', :action => 'index', :format => 'atom') +# should route(:get, "/projects.xml").to( :controller => 'projects', :action => 'index', :format => 'xml') +# should route(:get, "/projects/new").to( :controller => 'projects', :action => 'new') +# should route(:get, "/projects/test").to( :controller => 'projects', :action => 'show', :id => 'test') +# should route(:get, "/projects/1.xml").to( :controller => 'projects', :action => 'show', :id => '1', :format => 'xml') +# should route(:get, "/projects/4223/settings").to( :controller => 'projects', :action => 'settings', :id => '4223') +# should route(:get, "/projects/4223/settings/members").to( :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members') +# should route(:get, "/projects/33/files").to( :controller => 'files', :action => 'index', :project_id => '33') +# should route(:get, "/projects/33/files/new").to( :controller => 'files', :action => 'new', :project_id => '33') +# should route(:get, "/projects/33/roadmap").to( :controller => 'versions', :action => 'index', :project_id => '33') +# should route(:get, "/projects/33/activity").to( :controller => 'activities', :action => 'index', :id => '33') +# should route(:get, "/projects/33/activity.atom").to( :controller => 'activities', :action => 'index', :id => '33', :format => 'atom') +# +# should route(:post, "/projects").to( :controller => 'projects', :action => 'create') +# should route(:post, "/projects.xml").to( :controller => 'projects', :action => 'create', :format => 'xml') +# should route(:post, "/projects/33/files").to( :controller => 'files', :action => 'create', :project_id => '33') +# should route(:post, "/projects/64/archive").to( :controller => 'projects', :action => 'archive', :id => '64') +# should route(:post, "/projects/64/unarchive").to( :controller => 'projects', :action => 'unarchive', :id => '64') +# +# should route(:put, "/projects/64/enumerations").to( :controller => 'project_enumerations', :action => 'update', :project_id => '64') +# should route(:put, "/projects/4223").to( :controller => 'projects', :action => 'update', :id => '4223') +# should route(:put, "/projects/1.xml").to( :controller => 'projects', :action => 'update', :id => '1', :format => 'xml') +# +# should route(:delete, "/projects/64").to( :controller => 'projects', :action => 'destroy', :id => '64') +# should route(:delete, "/projects/1.xml").to( :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml') +# should route(:delete, "/projects/64/enumerations").to( :controller => 'project_enumerations', :action => 'destroy', :project_id => '64') +# end +# +# context "repositories" do +# should route(:get, "/projects/redmine/repository").to( :controller => 'repositories', :action => 'show', :id => 'redmine') +# should route(:get, "/projects/redmine/repository/edit").to( :controller => 'repositories', :action => 'edit', :id => 'redmine') +# should route(:get, "/projects/redmine/repository/revisions").to( :controller => 'repositories', :action => 'revisions', :id => 'redmine') +# should route(:get, "/projects/redmine/repository/revisions.atom").to( :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom') +# should route(:get, "/projects/redmine/repository/revisions/2457").to( :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457') +# should route(:get, "/projects/redmine/repository/revisions/2457/diff").to( :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457') +# should route(:get, "/projects/redmine/repository/revisions/2457/diff.diff").to( :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff') +# should route(:get, "/projects/redmine/repository/diff/path/to/file.c").to( :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]) +# should route(:get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c").to( :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2') +# should route(:get, "/projects/redmine/repository/browse/path/to/file.c").to( :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]) +# should route(:get, "/projects/redmine/repository/entry/path/to/file.c").to( :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]) +# should route(:get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c").to( :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2') +# should route(:get, "/projects/redmine/repository/raw/path/to/file.c").to( :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw') +# should route(:get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c").to( :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw') +# should route(:get, "/projects/redmine/repository/annotate/path/to/file.c").to( :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]) +# should route(:get, "/projects/redmine/repository/changes/path/to/file.c").to( :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]) +# should route(:get, "/projects/redmine/repository/statistics").to( :controller => 'repositories', :action => 'stats', :id => 'redmine') +# +# +# should route(:post, "/projects/redmine/repository/edit").to( :controller => 'repositories', :action => 'edit', :id => 'redmine') +# end +# +# context "timelogs (global)" do +# should route(:get, "/time_entries").to( :controller => 'timelog', :action => 'index') +# should route(:get, "/time_entries.csv").to( :controller => 'timelog', :action => 'index', :format => 'csv') +# should route(:get, "/time_entries.atom").to( :controller => 'timelog', :action => 'index', :format => 'atom') +# should route(:get, "/time_entries/new").to( :controller => 'timelog', :action => 'new') +# should route(:get, "/time_entries/22/edit").to( :controller => 'timelog', :action => 'edit', :id => '22') +# +# should route(:post, "/time_entries").to( :controller => 'timelog', :action => 'create') +# +# should route(:put, "/time_entries/22").to( :controller => 'timelog', :action => 'update', :id => '22') +# +# should route(:delete, "/time_entries/55").to( :controller => 'timelog', :action => 'destroy', :id => '55') +# end +# +# context "timelogs (scoped under project)" do +# should route(:get, "/projects/567/time_entries").to( :controller => 'timelog', :action => 'index', :project_id => '567') +# should route(:get, "/projects/567/time_entries.csv").to( :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv') +# should route(:get, "/projects/567/time_entries.atom").to( :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom') +# should route(:get, "/projects/567/time_entries/new").to( :controller => 'timelog', :action => 'new', :project_id => '567') +# should route(:get, "/projects/567/time_entries/22/edit").to( :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567') +# +# should route(:post, "/projects/567/time_entries").to( :controller => 'timelog', :action => 'create', :project_id => '567') +# +# should route(:put, "/projects/567/time_entries/22").to( :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567') +# +# should route(:delete, "/projects/567/time_entries/55").to( :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567') +# end +# +# context "timelogs (scoped under issues)" do +# should route(:get, "/issues/234/time_entries").to( :controller => 'timelog', :action => 'index', :issue_id => '234') +# should route(:get, "/issues/234/time_entries.csv").to( :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv') +# should route(:get, "/issues/234/time_entries.atom").to( :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom') +# should route(:get, "/issues/234/time_entries/new").to( :controller => 'timelog', :action => 'new', :issue_id => '234') +# should route(:get, "/issues/234/time_entries/22/edit").to( :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234') +# +# should route(:post, "/issues/234/time_entries").to( :controller => 'timelog', :action => 'create', :issue_id => '234') +# +# should route(:put, "/issues/234/time_entries/22").to( :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234') +# +# should route(:delete, "/issues/234/time_entries/55").to( :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234') +# end +# +# context "timelogs (scoped under project and issues)" do +# should route(:get, "/projects/ecookbook/issues/234/time_entries").to( :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook') +# should route(:get, "/projects/ecookbook/issues/234/time_entries.csv").to( :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv') +# should route(:get, "/projects/ecookbook/issues/234/time_entries.atom").to( :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom') +# should route(:get, "/projects/ecookbook/issues/234/time_entries/new").to( :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook') +# should route(:get, "/projects/ecookbook/issues/234/time_entries/22/edit").to( :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook') +# +# should route(:post, "/projects/ecookbook/issues/234/time_entries").to( :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook') +# +# should route(:put, "/projects/ecookbook/issues/234/time_entries/22").to( :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook') +# +# should route(:delete, "/projects/ecookbook/issues/234/time_entries/55").to( :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook') +# end +# +# context "time_entry_reports" do +# should route(:get, "/time_entries/report").to( :controller => 'time_entry_reports', :action => 'report') +# should route(:get, "/projects/567/time_entries/report").to( :controller => 'time_entry_reports', :action => 'report', :project_id => '567') +# should route(:get, "/projects/567/time_entries/report.csv").to( :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv') +# end +# +# context "users" do +# should route(:get, "/users").to( :controller => 'users', :action => 'index') +# should route(:get, "/users.xml").to( :controller => 'users', :action => 'index', :format => 'xml') +# should route(:get, "/users/44").to( :controller => 'users', :action => 'show', :id => '44') +# should route(:get, "/users/44.xml").to( :controller => 'users', :action => 'show', :id => '44', :format => 'xml') +# should route(:get, "/users/current").to( :controller => 'users', :action => 'show', :id => 'current') +# should route(:get, "/users/current.xml").to( :controller => 'users', :action => 'show', :id => 'current', :format => 'xml') +# should route(:get, "/users/new").to( :controller => 'users', :action => 'new') +# should route(:get, "/users/444/edit").to( :controller => 'users', :action => 'edit', :id => '444') +# should route(:get, "/users/222/edit/membership").to( :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership') +# +# should route(:post, "/users").to( :controller => 'users', :action => 'create') +# should route(:post, "/users.xml").to( :controller => 'users', :action => 'create', :format => 'xml') +# should route(:post, "/users/123/memberships").to( :controller => 'users', :action => 'edit_membership', :id => '123') +# should route(:post, "/users/123/memberships/55").to( :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55') +# should route(:post, "/users/567/memberships/12/destroy").to( :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12') +# +# should route(:put, "/users/444").to( :controller => 'users', :action => 'update', :id => '444') +# should route(:put, "/users/444.xml").to( :controller => 'users', :action => 'update', :id => '444', :format => 'xml') +# end +# +# # TODO: should they all be scoped under /projects/:project_id ? +# context "versions" do +# should route(:get, "/projects/foo/versions/new").to( :controller => 'versions', :action => 'new', :project_id => 'foo') +# should route(:get, "/versions/show/1").to( :controller => 'versions', :action => 'show', :id => '1') +# should route(:get, "/versions/edit/1").to( :controller => 'versions', :action => 'edit', :id => '1') +# +# should route(:post, "/projects/foo/versions").to( :controller => 'versions', :action => 'create', :project_id => 'foo') +# should route(:post, "/versions/update/1").to( :controller => 'versions', :action => 'update', :id => '1') +# +# should route(:delete, "/versions/destroy/1").to( :controller => 'versions', :action => 'destroy', :id => '1') +# end +# +# context "wiki (singular, project's pages)" do +# should route(:get, "/projects/567/wiki").to( :controller => 'wiki', :action => 'show', :project_id => '567') +# should route(:get, "/projects/567/wiki/lalala").to( :controller => 'wiki', :action => 'show', :project_id => '567', :id => 'lalala') +# should route(:get, "/projects/567/wiki/my_page/edit").to( :controller => 'wiki', :action => 'edit', :project_id => '567', :id => 'my_page') +# should route(:get, "/projects/1/wiki/CookBook_documentation/history").to( :controller => 'wiki', :action => 'history', :project_id => '1', :id => 'CookBook_documentation') +# should route(:get, "/projects/1/wiki/CookBook_documentation/diff").to( :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation') +# should route(:get, "/projects/1/wiki/CookBook_documentation/diff/2").to( :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2') +# should route(:get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1").to( :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2', :version_from => '1') +# should route(:get, "/projects/1/wiki/CookBook_documentation/annotate/2").to( :controller => 'wiki', :action => 'annotate', :project_id => '1', :id => 'CookBook_documentation', :version => '2') +# should route(:get, "/projects/22/wiki/ladida/rename").to( :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida') +# should route(:get, "/projects/567/wiki/index").to( :controller => 'wiki', :action => 'index', :project_id => '567') +# should route(:get, "/projects/567/wiki/date_index").to( :controller => 'wiki', :action => 'date_index', :project_id => '567') +# should route(:get, "/projects/567/wiki/export").to( :controller => 'wiki', :action => 'export', :project_id => '567') +# +# should route(:post, "/projects/567/wiki/CookBook_documentation/preview").to( :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation') +# should route(:post, "/projects/22/wiki/ladida/rename").to( :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida') +# should route(:post, "/projects/22/wiki/ladida/protect").to( :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida') +# should route(:post, "/projects/22/wiki/ladida/add_attachment").to( :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida') +# +# should route(:put, "/projects/567/wiki/my_page").to( :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page') +# +# should route(:delete, "/projects/22/wiki/ladida").to( :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida') +# end +# +# context "wikis (plural, admin setup)" do +# should route(:get, "/projects/ladida/wiki/destroy").to( :controller => 'wikis', :action => 'destroy', :id => 'ladida') +# +# should route(:post, "/projects/ladida/wiki").to( :controller => 'wikis', :action => 'edit', :id => 'ladida') +# should route(:post, "/projects/ladida/wiki/destroy").to( :controller => 'wikis', :action => 'destroy', :id => 'ladida') +# end +# +# context "administration panel" do +# should route(:get, "/admin/projects").to( :controller => 'admin', :action => 'projects') +# end +#end From d86490abc109dd647bef5efcdb28ccdc377912b6 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 14 Aug 2012 08:51:56 +0200 Subject: [PATCH 16/17] adds tests for routing of issue watches --- test/integration/routing_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index e33c420832..1fda10cbe5 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -223,6 +223,28 @@ class RoutingTest < ActionController::IntegrationTest :action => 'bulk_edit') should route(:put, "/issues/bulk_update").to( :controller => 'issues', :action => 'bulk_update') + + end + + context "watches" do + should route(:post, "/issues/1/watch").to( :controller => 'watchers', + :action => 'watch', + :object_type => 'issues', + :object_id => '1' ) + + should route(:delete, "/issues/1/unwatch").to( :controller => 'watchers', + :action => 'unwatch', + :object_type => 'issues', + :object_id => '1' ) + + should route(:get, "/issues/1/watchers/new").to( :controller => 'watchers', + :action => 'new', + :object_type => 'issues', + :object_id => '1' ) + + should route(:delete, "/watchers/1").to( :controller => 'watchers', + :action => 'destroy', + :id => '1' ) end end From dcea08f70ed6f12628598b651806e7fe2e0d4a4c Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 14 Aug 2012 08:59:58 +0200 Subject: [PATCH 17/17] adds watch routes for messages and boards --- config/routes.rb | 2 +- test/integration/routing_test.rb | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 93a86793a5..bc22a4b87e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,7 +74,7 @@ OpenProject::Application.routes.draw do # generic route for adding/removing watchers # looks to be ressourceful - scope ':object_type/:object_id', :constraints => { :object_type => /issues/, + scope ':object_type/:object_id', :constraints => { :object_type => /issues|messages|boards/, :object_id => /\d+/ } do resources :watchers, :only => [:new] diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 1fda10cbe5..f5f9aafca6 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -227,21 +227,23 @@ class RoutingTest < ActionController::IntegrationTest end context "watches" do - should route(:post, "/issues/1/watch").to( :controller => 'watchers', - :action => 'watch', - :object_type => 'issues', - :object_id => '1' ) + ['issues', 'messages, boards'].each do |type| + should route(:post, "/#{type}/1/watch").to( :controller => 'watchers', + :action => 'watch', + :object_type => type, + :object_id => '1' ) - should route(:delete, "/issues/1/unwatch").to( :controller => 'watchers', - :action => 'unwatch', - :object_type => 'issues', - :object_id => '1' ) - - should route(:get, "/issues/1/watchers/new").to( :controller => 'watchers', - :action => 'new', - :object_type => 'issues', + should route(:delete, "/#{type}/1/unwatch").to( :controller => 'watchers', + :action => 'unwatch', + :object_type => type, :object_id => '1' ) + should route(:get, "/#{type}/1/watchers/new").to( :controller => 'watchers', + :action => 'new', + :object_type => type, + :object_id => '1' ) + end + should route(:delete, "/watchers/1").to( :controller => 'watchers', :action => 'destroy', :id => '1' )