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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/redmine_extensions/redmine_extensions.js.orig +648 -0
  3. data/app/views/easy_entity_assignments/_query_index.html.erb.orig +16 -0
  4. data/config/locales/cs.yml +4 -1
  5. data/config/locales/en.yml +1 -0
  6. data/lib/generators/redmine_extensions/entity/templates/context_menu.html.erb.erb +14 -1
  7. data/lib/generators/redmine_extensions/entity/templates/controller.rb.erb +40 -6
  8. data/lib/generators/redmine_extensions/entity/templates/edit.js.erb.erb +5 -5
  9. data/lib/generators/redmine_extensions/entity/templates/index.js.erb.erb +3 -3
  10. data/lib/generators/redmine_extensions/entity/templates/new.js.erb.erb +5 -5
  11. data/lib/generators/redmine_extensions/entity/templates/show.js.erb.erb +3 -3
  12. data/lib/redmine_extensions/easy_query_helpers/outputs.rb +18 -2
  13. data/lib/redmine_extensions/query_output.rb +30 -11
  14. data/lib/redmine_extensions/redmine_patches/controllers/issues_controller_patch.rb +9 -0
  15. data/lib/redmine_extensions/version.rb +1 -1
  16. data/lib/redmine_extensions/version.rb.orig +7 -0
  17. data/spec/redmine/app/controllers/custom_field_enumerations_controller.rb +75 -0
  18. data/spec/redmine/app/controllers/imports_controller.rb +121 -0
  19. data/spec/redmine/app/helpers/imports_helper.rb +47 -0
  20. data/spec/redmine/app/models/custom_field_enumeration.rb +90 -0
  21. data/spec/redmine/app/models/import.rb +249 -0
  22. data/spec/redmine/app/models/import_item.rb +22 -0
  23. data/spec/redmine/app/models/issue_import.rb +186 -0
  24. data/spec/redmine/app/views/attachments/image.html.erb +3 -0
  25. data/spec/redmine/app/views/attachments/other.html.erb +3 -0
  26. data/spec/redmine/app/views/common/_image.html.erb +1 -0
  27. data/spec/redmine/app/views/common/_other.html.erb +1 -0
  28. data/spec/redmine/app/views/custom_field_enumerations/create.js.erb +2 -0
  29. data/spec/redmine/app/views/custom_field_enumerations/destroy.html.erb +14 -0
  30. data/spec/redmine/app/views/custom_field_enumerations/index.html.erb +47 -0
  31. data/spec/redmine/app/views/custom_fields/formats/_enumeration.erb +12 -0
  32. data/spec/redmine/app/views/imports/_fields_mapping.html.erb +90 -0
  33. data/spec/redmine/app/views/imports/mapping.html.erb +52 -0
  34. data/spec/redmine/app/views/imports/mapping.js.erb +1 -0
  35. data/spec/redmine/app/views/imports/new.html.erb +15 -0
  36. data/spec/redmine/app/views/imports/run.html.erb +20 -0
  37. data/spec/redmine/app/views/imports/run.js.erb +11 -0
  38. data/spec/redmine/app/views/imports/settings.html.erb +30 -0
  39. data/spec/redmine/app/views/imports/show.html.erb +38 -0
  40. data/spec/redmine/app/views/layouts/_file.html.erb +15 -0
  41. data/spec/redmine/app/views/mailer/security_notification.html.erb +13 -0
  42. data/spec/redmine/app/views/mailer/security_notification.text.erb +8 -0
  43. data/spec/redmine/app/views/mailer/settings_updated.html.erb +14 -0
  44. data/spec/redmine/app/views/mailer/settings_updated.text.erb +12 -0
  45. data/spec/redmine/app/views/queries/_query_form.html.erb +62 -0
  46. data/spec/redmine/app/views/repositories/_changeset.html.erb +40 -0
  47. data/spec/redmine/app/views/search/index.api.rsb +12 -0
  48. data/spec/redmine/app/views/settings/_api.html.erb +10 -0
  49. data/spec/redmine/app/views/settings/_attachments.html.erb +21 -0
  50. data/spec/redmine/app/views/wiki/_new_modal.html.erb +21 -0
  51. data/spec/redmine/app/views/wiki/new.html.erb +17 -0
  52. data/spec/redmine/app/views/wiki/new.js.erb +2 -0
  53. data/spec/redmine/appveyor.yml +36 -0
  54. data/spec/redmine/db/migrate/20150725112753_insert_allowed_statuses_for_new_issues.rb +23 -0
  55. data/spec/redmine/db/migrate/20150730122707_create_imports.rb +13 -0
  56. data/spec/redmine/db/migrate/20150730122735_create_import_items.rb +10 -0
  57. data/spec/redmine/db/migrate/20150921204850_change_time_entries_comments_limit_to_1024.rb +9 -0
  58. data/spec/redmine/db/migrate/20150921210243_change_wiki_contents_comments_limit_to_1024.rb +11 -0
  59. data/spec/redmine/db/migrate/20151020182334_change_attachments_filesize_limit_to_8.rb +9 -0
  60. data/spec/redmine/db/migrate/20151020182731_fix_comma_in_user_format_setting_value.rb +13 -0
  61. data/spec/redmine/db/migrate/20151021184614_change_issue_categories_name_limit_to_60.rb +9 -0
  62. data/spec/redmine/db/migrate/20151021185456_change_auth_sources_filter_to_text.rb +9 -0
  63. data/spec/redmine/db/migrate/20151021190616_change_user_preferences_hide_mail_default_to_true.rb +9 -0
  64. data/spec/redmine/db/migrate/20151024082034_add_tokens_updated_on.rb +10 -0
  65. data/spec/redmine/db/migrate/20151025072118_create_custom_field_enumerations.rb +10 -0
  66. data/spec/redmine/db/migrate/20151031095005_add_projects_default_version_id.rb +12 -0
  67. data/spec/redmine/db/migrate/20160404080304_force_password_reset_during_setup.rb +9 -0
  68. data/spec/redmine/db/migrate/20160416072926_remove_position_defaults.rb +13 -0
  69. data/spec/redmine/db/migrate/20160529063352_add_roles_settings.rb +5 -0
  70. data/spec/redmine/lib/redmine/acts/positioned.rb +118 -0
  71. data/spec/redmine/lib/redmine/helpers/url.rb +35 -0
  72. data/spec/redmine/lib/redmine/hook/listener.rb +32 -0
  73. data/spec/redmine/lib/redmine/hook/view_listener.rb +78 -0
  74. data/spec/redmine/log/test.log +2 -0
  75. data/spec/redmine/plugins/dummy_plugin/Gemfile +1 -0
  76. data/spec/redmine/plugins/dummy_plugin/app/controllers/dummy_autocompletes_controller.rb +4 -0
  77. data/spec/redmine/plugins/dummy_plugin/app/views/dummy_autocompletes/index.html.erb +3 -0
  78. data/spec/redmine/plugins/dummy_plugin/config/locales/en.yml +2 -0
  79. data/spec/redmine/plugins/dummy_plugin/config/routes.rb +1 -0
  80. data/spec/redmine/plugins/dummy_plugin/init.rb +34 -0
  81. data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/easy_patch/redmine/controllers/issues_controller_patch.example +30 -0
  82. data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/easy_patch/redmine/helpers/issues_helper_patch.example +30 -0
  83. data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/easy_patch/redmine/models/issue_patch.example +30 -0
  84. data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/hooks.rb +5 -0
  85. data/spec/redmine/plugins/dummy_plugin/lib/dummy_plugin/internals.rb +4 -0
  86. data/spec/redmine/public/images/jstoolbar/bt_precode.png +0 -0
  87. data/spec/redmine/public/images/reorder.png +0 -0
  88. data/spec/redmine/public/javascripts/jquery-1.11.1-ui-1.11.0-ujs-3.1.4.js +21 -0
  89. data/spec/redmine/public/javascripts/redmine_extensions/application.js +13 -0
  90. data/spec/redmine/public/javascripts/redmine_extensions/easy_togglers.js +58 -0
  91. data/spec/redmine/public/javascripts/redmine_extensions/jquery.entityarray.js +130 -0
  92. data/spec/redmine/public/javascripts/redmine_extensions/redmine_extensions.js +642 -0
  93. data/spec/redmine/public/javascripts/responsive.js +83 -0
  94. data/spec/redmine/public/stylesheets/responsive.css +799 -0
  95. data/spec/redmine/test/fixtures/files/import_dates.csv +4 -0
  96. data/spec/redmine/test/fixtures/files/import_iso8859-1.csv +3 -0
  97. data/spec/redmine/test/fixtures/files/import_issues.csv +4 -0
  98. data/spec/redmine/test/fixtures/ldap/slapd.centos6.conf +24 -0
  99. data/spec/redmine/test/fixtures/ldap/slapd.ubuntu.12.04.conf +23 -0
  100. data/spec/redmine/test/fixtures/mail_handler/issue_update_with_cc.eml +19 -0
  101. data/spec/redmine/test/fixtures/mail_handler/ticket_on_project_given_by_to_header.eml +60 -0
  102. data/spec/redmine/test/fixtures/mail_handler/ticket_with_text_attachment_iso-8859-2.eml +31 -0
  103. data/spec/redmine/test/functional/custom_field_enumerations_controller_test.rb +115 -0
  104. data/spec/redmine/test/functional/imports_controller_test.rb +205 -0
  105. data/spec/redmine/test/functional/sessions_controller_test.rb +138 -0
  106. data/spec/redmine/test/integration/api_test/search_test.rb +92 -0
  107. data/spec/redmine/test/integration/routing/imports_test.rb +36 -0
  108. data/spec/redmine/test/integration/sessions_test.rb +97 -0
  109. data/spec/redmine/test/ui/custom_fields_test_ui.rb +38 -0
  110. data/spec/redmine/test/unit/attachment_transaction_test.rb +76 -0
  111. data/spec/redmine/test/unit/helpers/journals_helper_test.rb +48 -0
  112. data/spec/redmine/test/unit/helpers/wiki_helper_test.rb +45 -0
  113. data/spec/redmine/test/unit/issue_import_test.rb +178 -0
  114. data/spec/redmine/test/unit/lib/redmine/acts/positioned_with_scope_test.rb +53 -0
  115. data/spec/redmine/test/unit/lib/redmine/acts/positioned_without_scope_test.rb +55 -0
  116. data/spec/redmine/test/unit/lib/redmine/field_format/enumeration_format_test.rb +91 -0
  117. data/spec/support/easy_queries_helpers.rb +0 -0
  118. metadata +216 -10
@@ -0,0 +1,138 @@
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 SessionsControllerTest < Redmine::ControllerTest
21
+ include Redmine::I18n
22
+ tests WelcomeController
23
+
24
+ fixtures :users, :email_addresses
25
+
26
+ def setup
27
+ Rails.application.config.redmine_verify_sessions = true
28
+ end
29
+
30
+ def teardown
31
+ Rails.application.config.redmine_verify_sessions = false
32
+ end
33
+
34
+ def test_session_token_should_be_updated
35
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => 10.hours.ago, :updated_on => 10.hours.ago)
36
+ created = token.reload.created_on
37
+
38
+ get :index, :session => {:user_id => 2, :tk => token.value}
39
+ assert_response :success
40
+ token.reload
41
+ assert_equal created.to_i, token.created_on.to_i
42
+ assert_not_equal created.to_i, token.updated_on.to_i
43
+ assert token.updated_on > created
44
+ end
45
+
46
+ def test_user_session_should_not_be_reset_if_lifetime_and_timeout_disabled
47
+ created = 2.years.ago
48
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
49
+
50
+ with_settings :session_lifetime => '0', :session_timeout => '0' do
51
+ get :index, :session => {:user_id => 2, :tk => token.value}
52
+ assert_response :success
53
+ end
54
+ end
55
+
56
+ def test_user_session_without_token_should_be_reset
57
+ get :index, :session => {:user_id => 2}
58
+ assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
59
+ end
60
+
61
+ def test_expired_user_session_should_be_reset_if_lifetime_enabled
62
+ created = 2.days.ago
63
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
64
+
65
+ with_settings :session_timeout => '720' do
66
+ get :index, :session => {:user_id => 2, :tk => token.value}
67
+ assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
68
+ end
69
+ end
70
+
71
+ def test_valid_user_session_should_not_be_reset_if_lifetime_enabled
72
+ created = 3.hours.ago
73
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
74
+
75
+ with_settings :session_timeout => '720' do
76
+ get :index, :session => {:user_id => 2, :tk => token.value}
77
+ assert_response :success
78
+ end
79
+ end
80
+
81
+ def test_expired_user_session_should_be_reset_if_timeout_enabled
82
+ created = 4.hours.ago
83
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
84
+
85
+ with_settings :session_timeout => '60' do
86
+ get :index, :session => {:user_id => 2, :tk => token.value}
87
+ assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
88
+ end
89
+ end
90
+
91
+ def test_valid_user_session_should_not_be_reset_if_timeout_enabled
92
+ created = 10.minutes.ago
93
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
94
+
95
+ with_settings :session_timeout => '60' do
96
+ get :index, :session => {:user_id => 2, :tk => token.value}
97
+ assert_response :success
98
+ end
99
+ end
100
+
101
+ def test_expired_user_session_should_be_restarted_if_autologin
102
+ created = 2.hours.ago
103
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
104
+
105
+ with_settings :session_lifetime => '720', :session_timeout => '60', :autologin => 7 do
106
+ autologin_token = Token.create!(:user_id => 2, :action => 'autologin', :created_on => 1.day.ago)
107
+ @request.cookies['autologin'] = autologin_token.value
108
+
109
+ get :index, :session => {:user_id => 2, :tk => token.value}
110
+ assert_equal 2, session[:user_id]
111
+ assert_response :success
112
+ assert_not_equal token.value, session[:tk]
113
+ end
114
+ end
115
+
116
+ def test_expired_user_session_should_set_locale
117
+ set_language_if_valid 'it'
118
+ user = User.find(2)
119
+ user.language = 'fr'
120
+ user.save!
121
+ created = 4.hours.ago
122
+ token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
123
+
124
+ with_settings :session_timeout => '60' do
125
+ get :index, :session => {:user_id => user.id, :tk => token.value}
126
+ assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
127
+ assert_include "Veuillez vous reconnecter", flash[:error]
128
+ assert_equal :fr, current_language
129
+ end
130
+ end
131
+
132
+ def test_anonymous_session_should_not_be_reset
133
+ with_settings :session_lifetime => '720', :session_timeout => '60' do
134
+ get :index
135
+ assert_response :success
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,92 @@
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 Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base
21
+ fixtures :projects, :projects_trackers,
22
+ :enabled_modules, :roles, :users, :members, :member_roles,
23
+ :issues, :trackers, :issue_statuses, :enumerations,
24
+ :workflows,
25
+ :custom_fields, :custom_values,
26
+ :custom_fields_projects, :custom_fields_trackers,
27
+ :repositories, :changesets
28
+
29
+ test "GET /search.xml should return xml content" do
30
+ get '/search.xml'
31
+
32
+ assert_response :success
33
+ assert_equal 'application/xml', @response.content_type
34
+ end
35
+
36
+ test "GET /search.json should return json content" do
37
+ get '/search.json'
38
+
39
+ assert_response :success
40
+ assert_equal 'application/json', @response.content_type
41
+
42
+ json = ActiveSupport::JSON.decode(response.body)
43
+ assert_kind_of Hash, json
44
+ assert_kind_of Array, json['results']
45
+ end
46
+
47
+ test "GET /search.xml without query strings should return empty results" do
48
+ get '/search.xml', :q => '', :all_words => ''
49
+
50
+ assert_response :success
51
+ assert_select 'result', 0
52
+ end
53
+
54
+ test "GET /search.xml with query strings should return results" do
55
+ issue = Issue.generate!(:subject => 'searchapi')
56
+
57
+ get '/search.xml', :q => 'searchapi', :all_words => ''
58
+
59
+ assert_response :success
60
+
61
+ assert_select 'results[type=array]' do
62
+ assert_select 'result', 1
63
+
64
+ assert_select 'result' do
65
+ assert_select 'id', :text => issue.id.to_s
66
+ assert_select 'title', :text => "Bug ##{issue.id} (New): searchapi"
67
+ assert_select 'type', :text => 'issue'
68
+ assert_select 'url', :text => "http://www.example.com/issues/#{issue.id}"
69
+ assert_select 'description', :text => ''
70
+ assert_select 'datetime'
71
+ end
72
+ end
73
+ end
74
+
75
+ test "GET /search.xml should paginate" do
76
+ issue = (0..10).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse.map(&:id)
77
+
78
+ get '/search.json', :q => 'search_with_limited_results', :limit => 4
79
+ json = ActiveSupport::JSON.decode(response.body)
80
+ assert_equal 11, json['total_count']
81
+ assert_equal 0, json['offset']
82
+ assert_equal 4, json['limit']
83
+ assert_equal issue[0..3], json['results'].map {|r| r['id']}
84
+
85
+ get '/search.json', :q => 'search_with_limited_results', :offset => 8, :limit => 4
86
+ json = ActiveSupport::JSON.decode(response.body)
87
+ assert_equal 11, json['total_count']
88
+ assert_equal 8, json['offset']
89
+ assert_equal 4, json['limit']
90
+ assert_equal issue[8..10], json['results'].map {|r| r['id']}
91
+ end
92
+ end
@@ -0,0 +1,36 @@
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 RoutingImportsTest < Redmine::RoutingTest
21
+ def test_imports
22
+ should_route 'GET /issues/imports/new' => 'imports#new'
23
+ should_route 'POST /imports' => 'imports#create'
24
+
25
+ should_route 'GET /imports/4ae6bc' => 'imports#show', :id => '4ae6bc'
26
+
27
+ should_route 'GET /imports/4ae6bc/settings' => 'imports#settings', :id => '4ae6bc'
28
+ should_route 'POST /imports/4ae6bc/settings' => 'imports#settings', :id => '4ae6bc'
29
+
30
+ should_route 'GET /imports/4ae6bc/mapping' => 'imports#mapping', :id => '4ae6bc'
31
+ should_route 'POST /imports/4ae6bc/mapping' => 'imports#mapping', :id => '4ae6bc'
32
+
33
+ should_route 'GET /imports/4ae6bc/run' => 'imports#run', :id => '4ae6bc'
34
+ should_route 'POST /imports/4ae6bc/run' => 'imports#run', :id => '4ae6bc'
35
+ end
36
+ end
@@ -0,0 +1,97 @@
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 SessionsTest < Redmine::IntegrationTest
21
+ fixtures :users, :email_addresses, :roles
22
+
23
+ def setup
24
+ Rails.application.config.redmine_verify_sessions = true
25
+ end
26
+
27
+ def teardown
28
+ Rails.application.config.redmine_verify_sessions = false
29
+ end
30
+
31
+ def test_change_password_kills_sessions
32
+ log_user('jsmith', 'jsmith')
33
+
34
+ jsmith = User.find(2)
35
+ jsmith.password = "somenewpassword"
36
+ jsmith.save!
37
+
38
+ get '/my/account'
39
+ assert_response 302
40
+ assert flash[:error].match(/Your session has expired/)
41
+ end
42
+
43
+ def test_lock_user_kills_sessions
44
+ log_user('jsmith', 'jsmith')
45
+
46
+ jsmith = User.find(2)
47
+ assert jsmith.lock!
48
+ assert jsmith.activate!
49
+
50
+ get '/my/account'
51
+ assert_response 302
52
+ assert flash[:error].match(/Your session has expired/)
53
+ end
54
+
55
+ def test_update_user_does_not_kill_sessions
56
+ log_user('jsmith', 'jsmith')
57
+
58
+ jsmith = User.find(2)
59
+ jsmith.firstname = 'Robert'
60
+ jsmith.save!
61
+
62
+ get '/my/account'
63
+ assert_response 200
64
+ end
65
+
66
+ def test_change_password_generates_a_new_token_for_current_session
67
+ log_user('jsmith', 'jsmith')
68
+ assert_not_nil token = session[:tk]
69
+
70
+ get '/my/password'
71
+ assert_response 200
72
+ post '/my/password', :password => 'jsmith',
73
+ :new_password => 'secret123',
74
+ :new_password_confirmation => 'secret123'
75
+ assert_response 302
76
+ assert_not_equal token, session[:tk]
77
+
78
+ get '/my/account'
79
+ assert_response 200
80
+ end
81
+
82
+ def test_simultaneous_sessions_should_be_valid
83
+ first = open_session do |session|
84
+ session.post "/login", :username => 'jsmith', :password => 'jsmith'
85
+ end
86
+ other = open_session do |session|
87
+ session.post "/login", :username => 'jsmith', :password => 'jsmith'
88
+ end
89
+
90
+ first.get '/my/account'
91
+ assert_equal 200, first.response.response_code
92
+ first.post '/logout'
93
+
94
+ other.get '/my/account'
95
+ assert_equal 200, other.response.response_code
96
+ end
97
+ end
@@ -0,0 +1,38 @@
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('../base', __FILE__)
19
+
20
+ class Redmine::UiTest::CustomFieldsTest < Redmine::UiTest::Base
21
+ fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
22
+ :trackers, :projects_trackers, :enabled_modules,
23
+ :custom_fields, :custom_values, :custom_fields_trackers
24
+
25
+ def test_reordering_should_redirect_to_index
26
+ assert_equal 1, UserCustomField.find(4).position
27
+ log_user 'admin', 'admin'
28
+ visit '/custom_fields'
29
+
30
+ # click 'User' tab
31
+ page.first('a#tab-UserCustomField').click
32
+ # click 'Move down' link on the first row
33
+ page.first('td.reorder a:nth-child(3)').click
34
+
35
+ assert_equal "/custom_fields?tab=UserCustomField", URI.parse(current_url).request_uri
36
+ assert_equal 2, UserCustomField.find(4).position
37
+ end
38
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Redmine - project management software
4
+ # Copyright (C) 2006-2016 Jean-Philippe Lang
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; either version 2
9
+ # of the License, or (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
+
20
+ require File.expand_path('../../test_helper', __FILE__)
21
+
22
+ class AttachmentTest < ActiveSupport::TestCase
23
+ fixtures :users, :email_addresses, :projects, :roles, :members, :member_roles,
24
+ :enabled_modules, :issues, :trackers, :attachments
25
+
26
+ self.use_transactional_fixtures = false
27
+
28
+ def setup
29
+ set_tmp_attachments_directory
30
+ end
31
+
32
+ def test_rollback_after_create_should_remove_file_from_disk
33
+ diskfile = nil
34
+
35
+ Attachment.transaction do
36
+ a = Attachment.new(:container => Issue.find(1),
37
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
38
+ :author => User.find(1))
39
+ a.save!
40
+ diskfile = a.diskfile
41
+ assert File.exist?(diskfile)
42
+ raise ActiveRecord::Rollback
43
+ end
44
+ assert !File.exist?(diskfile)
45
+ end
46
+
47
+ def test_destroy_should_remove_file_from_disk_after_commit
48
+ a = Attachment.new(:container => Issue.find(1),
49
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
50
+ :author => User.find(1))
51
+ a.save!
52
+ diskfile = a.diskfile
53
+ assert File.exist?(diskfile)
54
+
55
+ Attachment.transaction do
56
+ a.destroy
57
+ assert File.exist?(diskfile)
58
+ end
59
+ assert !File.exist?(diskfile)
60
+ end
61
+
62
+ def test_rollback_after_destroy_should_not_remove_file_from_disk
63
+ a = Attachment.new(:container => Issue.find(1),
64
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
65
+ :author => User.find(1))
66
+ a.save!
67
+ diskfile = a.diskfile
68
+ assert File.exist?(diskfile)
69
+
70
+ Attachment.transaction do
71
+ a.destroy
72
+ raise ActiveRecord::Rollback
73
+ end
74
+ assert File.exist?(diskfile)
75
+ end
76
+ end