summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/roles.yml1
-rw-r--r--test/functional/repositories_controller_test.rb32
-rw-r--r--test/integration/routing/repositories_test.rb26
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)