diff options
author | Go MAEDA <maeda@farend.jp> | 2019-05-09 07:40:06 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-05-09 07:40:06 +0000 |
commit | b540046ed7084ba50f5ca280f3ffae0751af8142 (patch) | |
tree | 4bc946090d4940a219e84f70ca72c5655de5be42 /test | |
parent | bcc60805c97104f44a37b92321d7aa1e5c51b622 (diff) | |
download | redmine-b540046ed7084ba50f5ca280f3ffae0751af8142.tar.gz redmine-b540046ed7084ba50f5ca280f3ffae0751af8142.zip |
Generalize issues imports (#28234).
Extend import controller to support arbitrary imports based on Import subclasses. This way, we may add other kinds of imports, by providing some views and a custom import class. This may also be done from within plugins.
Patch by Gregor Schmidt.
git-svn-id: http://svn.redmine.org/redmine/trunk@18145 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/imports_controller_test.rb | 3 | ||||
-rw-r--r-- | test/integration/routing/imports_test.rb | 3 | ||||
-rw-r--r-- | test/unit/issue_import_test.rb | 6 |
3 files changed, 10 insertions, 2 deletions
diff --git a/test/functional/imports_controller_test.rb b/test/functional/imports_controller_test.rb index d6a110056..a094b81eb 100644 --- a/test/functional/imports_controller_test.rb +++ b/test/functional/imports_controller_test.rb @@ -44,7 +44,7 @@ class ImportsControllerTest < Redmine::ControllerTest end def test_new_should_display_the_upload_form - get :new + get :new, :params => { :type => 'IssueImport' } assert_response :success assert_select 'input[name=?]', 'file' end @@ -52,6 +52,7 @@ class ImportsControllerTest < Redmine::ControllerTest def test_create_should_save_the_file import = new_record(Import) do post :create, :params => { + :type => 'IssueImport', :file => uploaded_test_file('import_issues.csv', 'text/csv') } assert_response 302 diff --git a/test/integration/routing/imports_test.rb b/test/integration/routing/imports_test.rb index ec71470d0..eb96a9a98 100644 --- a/test/integration/routing/imports_test.rb +++ b/test/integration/routing/imports_test.rb @@ -21,7 +21,8 @@ require File.expand_path('../../../test_helper', __FILE__) class RoutingImportsTest < Redmine::RoutingTest def test_imports - should_route 'GET /issues/imports/new' => 'imports#new' + should_route 'GET /issues/imports/new' => 'imports#new', :type => 'IssueImport' + should_route 'POST /imports' => 'imports#create' should_route 'GET /imports/4ae6bc' => 'imports#show', :id => '4ae6bc' diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb index 9c4eafba1..4def8b120 100644 --- a/test/unit/issue_import_test.rb +++ b/test/unit/issue_import_test.rb @@ -41,6 +41,12 @@ class IssueImportTest < ActiveSupport::TestCase set_language_if_valid 'en' end + def test_authorized + assert IssueImport.authorized?(User.find(1)) # admins + assert IssueImport.authorized?(User.find(2)) # has import_issues permission + assert !IssueImport.authorized?(User.find(3)) # does not have permission + end + def test_create_versions_should_create_missing_versions import = generate_import_with_mapping import.mapping.merge!('fixed_version' => '9', 'create_versions' => '1') |