diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-05 10:56:27 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-05 10:56:27 +0000 |
commit | 1d4ef8964def4ecbe7a11485f72d7fbe61c55724 (patch) | |
tree | 4986d5f51daebd1ff66ac58cdf56042624e2edc3 /test | |
parent | c4ea429acbc09205155509e9c41e111294bc8f82 (diff) | |
download | redmine-1d4ef8964def4ecbe7a11485f72d7fbe61c55724.tar.gz redmine-1d4ef8964def4ecbe7a11485f72d7fbe61c55724.zip |
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8777 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/roles.yml | 1 | ||||
-rw-r--r-- | test/functional/repositories_controller_test.rb | 32 | ||||
-rw-r--r-- | test/integration/routing/repositories_test.rb | 26 |
3 files changed, 59 insertions, 0 deletions
diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index 0549ebe6c..0eaaafe72 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -53,6 +53,7 @@ roles_001: - :browse_repository - :manage_repository - :view_changesets + - :manage_related_issues - :manage_project_activities position: 1 diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 6bcbb6beb..844e8fa87 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -160,6 +160,38 @@ class RepositoriesControllerTest < ActionController::TestCase } end + def test_add_related_issue + @request.session[:user_id] = 2 + assert_difference 'Changeset.find(103).issues.size' do + post :add_related_issue, :id => 1, :rev => 4, :issue_id => 2 + assert_response :success + end + assert_select_rjs :replace_html, 'related-issues' + assert_equal [2], Changeset.find(103).issue_ids + end + + def test_add_related_issue_with_invalid_issue_id + @request.session[:user_id] = 2 + assert_no_difference 'Changeset.find(103).issues.size' do + post :add_related_issue, :id => 1, :rev => 4, :issue_id => 9999 + assert_response :success + end + assert_include 'alert("Issue is invalid")', @response.body + end + + def test_remove_related_issue + Changeset.find(103).issues << Issue.find(1) + Changeset.find(103).issues << Issue.find(2) + + @request.session[:user_id] = 2 + assert_difference 'Changeset.find(103).issues.size', -1 do + delete :remove_related_issue, :id => 1, :rev => 4, :issue_id => 2 + assert_response :success + end + assert_select_rjs :remove, 'related-issue-2' + assert_equal [1], Changeset.find(103).issue_ids + end + def test_graph_commits_per_month get :graph, :id => 1, :graph => 'commits_per_month' assert_response :success diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb index 5b2ccbcac..44fe7309e 100644 --- a/test/integration/routing/repositories_test.rb +++ b/test/integration/routing/repositories_test.rb @@ -341,6 +341,32 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest ) end + def test_repositories_related_issues + assert_routing( + { :method => 'post', + :path => "/projects/redmine/repository/revisions/123/issues" }, + { :controller => 'repositories', :action => 'add_related_issue', :id => 'redmine', :rev => '123' } + ) + assert_routing( + { :method => 'delete', + :path => "/projects/redmine/repository/revisions/123/issues/25" }, + { :controller => 'repositories', :action => 'remove_related_issue', :id => 'redmine', :rev => '123', :issue_id => '25' } + ) + end + + def test_repositories_related_issues_with_repository_id + assert_routing( + { :method => 'post', + :path => "/projects/redmine/repository/foo/revisions/123/issues" }, + { :controller => 'repositories', :action => 'add_related_issue', :id => 'redmine', :repository_id => 'foo', :rev => '123' } + ) + assert_routing( + { :method => 'delete', + :path => "/projects/redmine/repository/foo/revisions/123/issues/25" }, + { :controller => 'repositories', :action => 'remove_related_issue', :id => 'redmine', :repository_id => 'foo', :rev => '123', :issue_id => '25' } + ) + end + private def repository_path_hash(arr) |