redmine_extensions 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/redmine_extensions/redmine_extensions.js.orig +648 -0
- data/app/views/easy_entity_assignments/_query_index.html.erb.orig +16 -0
- data/config/locales/cs.yml +4 -1
- data/config/locales/en.yml +1 -0
- data/lib/generators/redmine_extensions/entity/templates/context_menu.html.erb.erb +14 -1
- data/lib/generators/redmine_extensions/entity/templates/controller.rb.erb +40 -6
- data/lib/generators/redmine_extensions/entity/templates/edit.js.erb.erb +5 -5
- data/lib/generators/redmine_extensions/entity/templates/index.js.erb.erb +3 -3
- data/lib/generators/redmine_extensions/entity/templates/new.js.erb.erb +5 -5
- data/lib/generators/redmine_extensions/entity/templates/show.js.erb.erb +3 -3
- data/lib/redmine_extensions/easy_query_helpers/outputs.rb +18 -2
- data/lib/redmine_extensions/query_output.rb +30 -11
- data/lib/redmine_extensions/redmine_patches/controllers/issues_controller_patch.rb +9 -0
- data/lib/redmine_extensions/version.rb +1 -1
- data/lib/redmine_extensions/version.rb.orig +7 -0
- data/spec/redmine/app/controllers/custom_field_enumerations_controller.rb +75 -0
- data/spec/redmine/app/controllers/imports_controller.rb +121 -0
- data/spec/redmine/app/helpers/imports_helper.rb +47 -0
- data/spec/redmine/app/models/custom_field_enumeration.rb +90 -0
- data/spec/redmine/app/models/import.rb +249 -0
- data/spec/redmine/app/models/import_item.rb +22 -0
- data/spec/redmine/app/models/issue_import.rb +186 -0
- data/spec/redmine/app/views/attachments/image.html.erb +3 -0
- data/spec/redmine/app/views/attachments/other.html.erb +3 -0
- data/spec/redmine/app/views/common/_image.html.erb +1 -0
- data/spec/redmine/app/views/common/_other.html.erb +1 -0
- data/spec/redmine/app/views/custom_field_enumerations/create.js.erb +2 -0
- data/spec/redmine/app/views/custom_field_enumerations/destroy.html.erb +14 -0
- data/spec/redmine/app/views/custom_field_enumerations/index.html.erb +47 -0
- data/spec/redmine/app/views/custom_fields/formats/_enumeration.erb +12 -0
- data/spec/redmine/app/views/imports/_fields_mapping.html.erb +90 -0
- data/spec/redmine/app/views/imports/mapping.html.erb +52 -0
- data/spec/redmine/app/views/imports/mapping.js.erb +1 -0
- data/spec/redmine/app/views/imports/new.html.erb +15 -0
- data/spec/redmine/app/views/imports/run.html.erb +20 -0
- data/spec/redmine/app/views/imports/run.js.erb +11 -0
- data/spec/redmine/app/views/imports/settings.html.erb +30 -0
- data/spec/redmine/app/views/imports/show.html.erb +38 -0
- data/spec/redmine/app/views/layouts/_file.html.erb +15 -0
- data/spec/redmine/app/views/mailer/security_notification.html.erb +13 -0
- data/spec/redmine/app/views/mailer/security_notification.text.erb +8 -0
- data/spec/redmine/app/views/mailer/settings_updated.html.erb +14 -0
- data/spec/redmine/app/views/mailer/settings_updated.text.erb +12 -0
- data/spec/redmine/app/views/queries/_query_form.html.erb +62 -0
- data/spec/redmine/app/views/repositories/_changeset.html.erb +40 -0
- data/spec/redmine/app/views/search/index.api.rsb +12 -0
- data/spec/redmine/app/views/settings/_api.html.erb +10 -0
- data/spec/redmine/app/views/settings/_attachments.html.erb +21 -0
- data/spec/redmine/app/views/wiki/_new_modal.html.erb +21 -0
- data/spec/redmine/app/views/wiki/new.html.erb +17 -0
- data/spec/redmine/app/views/wiki/new.js.erb +2 -0
- data/spec/redmine/appveyor.yml +36 -0
- data/spec/redmine/db/migrate/20150725112753_insert_allowed_statuses_for_new_issues.rb +23 -0
- data/spec/redmine/db/migrate/20150730122707_create_imports.rb +13 -0
- data/spec/redmine/db/migrate/20150730122735_create_import_items.rb +10 -0
- data/spec/redmine/db/migrate/20150921204850_change_time_entries_comments_limit_to_1024.rb +9 -0
- data/spec/redmine/db/migrate/20150921210243_change_wiki_contents_comments_limit_to_1024.rb +11 -0
- data/spec/redmine/db/migrate/20151020182334_change_attachments_filesize_limit_to_8.rb +9 -0
- data/spec/redmine/db/migrate/20151020182731_fix_comma_in_user_format_setting_value.rb +13 -0
- data/spec/redmine/db/migrate/20151021184614_change_issue_categories_name_limit_to_60.rb +9 -0
- data/spec/redmine/db/migrate/20151021185456_change_auth_sources_filter_to_text.rb +9 -0
- data/spec/redmine/db/migrate/20151021190616_change_user_preferences_hide_mail_default_to_true.rb +9 -0
- data/spec/redmine/db/migrate/20151024082034_add_tokens_updated_on.rb +10 -0
- data/spec/redmine/db/migrate/20151025072118_create_custom_field_enumerations.rb +10 -0
- data/spec/redmine/db/migrate/20151031095005_add_projects_default_version_id.rb +12 -0
- data/spec/redmine/db/migrate/20160404080304_force_password_reset_during_setup.rb +9 -0
- data/spec/redmine/db/migrate/20160416072926_remove_position_defaults.rb +13 -0
- data/spec/redmine/db/migrate/20160529063352_add_roles_settings.rb +5 -0
- data/spec/redmine/lib/redmine/acts/positioned.rb +118 -0
- data/spec/redmine/lib/redmine/helpers/url.rb +35 -0
- data/spec/redmine/lib/redmine/hook/listener.rb +32 -0
- data/spec/redmine/lib/redmine/hook/view_listener.rb +78 -0
- data/spec/redmine/log/test.log +2 -0
- data/spec/redmine/plugins/dummy_plugin/Gemfile +1 -0
- data/spec/redmine/plugins/dummy_plugin/app/controllers/dummy_autocompletes_controller.rb +4 -0
- data/spec/redmine/plugins/dummy_plugin/app/views/dummy_autocompletes/index.html.erb +3 -0
- data/spec/redmine/plugins/dummy_plugin/config/locales/en.yml +2 -0
- data/spec/redmine/plugins/dummy_plugin/config/routes.rb +1 -0
- data/spec/redmine/plugins/dummy_plugin/init.rb +34 -0
- data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/easy_patch/redmine/controllers/issues_controller_patch.example +30 -0
- data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/easy_patch/redmine/helpers/issues_helper_patch.example +30 -0
- data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/easy_patch/redmine/models/issue_patch.example +30 -0
- data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/hooks.rb +5 -0
- data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/internals.rb +4 -0
- data/spec/redmine/public/images/jstoolbar/bt_precode.png +0 -0
- data/spec/redmine/public/images/reorder.png +0 -0
- data/spec/redmine/public/javascripts/jquery-1.11.1-ui-1.11.0-ujs-3.1.4.js +21 -0
- data/spec/redmine/public/javascripts/redmine_extensions/application.js +13 -0
- data/spec/redmine/public/javascripts/redmine_extensions/easy_togglers.js +58 -0
- data/spec/redmine/public/javascripts/redmine_extensions/jquery.entityarray.js +130 -0
- data/spec/redmine/public/javascripts/redmine_extensions/redmine_extensions.js +642 -0
- data/spec/redmine/public/javascripts/responsive.js +83 -0
- data/spec/redmine/public/stylesheets/responsive.css +799 -0
- data/spec/redmine/test/fixtures/files/import_dates.csv +4 -0
- data/spec/redmine/test/fixtures/files/import_iso8859-1.csv +3 -0
- data/spec/redmine/test/fixtures/files/import_issues.csv +4 -0
- data/spec/redmine/test/fixtures/ldap/slapd.centos6.conf +24 -0
- data/spec/redmine/test/fixtures/ldap/slapd.ubuntu.12.04.conf +23 -0
- data/spec/redmine/test/fixtures/mail_handler/issue_update_with_cc.eml +19 -0
- data/spec/redmine/test/fixtures/mail_handler/ticket_on_project_given_by_to_header.eml +60 -0
- data/spec/redmine/test/fixtures/mail_handler/ticket_with_text_attachment_iso-8859-2.eml +31 -0
- data/spec/redmine/test/functional/custom_field_enumerations_controller_test.rb +115 -0
- data/spec/redmine/test/functional/imports_controller_test.rb +205 -0
- data/spec/redmine/test/functional/sessions_controller_test.rb +138 -0
- data/spec/redmine/test/integration/api_test/search_test.rb +92 -0
- data/spec/redmine/test/integration/routing/imports_test.rb +36 -0
- data/spec/redmine/test/integration/sessions_test.rb +97 -0
- data/spec/redmine/test/ui/custom_fields_test_ui.rb +38 -0
- data/spec/redmine/test/unit/attachment_transaction_test.rb +76 -0
- data/spec/redmine/test/unit/helpers/journals_helper_test.rb +48 -0
- data/spec/redmine/test/unit/helpers/wiki_helper_test.rb +45 -0
- data/spec/redmine/test/unit/issue_import_test.rb +178 -0
- data/spec/redmine/test/unit/lib/redmine/acts/positioned_with_scope_test.rb +53 -0
- data/spec/redmine/test/unit/lib/redmine/acts/positioned_without_scope_test.rb +55 -0
- data/spec/redmine/test/unit/lib/redmine/field_format/enumeration_format_test.rb +91 -0
- data/spec/support/easy_queries_helpers.rb +0 -0
- metadata +216 -10
@@ -0,0 +1,4 @@
|
|
1
|
+
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker;status
|
2
|
+
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug;new
|
3
|
+
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request;new
|
4
|
+
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug;assigned
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Sample OpenLDAP configuration file for Redmine LDAP test server
|
2
|
+
# CentOS6 openldap-servers-2.4.40-6.el6_7.x86_64
|
3
|
+
#
|
4
|
+
|
5
|
+
include /etc/openldap/schema/core.schema
|
6
|
+
include /etc/openldap/schema/cosine.schema
|
7
|
+
include /etc/openldap/schema/inetorgperson.schema
|
8
|
+
include /etc/openldap/schema/openldap.schema
|
9
|
+
include /etc/openldap/schema/nis.schema
|
10
|
+
|
11
|
+
pidfile /var/run/openldap/slapd.pid
|
12
|
+
argsfile /var/run/openldap/slapd.args
|
13
|
+
|
14
|
+
modulepath /usr/lib64/openldap
|
15
|
+
moduleload back_bdb.la
|
16
|
+
|
17
|
+
database bdb
|
18
|
+
suffix "dc=redmine,dc=org"
|
19
|
+
rootdn "cn=Manager,dc=redmine,dc=org"
|
20
|
+
rootpw secret
|
21
|
+
directory /var/lib/ldap
|
22
|
+
|
23
|
+
# Indices to maintain
|
24
|
+
index objectClass eq
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Sample OpenLDAP configuration file for Redmine LDAP test server
|
2
|
+
# Ubuntu 12.04 LTS Server Edition 64 bit slapd (2.4.28-1.1ubuntu4.6)
|
3
|
+
#
|
4
|
+
|
5
|
+
include /etc/ldap/schema/core.schema
|
6
|
+
include /etc/ldap/schema/cosine.schema
|
7
|
+
include /etc/ldap/schema/inetorgperson.schema
|
8
|
+
include /etc/ldap/schema/openldap.schema
|
9
|
+
include /etc/ldap/schema/nis.schema
|
10
|
+
|
11
|
+
pidfile /var/run/slapd/slapd.pid
|
12
|
+
argsfile /var/run/slapd/slapd.args
|
13
|
+
|
14
|
+
modulepath /usr/lib/ldap
|
15
|
+
moduleload back_bdb.la
|
16
|
+
|
17
|
+
database bdb
|
18
|
+
suffix "dc=redmine,dc=org"
|
19
|
+
rootdn "cn=Manager,dc=redmine,dc=org"
|
20
|
+
rootpw secret
|
21
|
+
|
22
|
+
# Indices to maintain
|
23
|
+
index objectClass eq
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Return-Path: <JSmith@somenet.foo>
|
2
|
+
Received: from osiris ([127.0.0.1])
|
3
|
+
by OSIRIS
|
4
|
+
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
5
|
+
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
6
|
+
In-Reply-To: <redmine.issue-2.20060719210421@osiris>
|
7
|
+
From: "John Smith" <JSmith@somenet.foo>
|
8
|
+
To: <redmine@somenet.foo>
|
9
|
+
Cc: <dlopper@somenet.foo>
|
10
|
+
Subject: Re: update to issue 2
|
11
|
+
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
12
|
+
MIME-Version: 1.0
|
13
|
+
Content-Type: text/plain;
|
14
|
+
format=flowed;
|
15
|
+
charset="iso-8859-1";
|
16
|
+
reply-type=original
|
17
|
+
Content-Transfer-Encoding: 7bit
|
18
|
+
|
19
|
+
An update to the issue by the sender.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Return-Path: <JSmith@somenet.foo>
|
2
|
+
Received: from osiris ([127.0.0.1])
|
3
|
+
by OSIRIS
|
4
|
+
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
5
|
+
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
6
|
+
From: "John Smith" <JSmith@somenet.foo>
|
7
|
+
To: <redmine+onlinestore@somenet.foo>
|
8
|
+
Subject: New ticket on a given project
|
9
|
+
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
10
|
+
MIME-Version: 1.0
|
11
|
+
Content-Type: text/plain;
|
12
|
+
format=flowed;
|
13
|
+
charset="iso-8859-1";
|
14
|
+
reply-type=original
|
15
|
+
Content-Transfer-Encoding: 7bit
|
16
|
+
X-Priority: 3
|
17
|
+
X-MSMail-Priority: Normal
|
18
|
+
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
19
|
+
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
20
|
+
|
21
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
22
|
+
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
23
|
+
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
24
|
+
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
25
|
+
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
26
|
+
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
27
|
+
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
28
|
+
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
29
|
+
sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et
|
30
|
+
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
31
|
+
platea dictumst.
|
32
|
+
|
33
|
+
Status: Resolved
|
34
|
+
due date: 2010-12-31
|
35
|
+
Start Date:2010-01-01
|
36
|
+
Assigned to: John Smith
|
37
|
+
fixed version: alpha
|
38
|
+
estimated hours: 2.5
|
39
|
+
done ratio: 30
|
40
|
+
|
41
|
+
--- This line starts with a delimiter and should not be stripped
|
42
|
+
|
43
|
+
This paragraph is before delimiters.
|
44
|
+
|
45
|
+
BREAK
|
46
|
+
|
47
|
+
This paragraph is between delimiters.
|
48
|
+
|
49
|
+
---
|
50
|
+
|
51
|
+
This paragraph is after the delimiter so it shouldn't appear.
|
52
|
+
|
53
|
+
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
54
|
+
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
55
|
+
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
56
|
+
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
57
|
+
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
58
|
+
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Date: Thu, 14 Jan 2016 18:32:45 +0100
|
2
|
+
From: John Smith <JSmith@somenet.foo>
|
3
|
+
To: redmine@somenet.foo
|
4
|
+
Message-ID: <7A3.L9Yi.1Ki1}PMZiV5.1Mbzkz@seznam.cz>
|
5
|
+
Subject: issue #21742
|
6
|
+
Mime-Version: 1.0
|
7
|
+
Content-Type: multipart/mixed;
|
8
|
+
boundary="=_08d580646981073f1a667ba3=898e56d9-3d29-5ed2-9c9a-cc3a5d9474b5_=";
|
9
|
+
charset=UTF-8
|
10
|
+
Content-Transfer-Encoding: 7bit
|
11
|
+
X-Mailer: szn-ebox-4.5.88
|
12
|
+
|
13
|
+
|
14
|
+
--=_08d580646981073f1a667ba3=898e56d9-3d29-5ed2-9c9a-cc3a5d9474b5_=
|
15
|
+
Content-Type: text/plain;
|
16
|
+
charset=utf-8
|
17
|
+
Content-Transfer-Encoding: base64
|
18
|
+
|
19
|
+
|
20
|
+
--=_08d580646981073f1a667ba3=898e56d9-3d29-5ed2-9c9a-cc3a5d9474b5_=
|
21
|
+
Content-Type: text/plain;
|
22
|
+
charset=UTF-8;
|
23
|
+
name=latin2.txt
|
24
|
+
Content-Transfer-Encoding: quoted-printable
|
25
|
+
Content-Disposition: attachment;
|
26
|
+
filename=latin2.txt;
|
27
|
+
size=19
|
28
|
+
|
29
|
+
p=F8=EDli=B9 =BEluou=E8k=FD k=F9n=
|
30
|
+
|
31
|
+
--=_08d580646981073f1a667ba3=898e56d9-3d29-5ed2-9c9a-cc3a5d9474b5_=--
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# Redmine - project management software
|
2
|
+
# Copyright (C) 2006-2016 Jean-Philippe Lang
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or
|
5
|
+
# modify it under the terms of the GNU General Public License
|
6
|
+
# as published by the Free Software Foundation; either version 2
|
7
|
+
# of the License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
17
|
+
|
18
|
+
require File.expand_path('../../test_helper', __FILE__)
|
19
|
+
|
20
|
+
class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
21
|
+
fixtures :users, :email_addresses
|
22
|
+
|
23
|
+
def setup
|
24
|
+
@request.session[:user_id] = 1
|
25
|
+
@field = GroupCustomField.create!(:name => 'List', :field_format => 'enumeration', :is_required => false)
|
26
|
+
@foo = CustomFieldEnumeration.new(:name => 'Foo')
|
27
|
+
@bar = CustomFieldEnumeration.new(:name => 'Bar')
|
28
|
+
@field.enumerations << @foo
|
29
|
+
@field.enumerations << @bar
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_index
|
33
|
+
get :index, :custom_field_id => @field.id
|
34
|
+
assert_response :success
|
35
|
+
|
36
|
+
assert_select 'ul#custom_field_enumerations' do
|
37
|
+
assert_select 'li', 2
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_create
|
42
|
+
assert_difference 'CustomFieldEnumeration.count' do
|
43
|
+
post :create, :custom_field_id => @field.id, :custom_field_enumeration => { :name => 'Baz' }
|
44
|
+
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_equal 3, @field.reload.enumerations.count
|
48
|
+
enum = @field.enumerations.last
|
49
|
+
assert_equal 'Baz', enum.name
|
50
|
+
assert_equal true, enum.active
|
51
|
+
assert_equal 3, enum.position
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_create_xhr
|
55
|
+
assert_difference 'CustomFieldEnumeration.count' do
|
56
|
+
xhr :post, :create, :custom_field_id => @field.id, :custom_field_enumeration => { :name => 'Baz' }
|
57
|
+
assert_response :success
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_update_each
|
62
|
+
put :update_each, :custom_field_id => @field.id, :custom_field_enumerations => {
|
63
|
+
@bar.id => {:position => "1", :name => "Baz", :active => "1"},
|
64
|
+
@foo.id => {:position => "2", :name => "Foo", :active => "0"}
|
65
|
+
}
|
66
|
+
assert_response 302
|
67
|
+
|
68
|
+
@bar.reload
|
69
|
+
assert_equal "Baz", @bar.name
|
70
|
+
assert_equal true, @bar.active
|
71
|
+
assert_equal 1, @bar.position
|
72
|
+
|
73
|
+
@foo.reload
|
74
|
+
assert_equal "Foo", @foo.name
|
75
|
+
assert_equal false, @foo.active
|
76
|
+
assert_equal 2, @foo.position
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_destroy
|
80
|
+
assert_difference 'CustomFieldEnumeration.count', -1 do
|
81
|
+
delete :destroy, :custom_field_id => @field.id, :id => @foo.id
|
82
|
+
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
83
|
+
end
|
84
|
+
|
85
|
+
assert_equal 1, @field.reload.enumerations.count
|
86
|
+
enum = @field.enumerations.last
|
87
|
+
assert_equal 'Bar', enum.name
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_destroy_enumeration_in_use_should_display_destroy_form
|
91
|
+
group = Group.generate!
|
92
|
+
group.custom_field_values = {@field.id.to_s => @foo.id.to_s}
|
93
|
+
group.save!
|
94
|
+
|
95
|
+
assert_no_difference 'CustomFieldEnumeration.count' do
|
96
|
+
delete :destroy, :custom_field_id => @field.id, :id => @foo.id
|
97
|
+
assert_response :success
|
98
|
+
|
99
|
+
assert_select 'select[name=?]', 'reassign_to_id'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_destroy_enumeration_in_use_should_destroy_and_reassign_values
|
104
|
+
group = Group.generate!
|
105
|
+
group.custom_field_values = {@field.id.to_s => @foo.id.to_s}
|
106
|
+
group.save!
|
107
|
+
|
108
|
+
assert_difference 'CustomFieldEnumeration.count', -1 do
|
109
|
+
delete :destroy, :custom_field_id => @field.id, :id => @foo.id, :reassign_to_id => @bar.id
|
110
|
+
assert_response 302
|
111
|
+
end
|
112
|
+
|
113
|
+
assert_equal @bar.id.to_s, group.reload.custom_field_value(@field)
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
# Redmine - project management software
|
2
|
+
# Copyright (C) 2006-2016 Jean-Philippe Lang
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or
|
5
|
+
# modify it under the terms of the GNU General Public License
|
6
|
+
# as published by the Free Software Foundation; either version 2
|
7
|
+
# of the License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
17
|
+
|
18
|
+
require File.expand_path('../../test_helper', __FILE__)
|
19
|
+
|
20
|
+
class ImportsControllerTest < Redmine::ControllerTest
|
21
|
+
fixtures :projects, :enabled_modules,
|
22
|
+
:users, :email_addresses,
|
23
|
+
:roles, :members, :member_roles,
|
24
|
+
:issues, :issue_statuses,
|
25
|
+
:trackers, :projects_trackers,
|
26
|
+
:versions,
|
27
|
+
:issue_categories,
|
28
|
+
:enumerations,
|
29
|
+
:workflows,
|
30
|
+
:custom_fields,
|
31
|
+
:custom_values,
|
32
|
+
:custom_fields_projects,
|
33
|
+
:custom_fields_trackers
|
34
|
+
|
35
|
+
def setup
|
36
|
+
User.current = nil
|
37
|
+
@request.session[:user_id] = 2
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
Import.destroy_all
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_new_should_display_the_upload_form
|
45
|
+
get :new
|
46
|
+
assert_response :success
|
47
|
+
assert_select 'input[name=?]', 'file'
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_create_should_save_the_file
|
51
|
+
import = new_record(Import) do
|
52
|
+
post :create, :file => uploaded_test_file('import_issues.csv', 'text/csv')
|
53
|
+
assert_response 302
|
54
|
+
end
|
55
|
+
assert_equal 2, import.user_id
|
56
|
+
assert_match /\A[0-9a-f]+\z/, import.filename
|
57
|
+
assert import.file_exists?
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_get_settings_should_display_settings_form
|
61
|
+
import = generate_import
|
62
|
+
get :settings, :id => import.to_param
|
63
|
+
assert_response :success
|
64
|
+
assert_select 'select[name=?]', 'import_settings[separator]'
|
65
|
+
assert_select 'select[name=?]', 'import_settings[wrapper]'
|
66
|
+
assert_select 'select[name=?]', 'import_settings[encoding]'
|
67
|
+
assert_select 'select[name=?]', 'import_settings[date_format]'
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_post_settings_should_update_settings
|
71
|
+
import = generate_import
|
72
|
+
|
73
|
+
post :settings, :id => import.to_param,
|
74
|
+
:import_settings => {:separator => ":", :wrapper => "|", :encoding => "UTF-8", :date_format => '%m/%d/%Y'}
|
75
|
+
assert_redirected_to "/imports/#{import.to_param}/mapping"
|
76
|
+
|
77
|
+
import.reload
|
78
|
+
assert_equal ":", import.settings['separator']
|
79
|
+
assert_equal "|", import.settings['wrapper']
|
80
|
+
assert_equal "UTF-8", import.settings['encoding']
|
81
|
+
assert_equal '%m/%d/%Y', import.settings['date_format']
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_post_settings_should_update_total_items_count
|
85
|
+
import = generate_import('import_iso8859-1.csv')
|
86
|
+
|
87
|
+
post :settings, :id => import.to_param,
|
88
|
+
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "ISO-8859-1"}
|
89
|
+
assert_response 302
|
90
|
+
import.reload
|
91
|
+
assert_equal 2, import.total_items
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_post_settings_with_wrong_encoding_should_display_error
|
95
|
+
import = generate_import('import_iso8859-1.csv')
|
96
|
+
|
97
|
+
post :settings, :id => import.to_param,
|
98
|
+
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "UTF-8"}
|
99
|
+
assert_response 200
|
100
|
+
import.reload
|
101
|
+
assert_nil import.total_items
|
102
|
+
assert_select 'div#flash_error', /not a valid UTF-8 encoded file/
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_get_mapping_should_display_mapping_form
|
106
|
+
import = generate_import('import_iso8859-1.csv')
|
107
|
+
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
|
108
|
+
import.save!
|
109
|
+
|
110
|
+
get :mapping, :id => import.to_param
|
111
|
+
assert_response :success
|
112
|
+
|
113
|
+
assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
|
114
|
+
assert_select 'option', 4
|
115
|
+
assert_select 'option[value="0"]', :text => 'column A'
|
116
|
+
end
|
117
|
+
|
118
|
+
assert_select 'table.sample-data' do
|
119
|
+
assert_select 'tr', 3
|
120
|
+
assert_select 'td', 9
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_post_mapping_should_update_mapping
|
125
|
+
import = generate_import('import_iso8859-1.csv')
|
126
|
+
|
127
|
+
post :mapping, :id => import.to_param,
|
128
|
+
:import_settings => {:mapping => {:project_id => '1', :tracker_id => '2', :subject => '0'}}
|
129
|
+
assert_redirected_to "/imports/#{import.to_param}/run"
|
130
|
+
import.reload
|
131
|
+
mapping = import.settings['mapping']
|
132
|
+
assert mapping
|
133
|
+
assert_equal '1', mapping['project_id']
|
134
|
+
assert_equal '2', mapping['tracker_id']
|
135
|
+
assert_equal '0', mapping['subject']
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_get_run
|
139
|
+
import = generate_import_with_mapping
|
140
|
+
|
141
|
+
get :run, :id => import
|
142
|
+
assert_response :success
|
143
|
+
assert_select '#import-progress'
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_post_run_should_import_the_file
|
147
|
+
import = generate_import_with_mapping
|
148
|
+
|
149
|
+
assert_difference 'Issue.count', 3 do
|
150
|
+
post :run, :id => import
|
151
|
+
assert_redirected_to "/imports/#{import.to_param}"
|
152
|
+
end
|
153
|
+
|
154
|
+
import.reload
|
155
|
+
assert_equal true, import.finished
|
156
|
+
assert_equal 3, import.items.count
|
157
|
+
|
158
|
+
issues = Issue.order(:id => :desc).limit(3).to_a
|
159
|
+
assert_equal ["Child of existing issue", "Child 1", "First"], issues.map(&:subject)
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_post_run_should_import_max_items_and_resume
|
163
|
+
ImportsController.any_instance.stubs(:max_items_per_request).returns(2)
|
164
|
+
import = generate_import_with_mapping
|
165
|
+
|
166
|
+
assert_difference 'Issue.count', 2 do
|
167
|
+
post :run, :id => import
|
168
|
+
assert_redirected_to "/imports/#{import.to_param}/run"
|
169
|
+
end
|
170
|
+
|
171
|
+
assert_difference 'Issue.count', 1 do
|
172
|
+
post :run, :id => import
|
173
|
+
assert_redirected_to "/imports/#{import.to_param}"
|
174
|
+
end
|
175
|
+
|
176
|
+
issues = Issue.order(:id => :desc).limit(3).to_a
|
177
|
+
assert_equal ["Child of existing issue", "Child 1", "First"], issues.map(&:subject)
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_show_without_errors
|
181
|
+
import = generate_import_with_mapping
|
182
|
+
import.run
|
183
|
+
assert_equal 0, import.unsaved_items.count
|
184
|
+
|
185
|
+
get :show, :id => import.to_param
|
186
|
+
assert_response :success
|
187
|
+
|
188
|
+
assert_select 'ul#saved-items'
|
189
|
+
assert_select 'ul#saved-items li', import.saved_items.count
|
190
|
+
assert_select 'table#unsaved-items', 0
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_show_with_errors_should_show_unsaved_items
|
194
|
+
import = generate_import_with_mapping
|
195
|
+
import.mapping.merge! 'subject' => 20
|
196
|
+
import.run
|
197
|
+
assert_not_equal 0, import.unsaved_items.count
|
198
|
+
|
199
|
+
get :show, :id => import.to_param
|
200
|
+
assert_response :success
|
201
|
+
|
202
|
+
assert_select 'table#unsaved-items'
|
203
|
+
assert_select 'table#unsaved-items tbody tr', import.unsaved_items.count
|
204
|
+
end
|
205
|
+
end
|