Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
87
test/application_system_test_case.rb
Normal file
87
test/application_system_test_case.rb
Normal file
|
@ -0,0 +1,87 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../test_helper', __FILE__)
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
DOWNLOADS_PATH = File.expand_path(File.join(Rails.root, 'tmp', 'downloads'))
|
||||
|
||||
driven_by :selenium, using: :chrome, screen_size: [1024, 900], options: {
|
||||
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
'chromeOptions' => {
|
||||
'prefs' => {
|
||||
'download.default_directory' => DOWNLOADS_PATH,
|
||||
'download.prompt_for_download' => false,
|
||||
'plugins.plugins_disabled' => ["Chrome PDF Viewer"]
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
setup do
|
||||
clear_downloaded_files
|
||||
Setting.delete_all
|
||||
Setting.clear_cache
|
||||
end
|
||||
|
||||
teardown do
|
||||
Setting.delete_all
|
||||
Setting.clear_cache
|
||||
end
|
||||
|
||||
# Should not depend on locale since Redmine displays login page
|
||||
# using default browser locale which depend on system locale for "real" browsers drivers
|
||||
def log_user(login, password)
|
||||
visit '/my/page'
|
||||
assert_equal '/login', current_path
|
||||
within('#login-form form') do
|
||||
fill_in 'username', :with => login
|
||||
fill_in 'password', :with => password
|
||||
find('input[name=login]').click
|
||||
end
|
||||
assert_equal '/my/page', current_path
|
||||
end
|
||||
|
||||
def clear_downloaded_files
|
||||
# https://github.com/SeleniumHQ/selenium/issues/5292
|
||||
FileUtils.rm downloaded_files if Redmine::Platform.mswin?
|
||||
end
|
||||
|
||||
def downloaded_files(filename='*')
|
||||
# https://github.com/SeleniumHQ/selenium/issues/5292
|
||||
downloaded_path = Redmine::Platform.mswin? ? DOWNLOADS_PATH : "#{ENV['HOME']}/Downloads"
|
||||
Dir.glob("#{downloaded_path}/#{filename}").
|
||||
reject{|f| f=~/\.(tmp|crdownload)$/}.sort_by{|f| File.mtime(f)}
|
||||
end
|
||||
|
||||
# Returns the path of the download file
|
||||
def downloaded_file(filename='*')
|
||||
files = []
|
||||
Timeout.timeout(5) do
|
||||
loop do
|
||||
files = downloaded_files(filename)
|
||||
break if files.present?
|
||||
sleep 0.2
|
||||
end
|
||||
end
|
||||
files.last
|
||||
end
|
||||
end
|
||||
|
||||
FileUtils.mkdir_p ApplicationSystemTestCase::DOWNLOADS_PATH
|
0
test/controllers/empty
Normal file
0
test/controllers/empty
Normal file
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -28,7 +30,7 @@ module Redmine
|
|||
end
|
||||
result.source_files.each do |source_file|
|
||||
File.open(File.join(output_path, source_file_result(source_file)), "w") do |file|
|
||||
file.puts template('source').result(binding)
|
||||
file.puts template('source').result(binding).force_encoding('utf-8')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,9 +9,10 @@ h1 {color:#777; margin-bottom:0.2em;}
|
|||
h2 {color:#aaa;margin-top:1em;font-size:18px;}
|
||||
table {width:100%; border-collapse:collapse;}
|
||||
th, td {border:1px solid #e2e2e2;}
|
||||
td {text-align:right; font-family:"Bitstream Vera Sans Mono","Monaco","Courier New",monospace;}
|
||||
td.filename {text-align:left; font-family:"Lucida Grande","Lucida Sans",Verdana,Helvetica,Arial,sans-serif;}
|
||||
td {text-align:right; white-space: nowrap; font-family:"Bitstream Vera Sans Mono","Monaco","Courier New",monospace;}
|
||||
td.filename {text-align:left; white-space: normal; font-family:"Lucida Grande","Lucida Sans",Verdana,Helvetica,Arial,sans-serif;}
|
||||
th {background:#e2e2e2;}
|
||||
table.file_list tr:hover { background-color:#ffffdd; }
|
||||
#generation {color:#777; font-size:90%;}
|
||||
a, a:link, a:visited {color:#169; text-decoration:none;}
|
||||
a:hover, a:active {color:#c61a1a; text-decoration:underline;}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: false
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: false
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: false
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -23,7 +25,7 @@ module RedminePmTest
|
|||
|
||||
# Cannot use transactional fixtures here: database
|
||||
# will be accessed from Redmine.pm with its own connection
|
||||
self.use_transactional_fixtures = false
|
||||
self.use_transactional_tests = false
|
||||
|
||||
def test_dummy
|
||||
end
|
||||
|
|
75
test/fixtures/attachments.yml
vendored
75
test/fixtures/attachments.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
attachments_001:
|
||||
---
|
||||
attachments_001:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
downloads: 0
|
||||
content_type: text/plain
|
||||
|
@ -13,7 +13,7 @@ attachments_001:
|
|||
filename: error281.txt
|
||||
author_id: 2
|
||||
description: An attachment
|
||||
attachments_002:
|
||||
attachments_002:
|
||||
created_on: 2007-01-27 15:08:27 +01:00
|
||||
downloads: 0
|
||||
content_type: text/plain
|
||||
|
@ -26,7 +26,7 @@ attachments_002:
|
|||
filesize: 28
|
||||
filename: document.txt
|
||||
author_id: 2
|
||||
attachments_003:
|
||||
attachments_003:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
downloads: 0
|
||||
content_type: image/gif
|
||||
|
@ -40,7 +40,7 @@ attachments_003:
|
|||
filename: logo.gif
|
||||
description: This is a logo
|
||||
author_id: 2
|
||||
attachments_004:
|
||||
attachments_004:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
container_id: 2
|
||||
|
@ -54,7 +54,7 @@ attachments_004:
|
|||
author_id: 2
|
||||
description: This is a Ruby source file
|
||||
content_type: application/x-ruby
|
||||
attachments_005:
|
||||
attachments_005:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
container_id: 3
|
||||
|
@ -67,7 +67,7 @@ attachments_005:
|
|||
filename: changeset_iso8859-1.diff
|
||||
author_id: 2
|
||||
content_type: text/x-diff
|
||||
attachments_006:
|
||||
attachments_006:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
container_id: 3
|
||||
|
@ -80,7 +80,7 @@ attachments_006:
|
|||
filename: archive.zip
|
||||
author_id: 2
|
||||
content_type: application/zip
|
||||
attachments_007:
|
||||
attachments_007:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
container_id: 4
|
||||
|
@ -93,7 +93,7 @@ attachments_007:
|
|||
filename: archive.zip
|
||||
author_id: 1
|
||||
content_type: application/zip
|
||||
attachments_008:
|
||||
attachments_008:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Project
|
||||
container_id: 1
|
||||
|
@ -106,7 +106,7 @@ attachments_008:
|
|||
filename: project_file.zip
|
||||
author_id: 2
|
||||
content_type: application/octet-stream
|
||||
attachments_009:
|
||||
attachments_009:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Version
|
||||
container_id: 1
|
||||
|
@ -119,7 +119,7 @@ attachments_009:
|
|||
filename: version_file.zip
|
||||
author_id: 2
|
||||
content_type: application/octet-stream
|
||||
attachments_010:
|
||||
attachments_010:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
container_id: 2
|
||||
|
@ -132,7 +132,7 @@ attachments_010:
|
|||
filename: picture.jpg
|
||||
author_id: 2
|
||||
content_type: image/jpeg
|
||||
attachments_011:
|
||||
attachments_011:
|
||||
created_on: 2007-02-12 15:08:27 +01:00
|
||||
container_type: Document
|
||||
container_id: 1
|
||||
|
@ -171,7 +171,7 @@ attachments_013:
|
|||
filename: foo.zip
|
||||
author_id: 2
|
||||
content_type: application/octet-stream
|
||||
attachments_014:
|
||||
attachments_014:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
container_id: 3
|
||||
|
@ -184,7 +184,7 @@ attachments_014:
|
|||
filename: changeset_utf8.diff
|
||||
author_id: 2
|
||||
content_type: text/x-diff
|
||||
attachments_015:
|
||||
attachments_015:
|
||||
id: 15
|
||||
created_on: 2010-07-19 21:07:27 +02:00
|
||||
container_type: Issue
|
||||
|
@ -198,7 +198,7 @@ attachments_015:
|
|||
author_id: 2
|
||||
content_type: text/x-diff
|
||||
description: attachement of a private issue
|
||||
attachments_016:
|
||||
attachments_016:
|
||||
content_type: image/png
|
||||
downloads: 0
|
||||
created_on: 2010-11-23 16:14:50 +09:00
|
||||
|
@ -212,7 +212,7 @@ attachments_016:
|
|||
filename: testfile.png
|
||||
filesize: 2654
|
||||
author_id: 2
|
||||
attachments_017:
|
||||
attachments_017:
|
||||
content_type: image/png
|
||||
downloads: 0
|
||||
created_on: 2010-12-23 16:14:50 +09:00
|
||||
|
@ -254,7 +254,7 @@ attachments_019:
|
|||
filename: Testテスト.PNG
|
||||
filesize: 3582
|
||||
author_id: 2
|
||||
attachments_020:
|
||||
attachments_020:
|
||||
content_type: text/plain
|
||||
downloads: 0
|
||||
created_on: 2012-05-12 16:14:50 +09:00
|
||||
|
@ -268,3 +268,44 @@ attachments_020:
|
|||
filename: root_attachment.txt
|
||||
filesize: 54
|
||||
author_id: 2
|
||||
attachments_021:
|
||||
created_on: 2007-03-05 15:08:27 +01:00
|
||||
container_type: Document
|
||||
container_id: 3
|
||||
downloads: 0
|
||||
disk_filename: 060719210727_archive.zip
|
||||
disk_directory: "2006/07"
|
||||
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
|
||||
id: 21
|
||||
filesize: 157
|
||||
filename: archive.zip
|
||||
author_id: 1
|
||||
content_type: application/zip
|
||||
attachments_022:
|
||||
created_on: 2019-04-30 09:23:44 +09:00
|
||||
container_type: Project
|
||||
container_id: 1
|
||||
downloads: 0
|
||||
disk_filename: 190430092344_redmine_logo.ai.unknown
|
||||
disk_directory: "2019/04"
|
||||
digest: 68d90c016f0806d88234a6f16530fdf0b7f1d2481354798f1a5fd165dca6b04f
|
||||
id: 22
|
||||
filesize: 4994
|
||||
filename: redmine_logo.ai.unknown
|
||||
author_id: 1
|
||||
description: unknown type
|
||||
content_type:
|
||||
attachments_023:
|
||||
created_on: 2019-05-11 14:18:19 +09:00
|
||||
content_type: application/pdf
|
||||
container_type: WikiPage
|
||||
container_id: 1
|
||||
downloads: 0
|
||||
disk_filename: 190511141819_ecookbook-gantt.pdf
|
||||
disk_directory: "2019/05"
|
||||
digest: da9c52e79d9eee7d47b9ee5db477985c542ea683e9f23ed32db55e35ef99c479
|
||||
id: 23
|
||||
filesize: 31620
|
||||
filename: ecookbook-gantt.pdf
|
||||
author_id: 2
|
||||
description: Gantt chart as of May 11
|
||||
|
|
4
test/fixtures/comments.yml
vendored
4
test/fixtures/comments.yml
vendored
|
@ -4,7 +4,7 @@ comments_001:
|
|||
commented_id: 1
|
||||
id: 1
|
||||
author_id: 1
|
||||
comments: my first comment
|
||||
content: my first comment
|
||||
created_on: 2006-12-10 18:10:10 +01:00
|
||||
updated_on: 2006-12-10 18:10:10 +01:00
|
||||
comments_002:
|
||||
|
@ -12,6 +12,6 @@ comments_002:
|
|||
commented_id: 1
|
||||
id: 2
|
||||
author_id: 2
|
||||
comments: This is an other comment
|
||||
content: This is an other comment
|
||||
created_on: 2006-12-10 18:12:10 +01:00
|
||||
updated_on: 2006-12-10 18:12:10 +01:00
|
||||
|
|
8
test/fixtures/configuration/default.yml
vendored
8
test/fixtures/configuration/default.yml
vendored
|
@ -1,8 +0,0 @@
|
|||
default:
|
||||
somesetting: foo
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
7
test/fixtures/configuration/empty.yml
vendored
7
test/fixtures/configuration/empty.yml
vendored
|
@ -1,7 +0,0 @@
|
|||
default:
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
8
test/fixtures/configuration/no_default.yml
vendored
8
test/fixtures/configuration/no_default.yml
vendored
|
@ -1,8 +0,0 @@
|
|||
default:
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
||||
somesetting: foo
|
9
test/fixtures/configuration/overrides.yml
vendored
9
test/fixtures/configuration/overrides.yml
vendored
|
@ -1,9 +0,0 @@
|
|||
default:
|
||||
somesetting: foo
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
||||
somesetting: bar
|
11
test/fixtures/documents.yml
vendored
11
test/fixtures/documents.yml
vendored
|
@ -1,14 +1,21 @@
|
|||
documents_001:
|
||||
documents_001:
|
||||
created_on: 2007-01-27 15:08:27 +01:00
|
||||
project_id: 1
|
||||
title: "Test document"
|
||||
id: 1
|
||||
description: "Document description"
|
||||
category_id: 1
|
||||
documents_002:
|
||||
documents_002:
|
||||
created_on: 2007-02-12 15:08:27 +01:00
|
||||
project_id: 1
|
||||
title: "An other document"
|
||||
id: 2
|
||||
description: ""
|
||||
category_id: 1
|
||||
documents_003:
|
||||
created_on: 2007-03-05 15:08:27 +01:00
|
||||
project_id: 1
|
||||
title: "An other document 2"
|
||||
id: 3
|
||||
description: ""
|
||||
category_id: 3
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# The Greeter class
|
||||
class Greeter
|
||||
def initialize(name)
|
||||
|
|
232
test/fixtures/files/2019/04/190430092344_redmine_logo.ai.unknown
vendored
Normal file
232
test/fixtures/files/2019/04/190430092344_redmine_logo.ai.unknown
vendored
Normal file
|
@ -0,0 +1,232 @@
|
|||
%!PS-Adobe-3.0
|
||||
%%Creator: Adobe Fireworks
|
||||
%%DocumentNeededResources: procset Adobe_level2_AI5 1.0 0
|
||||
%%+ procset Adobe_packedarray 2.0 0
|
||||
%%+ procset Adobe_cmykcolor 1.1 0
|
||||
%%+ procset Adobe_cshow 1.1 0
|
||||
%%+ procset Adobe_customcolor 1.0 0
|
||||
%%+ procset Adobe_typography_AI5 1.0 0
|
||||
%%+ procset Adobe_Illustrator_AI5 1.0 0
|
||||
%%BoundingBox:0 0 183 94
|
||||
%AI3_TemplateBox: 0 0 183 94
|
||||
%%PageOrigin:0 0
|
||||
%AI5_FileFormat 3
|
||||
%AI3_ColorUsage: Color
|
||||
%%DocumentProcessColors: Cyan Magenta Yellow Black
|
||||
%%EndComments
|
||||
%%BeginProlog
|
||||
%%EndProlog
|
||||
%%BeginSetup
|
||||
Adobe_packedarray /initialize get exec
|
||||
Adobe_cmykcolor /initialize get exec
|
||||
Adobe_cshow /initialize get exec
|
||||
Adobe_customcolor /initialize get exec
|
||||
Adobe_typography_AI5 /initialize get exec
|
||||
Adobe_Illustrator_AI5 /initialize get exec
|
||||
[
|
||||
39/quotesingle 96/grave 130/quotesinglbase 131/florin 132/quotedblbase
|
||||
133/ellipsis 134/dagger 135/daggerdbl 136/circumflex 137/perthousand
|
||||
139/guilsinglleft 140/OE 145/quoteleft 146/quoteright 147/quotedblleft
|
||||
148/quotedblright 149/bullet 150/endash 151/emdash 152/tilde
|
||||
155/guilsinglright 156/oe 157/dotlessi 159/Ydieresis 164/currency
|
||||
166/brokenbar 168/dieresis 169/copyright 170/ordfeminine 172/logicalnot
|
||||
174/registered 175/macron 176/ring 177/plusminus 178/twosuperior
|
||||
179/threesuperior 180/acute 181/mu 183/periodcentered 184/cedilla
|
||||
185/onesuperior 186/ordmasculine 188/onequarter 189/onehalf
|
||||
190/threequarters 192/Agrave 193/Aacute 194/Acircumflex 195/Atilde
|
||||
196/Adieresis 197/Aring 198/AE 199/Ccedilla 200/Egrave 201/Eacute
|
||||
202/Ecircumflex 203/Edieresis 204/Igrave 205/Iacute 206/Icircumflex
|
||||
207/Idieresis 208/Eth 209/Ntilde 210/Ograve 211/Oacute 212/Ocircumflex
|
||||
213/Otilde 214/Odieresis 215/multiply 216/Oslash 217/Ugrave 218/Uacute
|
||||
219/Ucircumflex 220/Udieresis 221/Yacute 222/Thorn 223/germandbls
|
||||
224/agrave 225/aacute 226/acircumflex 227/atilde 228/adieresis
|
||||
229/aring 230/ae 231/ccedilla 232/egrave 233/eacute 234/ecircumflex
|
||||
235/edieresis 236/igrave 237/iacute 238/icircumflex 239/idieresis
|
||||
240/eth 241/ntilde 242/ograve 243/oacute 244/ocircumflex 245/otilde
|
||||
246/odieresis 247/divide 248/oslash 249/ugrave 250/uacute 251/ucircumflex
|
||||
252/udieresis 253/yacute 254/thorn 255/ydieresis
|
||||
TE
|
||||
%AI3_BeginEncoding: _Delicious-Bold-Bold Delicious-Bold-Bold
|
||||
[/_Delicious-Bold-Bold/Delicious-Bold-Bold 0 0 0 TZ
|
||||
%AI3_EndEncoding TrueType
|
||||
%%EndSetup
|
||||
1 1 1 1 0 0 0 79 128 255 Lb
|
||||
(Ebene 1) Ln
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
44.00 44.80 m
|
||||
49.60 44.80 l
|
||||
50.00 49.60 l
|
||||
44.80 50.80 l
|
||||
44.00 44.80 l
|
||||
f
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
45.00 51.60 m
|
||||
50.00 50.40 l
|
||||
51.20 54.60 l
|
||||
47.00 56.80 l
|
||||
45.00 51.60 l
|
||||
f
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
47.40 57.60 m
|
||||
51.40 55.40 l
|
||||
54.60 57.60 l
|
||||
51.60 61.00 l
|
||||
47.40 57.60 l
|
||||
f
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
69.80 44.80 m
|
||||
64.20 44.80 l
|
||||
63.80 49.60 l
|
||||
69.00 50.80 l
|
||||
69.80 44.80 l
|
||||
f
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
68.80 51.60 m
|
||||
63.80 50.40 l
|
||||
62.60 54.60 l
|
||||
66.80 56.80 l
|
||||
68.80 51.60 l
|
||||
f
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
66.40 57.60 m
|
||||
62.40 55.40 l
|
||||
59.20 57.60 l
|
||||
62.20 61.00 l
|
||||
66.40 57.60 l
|
||||
f
|
||||
0.000 0.000 0.000 Xa
|
||||
1 XR
|
||||
52.60 61.60 m
|
||||
55.60 58.00 l
|
||||
58.40 58.00 l
|
||||
61.00 61.60 l
|
||||
58.40 62.40 l
|
||||
55.53 62.40 l
|
||||
52.60 61.60 l
|
||||
f
|
||||
1 To
|
||||
1 0 0 1 74 43 0.000000 Tp
|
||||
74.80 43.20 m
|
||||
141.58 43.20 l
|
||||
141.58 34.56 l
|
||||
74.80 34.56 l
|
||||
74.80 43.20 l
|
||||
n
|
||||
TP
|
||||
0 -14.00 Td
|
||||
0.200 0.200 0.200 Xa
|
||||
/_Delicious-Bold-Bold 14.00 Tf
|
||||
0.000000 Ts
|
||||
100.000000 100.0 Tz
|
||||
1 0 Tk
|
||||
0.000000 Tt
|
||||
0 Ta
|
||||
0.200 0.200 0.200 Xa
|
||||
0 Tr
|
||||
(Flexible Project Management) Tj
|
||||
TO
|
||||
1 To
|
||||
1 0 0 1 74 60 0.000000 Tp
|
||||
74.00 60.00 m
|
||||
139.29 60.00 l
|
||||
139.29 36.48 l
|
||||
74.00 36.48 l
|
||||
74.00 60.00 l
|
||||
n
|
||||
TP
|
||||
0 -45.00 Td
|
||||
0.604 0.027 0.000 Xa
|
||||
/_Delicious-Bold-Bold 45.00 Tf
|
||||
0.000000 Ts
|
||||
100.000000 100.0 Tz
|
||||
1 0 Tk
|
||||
0.000000 Tt
|
||||
0 Ta
|
||||
0.604 0.027 0.000 Xa
|
||||
0 Tr
|
||||
(RED) Tj
|
||||
/_Delicious-Bold-Bold 45.00 Tf
|
||||
0.000000 Ts
|
||||
100.000000 100.0 Tz
|
||||
1 0 Tk
|
||||
0.000000 Tt
|
||||
0 Ta
|
||||
0.753 0.106 0.102 Xa
|
||||
0 Tr
|
||||
(MINE) Tj
|
||||
TO
|
||||
0.604 0.027 0.000 Xa
|
||||
1 XR
|
||||
44.00 44.80 m
|
||||
49.60 44.80 l
|
||||
50.00 49.60 l
|
||||
44.80 50.80 l
|
||||
44.00 44.80 l
|
||||
f
|
||||
0.706 0.055 0.059 Xa
|
||||
1 XR
|
||||
45.00 51.60 m
|
||||
50.00 50.40 l
|
||||
51.20 54.60 l
|
||||
47.00 56.80 l
|
||||
45.00 51.60 l
|
||||
f
|
||||
0.753 0.106 0.102 Xa
|
||||
1 XR
|
||||
47.40 57.60 m
|
||||
51.40 55.40 l
|
||||
54.60 57.60 l
|
||||
51.60 61.00 l
|
||||
47.40 57.60 l
|
||||
f
|
||||
0.604 0.027 0.000 Xa
|
||||
1 XR
|
||||
69.80 44.80 m
|
||||
64.20 44.80 l
|
||||
63.80 49.60 l
|
||||
69.00 50.80 l
|
||||
69.80 44.80 l
|
||||
f
|
||||
0.706 0.055 0.059 Xa
|
||||
1 XR
|
||||
68.80 51.60 m
|
||||
63.80 50.40 l
|
||||
62.60 54.60 l
|
||||
66.80 56.80 l
|
||||
68.80 51.60 l
|
||||
f
|
||||
0.753 0.106 0.102 Xa
|
||||
1 XR
|
||||
66.40 57.60 m
|
||||
62.40 55.40 l
|
||||
59.20 57.60 l
|
||||
62.20 61.00 l
|
||||
66.40 57.60 l
|
||||
f
|
||||
0.753 0.106 0.102 Xa
|
||||
1 XR
|
||||
52.60 61.60 m
|
||||
55.60 58.00 l
|
||||
58.40 58.00 l
|
||||
61.00 61.60 l
|
||||
58.40 62.40 l
|
||||
55.53 62.40 l
|
||||
52.60 61.60 l
|
||||
f
|
||||
LB
|
||||
%%PageTrailer
|
||||
gsave annotatepage grestore showpage
|
||||
%%Trailer
|
||||
Adobe_Illustrator_AI5 /terminate get exec
|
||||
Adobe_typography_AI5 /terminate get exec
|
||||
Adobe_customcolor /terminate get exec
|
||||
Adobe_cshow /terminate get exec
|
||||
Adobe_cmykcolor /terminate get exec
|
||||
Adobe_packedarray /terminate get exec
|
||||
%%EOF
|
BIN
test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf
vendored
Normal file
BIN
test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf
vendored
Normal file
Binary file not shown.
1
test/fixtures/files/hello.js
vendored
Normal file
1
test/fixtures/files/hello.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
document.write('Hello, World!');
|
2
test/fixtures/files/import_dates_ja.csv
vendored
Normal file
2
test/fixtures/files/import_dates_ja.csv
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
subject;start
|
||||
Date in %Y/%m/%d format;2019/05/28;
|
|
8
test/fixtures/files/import_issues.csv
vendored
8
test/fixtures/files/import_issues.csv
vendored
|
@ -1,4 +1,4 @@
|
|||
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker;status
|
||||
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug;new
|
||||
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request;new
|
||||
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug;assigned
|
||||
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker;status;multicustom
|
||||
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug;new;"PostgreSQL, Oracle"
|
||||
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request;new;MySQL
|
||||
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug;assigned;
|
||||
|
|
|
5
test/fixtures/files/import_subtasks_with_unique_id.csv
vendored
Normal file
5
test/fixtures/files/import_subtasks_with_unique_id.csv
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
id;tracker;subject;parent
|
||||
RED-I;bug;Root;
|
||||
RED-II;bug;Child 1;RED-I
|
||||
RED-III;bug;Grand-child;RED-IV
|
||||
RED-IV;bug;Child 2;RED-I
|
|
5
test/fixtures/files/import_time_entries.csv
vendored
Normal file
5
test/fixtures/files/import_time_entries.csv
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
row;issue_id;date;hours;comment;activity;overtime;user_id
|
||||
1;;2020-01-01;1;Some Design;Design;yes;jsmith@somenet.foo
|
||||
2;;2020-01-02;2;Some Development;Development;yes;jsmith@somenet.foo
|
||||
3;1;2020-01-03;3;Some QA;QA;no;dlopper@somenet.foo
|
||||
4;2;2020-01-04;4;Some Inactivity;Inactive Activity;no;jsmith@somenet.foo
|
|
3
test/fixtures/files/testfile.md
vendored
Normal file
3
test/fixtures/files/testfile.md
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Header 1
|
||||
## Header 2
|
||||
### Header 3
|
5
test/fixtures/files/testfile.textile
vendored
Normal file
5
test/fixtures/files/testfile.textile
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
h1. Header 1
|
||||
|
||||
h2. Header 2
|
||||
|
||||
h3. Header 3
|
4
test/fixtures/issues.yml
vendored
4
test/fixtures/issues.yml
vendored
|
@ -15,6 +15,7 @@ issues_001:
|
|||
status_id: 1
|
||||
start_date: <%= 1.day.ago.to_date.to_s(:db) %>
|
||||
due_date: <%= 10.day.from_now.to_date.to_s(:db) %>
|
||||
estimated_hours: 200.0
|
||||
root_id: 1
|
||||
lft: 1
|
||||
rgt: 2
|
||||
|
@ -35,6 +36,7 @@ issues_002:
|
|||
status_id: 2
|
||||
start_date: <%= 2.day.ago.to_date.to_s(:db) %>
|
||||
due_date:
|
||||
estimated_hours: 0.5
|
||||
root_id: 2
|
||||
lft: 1
|
||||
rgt: 2
|
||||
|
@ -56,6 +58,7 @@ issues_003:
|
|||
status_id: 1
|
||||
start_date: <%= 15.day.ago.to_date.to_s(:db) %>
|
||||
due_date: <%= 5.day.ago.to_date.to_s(:db) %>
|
||||
estimated_hours: 1.0
|
||||
root_id: 3
|
||||
lft: 1
|
||||
rgt: 2
|
||||
|
@ -90,6 +93,7 @@ issues_005:
|
|||
assigned_to_id:
|
||||
author_id: 2
|
||||
status_id: 1
|
||||
estimated_hours: 2.0
|
||||
root_id: 5
|
||||
lft: 1
|
||||
rgt: 2
|
||||
|
|
38
test/fixtures/mail_handler/different_contents_in_text_and_html.eml
vendored
Normal file
38
test/fixtures/mail_handler/different_contents_in_text_and_html.eml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
From JSmith@somenet.foo Sun Mar 02 23:30:00 2019
|
||||
From: John Smith <JSmith@somenet.foo>
|
||||
Content-Type: multipart/mixed; boundary="Apple-Mail=_33C8180A-B097-4B87-A925-441300BDB9C9"
|
||||
Message-Id: <BB533668-3CC8-41CA-A951-0A5D8EA37FB0@somenet.foo>
|
||||
Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\))
|
||||
Subject: Different contents in text part and HTML part
|
||||
Date: Sun, 03 Mar 2019 08:30:00 +0900
|
||||
To: redmine@somenet.foo
|
||||
X-Mailer: Apple Mail (2.1503)
|
||||
|
||||
|
||||
|
||||
--Apple-Mail=_33C8180A-B097-4B87-A925-441300BDB9C9
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Type: text/plain;
|
||||
charset=us-ascii
|
||||
|
||||
The text part.
|
||||
|
||||
|
||||
--Apple-Mail=_33C8180A-B097-4B87-A925-441300BDB9C9
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Type: text/html;
|
||||
charset=us-ascii
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww=
|
||||
w.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns=3D"http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<p>The html part.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
--Apple-Mail=_33C8180A-B097-4B87-A925-441300BDB9C9--
|
8
test/fixtures/mail_handler/fullname_of_sender_in_parentheses.eml
vendored
Normal file
8
test/fixtures/mail_handler/fullname_of_sender_in_parentheses.eml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
Return-Path: <jdoe@example.net>
|
||||
From: jdoe@example.net (John Doe)
|
||||
To: <redmine@example.net>
|
||||
Subject: Name in parentheses
|
||||
Date: Sun, 03 Mar 2019 21:23:00 +0900
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
|
||||
The author's full name is enclosed in parentheses.
|
9
test/fixtures/mail_handler/subject_japanese_3.eml
vendored
Normal file
9
test/fixtures/mail_handler/subject_japanese_3.eml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
From: John Smith <JSmith@somenet.foo>
|
||||
To: "redmine@somenet.foo" <redmine@somenet.foo>
|
||||
Subject: =?iso-2022-jp?B?GyRCLSEbKEIgGyRCNF0/dDt6JUYlOSVIGyhC?=
|
||||
Date: Mon, 27 Aug 2018 09:30:00 +0900
|
||||
Message-ID: <87C31D42249DD0489D1A1444E3232DD7019D6183@foo.bar>
|
||||
|
||||
The subject contains a "CIRCLED DIGIT ONE" character (U+2460).
|
||||
It is undefined in ISO-2022-JP but defined in some vendor-extended
|
||||
variants such as ISO-2022-JP-MS.
|
|
@ -5,6 +5,7 @@ Received: from osiris ([127.0.0.1])
|
|||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "John Doe" <john.doe@somenet.foo>
|
||||
To: <redmine@somenet.foo>
|
||||
Cc: <dlopper@somenet.foo>
|
||||
Subject: Ticket by unknown user
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
|
|
|
@ -38,6 +38,7 @@ Assigned to: John Smith
|
|||
fixed version: alpha
|
||||
estimated hours: 2.5
|
||||
done ratio: 30
|
||||
parent issue: 4
|
||||
|
||||
--- This line starts with a delimiter and should not be stripped
|
||||
|
||||
|
|
41
test/fixtures/mail_handler/ticket_with_localized_private_flag.eml
vendored
Normal file
41
test/fixtures/mail_handler/ticket_with_localized_private_flag.eml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
Return-Path: <jsmith@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "John Smith" <jsmith@somenet.foo>
|
||||
To: <redmine@somenet.foo>
|
||||
Subject: New ticket on a given project
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
platea dictumst.
|
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
|
||||
Projet: onlinestore
|
||||
Privée: oui
|
1
test/fixtures/plugins/other_plugin/_other_plugin_settings.html.erb
vendored
Normal file
1
test/fixtures/plugins/other_plugin/_other_plugin_settings.html.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<p><label>Example setting</label><%= text_field_tag 'settings[sample_setting]', @settings['sample_setting'] %></p>
|
3
test/fixtures/projects_trackers.yml
vendored
3
test/fixtures/projects_trackers.yml
vendored
|
@ -44,3 +44,6 @@ projects_trackers_014:
|
|||
projects_trackers_015:
|
||||
project_id: 6
|
||||
tracker_id: 1
|
||||
projects_trackers_016:
|
||||
project_id: 3
|
||||
tracker_id: 1
|
||||
|
|
BIN
test/fixtures/repositories/darcs_repository.tar.gz
vendored
BIN
test/fixtures/repositories/darcs_repository.tar.gz
vendored
Binary file not shown.
BIN
test/fixtures/repositories/git_repository.tar.gz
vendored
BIN
test/fixtures/repositories/git_repository.tar.gz
vendored
Binary file not shown.
25
test/fixtures/roles.yml
vendored
25
test/fixtures/roles.yml
vendored
|
@ -1,12 +1,12 @@
|
|||
---
|
||||
roles_001:
|
||||
---
|
||||
roles_001:
|
||||
name: Manager
|
||||
id: 1
|
||||
builtin: 0
|
||||
issues_visibility: all
|
||||
users_visibility: all
|
||||
permissions: |
|
||||
---
|
||||
---
|
||||
- :add_project
|
||||
- :edit_project
|
||||
- :close_project
|
||||
|
@ -36,6 +36,7 @@ roles_001:
|
|||
- :view_time_entries
|
||||
- :edit_time_entries
|
||||
- :delete_time_entries
|
||||
- :import_time_entries
|
||||
- :view_news
|
||||
- :manage_news
|
||||
- :comment_news
|
||||
|
@ -51,6 +52,7 @@ roles_001:
|
|||
- :protect_wiki_pages
|
||||
- :delete_wiki_pages
|
||||
- :rename_wiki_pages
|
||||
- :manage_wiki
|
||||
- :view_messages
|
||||
- :add_messages
|
||||
- :edit_messages
|
||||
|
@ -66,14 +68,14 @@ roles_001:
|
|||
- :import_issues
|
||||
|
||||
position: 1
|
||||
roles_002:
|
||||
roles_002:
|
||||
name: Developer
|
||||
id: 2
|
||||
builtin: 0
|
||||
issues_visibility: default
|
||||
users_visibility: all
|
||||
permissions: |
|
||||
---
|
||||
---
|
||||
- :edit_project
|
||||
- :manage_members
|
||||
- :manage_versions
|
||||
|
@ -116,14 +118,14 @@ roles_002:
|
|||
- :view_changesets
|
||||
|
||||
position: 2
|
||||
roles_003:
|
||||
roles_003:
|
||||
name: Reporter
|
||||
id: 3
|
||||
builtin: 0
|
||||
issues_visibility: default
|
||||
users_visibility: all
|
||||
permissions: |
|
||||
---
|
||||
---
|
||||
- :edit_project
|
||||
- :manage_members
|
||||
- :manage_versions
|
||||
|
@ -159,14 +161,14 @@ roles_003:
|
|||
- :view_changesets
|
||||
|
||||
position: 3
|
||||
roles_004:
|
||||
roles_004:
|
||||
name: Non member
|
||||
id: 4
|
||||
builtin: 1
|
||||
issues_visibility: default
|
||||
users_visibility: all
|
||||
permissions: |
|
||||
---
|
||||
---
|
||||
- :view_issues
|
||||
- :add_issues
|
||||
- :edit_issues
|
||||
|
@ -191,14 +193,14 @@ roles_004:
|
|||
- :view_changesets
|
||||
|
||||
position: 1
|
||||
roles_005:
|
||||
roles_005:
|
||||
name: Anonymous
|
||||
id: 5
|
||||
builtin: 2
|
||||
issues_visibility: default
|
||||
users_visibility: all
|
||||
permissions: |
|
||||
---
|
||||
---
|
||||
- :view_issues
|
||||
- :add_issue_notes
|
||||
- :view_gantt
|
||||
|
@ -214,4 +216,3 @@ roles_005:
|
|||
- :view_changesets
|
||||
|
||||
position: 1
|
||||
|
||||
|
|
23
test/fixtures/time_entries.yml
vendored
23
test/fixtures/time_entries.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
time_entries_001:
|
||||
---
|
||||
time_entries_001:
|
||||
created_on: 2007-03-23 12:54:18 +01:00
|
||||
tweek: 12
|
||||
tmonth: 3
|
||||
|
@ -12,8 +12,9 @@ time_entries_001:
|
|||
id: 1
|
||||
hours: 4.25
|
||||
user_id: 2
|
||||
author_id: 2
|
||||
tyear: 2007
|
||||
time_entries_002:
|
||||
time_entries_002:
|
||||
created_on: 2007-03-23 14:11:04 +01:00
|
||||
tweek: 11
|
||||
tmonth: 3
|
||||
|
@ -26,8 +27,9 @@ time_entries_002:
|
|||
id: 2
|
||||
hours: 150.0
|
||||
user_id: 1
|
||||
author_id: 1
|
||||
tyear: 2007
|
||||
time_entries_003:
|
||||
time_entries_003:
|
||||
created_on: 2007-04-21 12:20:48 +02:00
|
||||
tweek: 16
|
||||
tmonth: 4
|
||||
|
@ -40,8 +42,9 @@ time_entries_003:
|
|||
id: 3
|
||||
hours: 1.0
|
||||
user_id: 1
|
||||
author_id: 1
|
||||
tyear: 2007
|
||||
time_entries_004:
|
||||
time_entries_004:
|
||||
created_on: 2007-04-22 12:20:48 +02:00
|
||||
tweek: 16
|
||||
tmonth: 4
|
||||
|
@ -50,12 +53,13 @@ time_entries_004:
|
|||
updated_on: 2007-04-22 12:20:48 +02:00
|
||||
activity_id: 10
|
||||
spent_on: 2007-04-22
|
||||
issue_id:
|
||||
issue_id:
|
||||
id: 4
|
||||
hours: 7.65
|
||||
user_id: 1
|
||||
author_id: 1
|
||||
tyear: 2007
|
||||
time_entries_005:
|
||||
time_entries_005:
|
||||
created_on: 2011-03-22 12:20:48 +02:00
|
||||
tweek: 12
|
||||
tmonth: 3
|
||||
|
@ -64,9 +68,10 @@ time_entries_005:
|
|||
updated_on: 2011-03-22 12:20:48 +02:00
|
||||
activity_id: 10
|
||||
spent_on: 2011-03-22
|
||||
issue_id:
|
||||
issue_id:
|
||||
id: 5
|
||||
hours: 7.65
|
||||
user_id: 1
|
||||
author_id: 1
|
||||
tyear: 2011
|
||||
|
||||
|
||||
|
|
2
test/fixtures/trackers.yml
vendored
2
test/fixtures/trackers.yml
vendored
|
@ -5,12 +5,14 @@ trackers_001:
|
|||
is_in_chlog: true
|
||||
default_status_id: 1
|
||||
position: 1
|
||||
description: Description for Bug tracker
|
||||
trackers_002:
|
||||
name: Feature request
|
||||
id: 2
|
||||
is_in_chlog: true
|
||||
default_status_id: 1
|
||||
position: 2
|
||||
description: Description for Feature request tracker
|
||||
trackers_003:
|
||||
name: Support request
|
||||
id: 3
|
||||
|
|
35
test/fixtures/user_preferences.yml
vendored
35
test/fixtures/user_preferences.yml
vendored
|
@ -1,41 +1,42 @@
|
|||
---
|
||||
user_preferences_001:
|
||||
---
|
||||
user_preferences_001:
|
||||
others: |
|
||||
---
|
||||
---
|
||||
:no_self_notified: false
|
||||
:my_page_layout:
|
||||
left:
|
||||
:my_page_layout:
|
||||
left:
|
||||
- latestnews
|
||||
- documents
|
||||
right:
|
||||
right:
|
||||
- issuesassignedtome
|
||||
top:
|
||||
top:
|
||||
- calendar
|
||||
:bookmarked_project_ids: "1,5"
|
||||
|
||||
id: 1
|
||||
user_id: 1
|
||||
hide_mail: true
|
||||
user_preferences_002:
|
||||
user_preferences_002:
|
||||
others: |
|
||||
---
|
||||
---
|
||||
:no_self_notified: false
|
||||
|
||||
|
||||
id: 2
|
||||
user_id: 2
|
||||
hide_mail: true
|
||||
user_preferences_003:
|
||||
user_preferences_003:
|
||||
others: |
|
||||
---
|
||||
---
|
||||
:no_self_notified: false
|
||||
:my_page_layout:
|
||||
left:
|
||||
:my_page_layout:
|
||||
left:
|
||||
- latestnews
|
||||
- documents
|
||||
right:
|
||||
right:
|
||||
- issuesassignedtome
|
||||
top:
|
||||
top:
|
||||
- calendar
|
||||
|
||||
|
||||
id: 3
|
||||
user_id: 3
|
||||
hide_mail: false
|
||||
|
|
1
test/fixtures/versions.yml
vendored
1
test/fixtures/versions.yml
vendored
|
@ -19,6 +19,7 @@ versions_002:
|
|||
effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>
|
||||
status: locked
|
||||
sharing: 'none'
|
||||
wiki_page_title: ECookBookV1
|
||||
versions_003:
|
||||
created_on: 2006-07-19 21:00:33 +02:00
|
||||
name: "2.0"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -168,7 +170,7 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||
:lastname => 'User',
|
||||
:mail => 'user@somedomain.com',
|
||||
:identity_url => 'http://openid.example.com/good_blank_user'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -310,7 +312,7 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/my/account'
|
||||
|
@ -324,7 +326,7 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||
assert user.active?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_post_register_with_registration_off_should_redirect
|
||||
with_settings :self_registration => '0' do
|
||||
assert_no_difference 'User.count' do
|
||||
|
@ -336,7 +338,7 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/'
|
||||
|
@ -355,11 +357,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:pref => {
|
||||
:hide_mail => '1'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -28,7 +30,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||
:enabled_modules,
|
||||
:journals, :journal_details
|
||||
|
||||
|
||||
def test_project_index
|
||||
get :index, :params => {
|
||||
:id => 1,
|
||||
|
@ -48,13 +49,14 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_previous_project_index
|
||||
@request.session[:user_id] = 1
|
||||
get :index, :params => {
|
||||
:id => 1,
|
||||
:from => 2.days.ago.to_date
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
|
||||
assert_select 'h3', :text => /#{User.current.time_to_date(3.days.ago).day}/
|
||||
assert_select 'dl dt.issue a', :text => /Cannot print recipes/
|
||||
end
|
||||
|
||||
|
@ -141,7 +143,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||
:show_issues => '1'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
|
||||
assert_select 'title', :text => /Issues/
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -73,7 +75,7 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||
|
||||
def test_load_default_configuration_data_should_rescue_error
|
||||
delete_configuration_data
|
||||
Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
|
||||
Redmine::DefaultData::Loader.stubs(:load).raises(StandardError.new("Something went wrong"))
|
||||
post :default_configuration, :params => {
|
||||
:lang => 'fr'
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_test_email_failure_should_display_the_error
|
||||
Mailer.stubs(:test_email).raises(Exception, 'Some error message')
|
||||
Mailer.stubs(:test_email).raises(StandardError, 'Some error message')
|
||||
post :test_email
|
||||
assert_redirected_to '/settings?tab=notifications'
|
||||
assert_match /Some error message/, flash[:error]
|
||||
|
@ -119,8 +121,10 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||
description 'This is a test plugin'
|
||||
version '0.0.1'
|
||||
settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
|
||||
directory 'test/fixtures/plugins/foo_plugin'
|
||||
end
|
||||
Redmine::Plugin.register :bar do
|
||||
Redmine::Plugin.register :other do
|
||||
directory 'test/fixtures/plugins/other_plugin'
|
||||
end
|
||||
|
||||
get :plugins
|
||||
|
@ -130,8 +134,8 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||
assert_select 'td span.name', :text => 'Foo plugin'
|
||||
assert_select 'td.configure a[href="/settings/plugin/foo"]'
|
||||
end
|
||||
assert_select 'tr#plugin-bar' do
|
||||
assert_select 'td span.name', :text => 'Bar'
|
||||
assert_select 'tr#plugin-other' do
|
||||
assert_select 'td span.name', :text => 'Other'
|
||||
assert_select 'td.configure a', 0
|
||||
end
|
||||
end
|
||||
|
|
27
test/functional/application_controller_test.rb
Normal file
27
test/functional/application_controller_test.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2020 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ApplicationControllerTest < Redmine::ControllerTest
|
||||
def test_back_url_should_remove_utf8_checkmark_from_referer
|
||||
@request.set_header 'HTTP_REFERER', "/path?utf8=\u2713&foo=bar"
|
||||
assert_equal "/path?foo=bar", @controller.back_url
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
# encoding: utf-8
|
||||
#
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -46,7 +46,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
|
||||
assert_select 'td.line-code', :text => /Demande créée avec succès/
|
||||
end
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_diff_replace_cannot_convert_content
|
||||
|
@ -64,7 +63,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'td.line-code', :text => /Demande cr\?\?e avec succ\?s/
|
||||
end
|
||||
end
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_diff_latin_1
|
||||
|
@ -82,7 +80,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'td.line-code', :text => /Demande créée avec succès/
|
||||
end
|
||||
end
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_should_save_diff_type_as_user_preference
|
||||
|
@ -132,7 +129,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_text_file_utf_8
|
||||
|
@ -143,8 +139,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert a.save
|
||||
assert_equal 'japanese-utf-8.txt', a.filename
|
||||
|
||||
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||||
|
||||
get :show, :params => {
|
||||
:id => a.id
|
||||
}
|
||||
|
@ -152,7 +146,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'tr#L1' do
|
||||
assert_select 'th.line-num', :text => '1'
|
||||
assert_select 'td', :text => /#{str_japanese}/
|
||||
assert_select 'td', :text => /日本語/
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -209,7 +203,38 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'text/html', @response.content_type
|
||||
assert_select '.nodata', :text => 'No preview available. Download the file instead.'
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_text_file_formated_markdown
|
||||
set_tmp_attachments_directory
|
||||
a = Attachment.new(:container => Issue.find(1),
|
||||
:file => uploaded_test_file('testfile.md', 'text/plain'),
|
||||
:author => User.find(1))
|
||||
assert a.save
|
||||
assert_equal 'testfile.md', a.filename
|
||||
|
||||
get :show, :params => {
|
||||
:id => a.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'div.wiki', :html => "<h1>Header 1</h1>\n\n<h2>Header 2</h2>\n\n<h3>Header 3</h3>"
|
||||
end
|
||||
|
||||
def test_show_text_file_fromated_textile
|
||||
set_tmp_attachments_directory
|
||||
a = Attachment.new(:container => Issue.find(1),
|
||||
:file => uploaded_test_file('testfile.textile', 'text/plain'),
|
||||
:author => User.find(1))
|
||||
assert a.save
|
||||
assert_equal 'testfile.textile', a.filename
|
||||
|
||||
get :show, :params => {
|
||||
:id => a.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'div.wiki', :html => "<h1>Header 1</h1>\n\n\n\t<h2>Header 2</h2>\n\n\n\t<h3>Header 3</h3>"
|
||||
end
|
||||
|
||||
def test_show_image
|
||||
|
@ -229,7 +254,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select '.nodata', :text => 'No preview available. Download the file instead.'
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_file_from_private_issue_without_permission
|
||||
|
@ -237,7 +261,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
:id => 15
|
||||
}
|
||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F15'
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_file_from_private_issue_with_permission
|
||||
|
@ -247,7 +270,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /private.diff/
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_file_without_container_should_be_allowed_to_author
|
||||
|
@ -287,6 +309,14 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_response 404
|
||||
end
|
||||
|
||||
def test_show_renders_pagination
|
||||
get :show, :params => { :id => 5, :type => 'inline' }
|
||||
assert_response :success
|
||||
|
||||
assert_select 'ul.pages li.next', :text => /next/i
|
||||
assert_select 'ul.pages li.previous', :text => /previous/i
|
||||
end
|
||||
|
||||
def test_download_text_file
|
||||
get :download, :params => {
|
||||
:id => 4
|
||||
|
@ -301,8 +331,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
:id => 4
|
||||
}
|
||||
assert_response 304
|
||||
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_download_js_file
|
||||
|
@ -336,7 +364,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/x-ruby', @response.content_type
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_download_should_assign_better_content_type_than_application_octet_stream
|
||||
|
@ -347,7 +374,15 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/x-ruby', @response.content_type
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_download_should_assign_application_octet_stream_if_content_type_is_not_determined
|
||||
get :download, :params => {
|
||||
:id => 22
|
||||
}
|
||||
assert_response :success
|
||||
assert_nil Redmine::MimeType.of(attachments(:attachments_022).filename)
|
||||
assert_equal 'application/octet-stream', @response.content_type
|
||||
end
|
||||
|
||||
def test_download_missing_file
|
||||
|
@ -355,7 +390,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
:id => 2
|
||||
}
|
||||
assert_response 404
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_download_should_be_denied_without_permission
|
||||
|
@ -363,7 +397,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
:id => 7
|
||||
}
|
||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7'
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
if convert_installed?
|
||||
|
@ -397,7 +430,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_thumbnail_should_round_size
|
||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 250}
|
||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 300}
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :thumbnail, :params => {
|
||||
|
@ -435,6 +468,22 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
puts '(ImageMagick convert not available)'
|
||||
end
|
||||
|
||||
if gs_installed?
|
||||
def test_thumbnail_for_pdf_should_be_png
|
||||
skip unless convert_installed?
|
||||
|
||||
Attachment.clear_thumbnails
|
||||
@request.session[:user_id] = 2
|
||||
get :thumbnail, :params => {
|
||||
:id => 23 # ecookbook-gantt.pdf
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'image/png', response.content_type
|
||||
end
|
||||
else
|
||||
puts '(GhostScript convert not available)'
|
||||
end
|
||||
|
||||
def test_edit_all
|
||||
@request.session[:user_id] = 2
|
||||
get :edit_all, :params => {
|
||||
|
@ -453,6 +502,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'input[name=?][value=?]', 'attachments[4][description]', 'This is a Ruby source file'
|
||||
end
|
||||
end
|
||||
|
||||
# Link to the container in heading
|
||||
assert_select 'h2 a', :text => "Feature request #2"
|
||||
end
|
||||
|
||||
def test_edit_all_with_invalid_container_class_should_return_404
|
||||
|
@ -488,12 +540,12 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
'1' => {
|
||||
:filename => 'newname.text',
|
||||
:description => ''
|
||||
},
|
||||
},
|
||||
'4' => {
|
||||
:filename => 'newname.rb',
|
||||
:description => 'Renamed'
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,12 +564,12 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||
'1' => {
|
||||
:filename => '',
|
||||
:description => ''
|
||||
},
|
||||
},
|
||||
'4' => {
|
||||
:filename => 'newname.rb',
|
||||
:description => 'Renamed'
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# encoding: utf-8
|
||||
#
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -23,9 +23,11 @@ class AttachmentsVisibilityTest < Redmine::ControllerTest
|
|||
tests AttachmentsController
|
||||
fixtures :users, :email_addresses, :projects, :roles, :members, :member_roles,
|
||||
:enabled_modules, :projects_trackers, :issue_statuses, :enumerations,
|
||||
:issues, :trackers, :versions
|
||||
:issues, :trackers, :versions,
|
||||
:custom_fields, :custom_fields_trackers, :custom_fields_projects
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_tmp_attachments_directory
|
||||
|
||||
@field = IssueCustomField.generate!(:field_format => 'attachment', :visible => true)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -159,6 +161,7 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/auth_sources'
|
||||
assert_equal 'This authentication mode is in use and cannot be deleted.', flash[:error]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -174,7 +177,7 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_test_connection_with_failure
|
||||
AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError.new("Something went wrong"))
|
||||
AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error.new("Something went wrong"))
|
||||
|
||||
get :test_connection, :params => {
|
||||
:id => 1
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -148,4 +150,20 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
assert_include 'application/json', response.headers['Content-Type']
|
||||
end
|
||||
|
||||
def test_auto_complete_without_term_should_return_last_10_issues
|
||||
# There are 9 issues generated by fixtures
|
||||
# and we need two more to test the 10 limit
|
||||
%w(1..2).each do
|
||||
Issue.generate!
|
||||
end
|
||||
|
||||
get :issues
|
||||
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
assert_equal 10, json.count
|
||||
assert_equal Issue.last.id, json.first['id'].to_i
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -30,13 +32,38 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
|||
:issue_relations,
|
||||
:issue_categories,
|
||||
:enumerations,
|
||||
:queries
|
||||
:queries,
|
||||
:users, :email_addresses
|
||||
|
||||
def test_show
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
# Ensure that an issue to which a user is assigned is in the current
|
||||
# month's calendar in order to test Gravatar
|
||||
travel_to issues(:issues_002).start_date
|
||||
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
# query form
|
||||
assert_select 'form#query_form' do
|
||||
assert_select 'div#query_form_with_buttons.hide-when-print' do
|
||||
assert_select 'div#query_form_content' do
|
||||
assert_select 'fieldset#filters.collapsible'
|
||||
end
|
||||
assert_select 'p.contextual'
|
||||
assert_select 'p.buttons'
|
||||
end
|
||||
end
|
||||
|
||||
# Assert context menu on issues
|
||||
assert_select 'form[data-cm-url=?]', '/issues/context_menu'
|
||||
assert_select 'div.issue.hascontextmenu.tooltip' do
|
||||
assert_select 'input[name=?][type=?]', 'ids[]', 'checkbox'
|
||||
assert_select 'img[class="gravatar"]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_should_run_custom_queries
|
||||
|
@ -109,8 +136,24 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
|||
get :show, :params => {
|
||||
:query_id => 6
|
||||
}
|
||||
|
||||
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => 'Open issues grouped by tracker'
|
||||
end
|
||||
|
||||
def test_show_calendar_day_css_classes
|
||||
get :show, :params => {
|
||||
:month => '12',
|
||||
:year => '2016'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'tr:nth-child(2)' do
|
||||
assert_select 'td.week-number', :text => '49'
|
||||
# non working days should have "nwday" CSS class
|
||||
assert_select 'td.nwday', 2
|
||||
assert_select 'td.nwday', :text => '4'
|
||||
assert_select 'td.nwday', :text => '10'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -29,7 +31,7 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||
post :create, :params => {
|
||||
:id => 1,
|
||||
:comment => {
|
||||
:comments => 'This is a test comment'
|
||||
:comments => 'This is a test comment'
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/news/1'
|
||||
|
@ -46,7 +48,7 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||
post :create, :params => {
|
||||
:id => 1,
|
||||
:comment => {
|
||||
:comments => ''
|
||||
:comments => ''
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
|
@ -61,7 +63,7 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||
post :create, :params => {
|
||||
:id => 1,
|
||||
:comment => {
|
||||
:comments => 'This is a test comment'
|
||||
:comments => 'This is a test comment'
|
||||
}
|
||||
}
|
||||
assert_response 403
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -31,7 +33,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||
:issues, :issue_statuses, :issue_categories,
|
||||
:users,
|
||||
:enumerations,
|
||||
:time_entries
|
||||
:time_entries,
|
||||
:custom_fields, :custom_fields_trackers, :custom_fields_projects
|
||||
|
||||
def test_context_menu_one_issue
|
||||
@request.session[:user_id] = 2
|
||||
|
@ -187,7 +190,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||
assert_select "li.cf_#{field.id}" do
|
||||
assert_select 'a[href="#"]', :text => 'User'
|
||||
assert_select 'ul' do
|
||||
assert_select 'a', Project.find(1).members.count + 1
|
||||
assert_select 'a', Project.find(1).members.count + 2 # users + 'none' + 'me'
|
||||
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith'
|
||||
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
|
||||
end
|
||||
|
@ -316,7 +319,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||
def test_time_entries_context_menu_without_edit_permission
|
||||
@request.session[:user_id] = 2
|
||||
Role.find_by_name('Manager').remove_permission! :edit_time_entries
|
||||
|
||||
|
||||
get :time_entries, :params => {
|
||||
:ids => [1, 2]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -45,7 +47,7 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||
post :create, :params => {
|
||||
:custom_field_id => @field.id,
|
||||
:custom_field_enumeration => {
|
||||
:name => 'Baz'
|
||||
:name => 'Baz'
|
||||
}
|
||||
}
|
||||
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
||||
|
@ -63,7 +65,7 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||
post :create, :params => {
|
||||
:custom_field_id => @field.id,
|
||||
:custom_field_enumeration => {
|
||||
:name => 'Baz'
|
||||
:name => 'Baz'
|
||||
}
|
||||
},
|
||||
:xhr => true
|
||||
|
@ -79,13 +81,13 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||
:position => "1",
|
||||
:name => "Baz",
|
||||
:active => "1"
|
||||
},
|
||||
},
|
||||
@foo.id.to_s => {
|
||||
:position => "2",
|
||||
:name => "Foo",
|
||||
:active => "0"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -93,12 +95,77 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'option[value=user]', :text => 'User'
|
||||
assert_select 'option[value=version]', :text => 'Version'
|
||||
end
|
||||
|
||||
# Visibility
|
||||
assert_select 'input[type=radio][name=?]', 'custom_field[visible]', 2
|
||||
assert_select 'input[type=checkbox][name=?]', 'custom_field[role_ids][]', 3
|
||||
|
||||
assert_select 'input[type=checkbox][name=?]', 'custom_field[project_ids][]', Project.count
|
||||
assert_select 'input[type=hidden][name=?]', 'custom_field[project_ids][]', 1
|
||||
assert_select 'input[type=hidden][name=type][value=IssueCustomField]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_time_entry_custom_field
|
||||
get :new, :params => {
|
||||
:type => 'TimeEntryCustomField'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form#custom_field_form' do
|
||||
assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' do
|
||||
assert_select 'option[value=user]', :text => 'User'
|
||||
assert_select 'option[value=version]', :text => 'Version'
|
||||
end
|
||||
|
||||
# Visibility
|
||||
assert_select 'input[type=radio][name=?]', 'custom_field[visible]', 2
|
||||
assert_select 'input[type=checkbox][name=?]', 'custom_field[role_ids][]', 3
|
||||
|
||||
assert_select 'input[type=hidden][name=type][value=TimeEntryCustomField]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_project_custom_field
|
||||
get :new, :params => {
|
||||
:type => 'ProjectCustomField'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form#custom_field_form' do
|
||||
assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' do
|
||||
assert_select 'option[value=user]', :text => 'User'
|
||||
assert_select 'option[value=version]', :text => 'Version'
|
||||
end
|
||||
|
||||
# Visibility
|
||||
assert_select 'input[type=radio][name=?]', 'custom_field[visible]', 2
|
||||
assert_select 'input[type=checkbox][name=?]', 'custom_field[role_ids][]', 3
|
||||
|
||||
assert_select 'input[type=hidden][name=type][value=ProjectCustomField]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_version_custom_field
|
||||
get :new, :params => {
|
||||
:type => 'VersionCustomField'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form#custom_field_form' do
|
||||
assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' do
|
||||
assert_select 'option[value=user]', :text => 'User'
|
||||
assert_select 'option[value=version]', :text => 'Version'
|
||||
end
|
||||
|
||||
# Visibility
|
||||
assert_select 'input[type=radio][name=?]', 'custom_field[visible]', 2
|
||||
assert_select 'input[type=checkbox][name=?]', 'custom_field[role_ids][]', 3
|
||||
|
||||
assert_select 'input[type=hidden][name=type][value=VersionCustomField]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_time_entry_custom_field_should_not_show_trackers_and_projects
|
||||
get :new, :params => {
|
||||
:type => 'TimeEntryCustomField'
|
||||
|
@ -191,7 +258,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||
:type => 'IssueCustomField',
|
||||
:custom_field => {
|
||||
:field_format => 'list'
|
||||
},
|
||||
},
|
||||
:format => 'js'
|
||||
},
|
||||
:xhr => true
|
||||
|
@ -245,7 +312,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||
:field_format => "string",
|
||||
:is_for_all => "0",
|
||||
:project_ids => ["1", "3", ""]
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
@ -254,6 +321,20 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||
assert_equal [1, 3], field.projects.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_create_with_continue_params
|
||||
assert_difference 'CustomField.count' do
|
||||
post :create, :params => {
|
||||
:type => 'IssueCustomField',
|
||||
:continue => 'Create and Continue',
|
||||
:custom_field => {
|
||||
:name => 'foo',
|
||||
:field_format => 'string'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/custom_fields/new?type=IssueCustomField'
|
||||
end
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'CustomField.count' do
|
||||
post :create, :params => {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -20,7 +22,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class DocumentsControllerTest < Redmine::ControllerTest
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
:enabled_modules, :documents, :enumerations,
|
||||
:groups_users, :attachments
|
||||
:groups_users, :attachments, :user_preferences
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
|
@ -29,7 +31,7 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
|||
def test_index
|
||||
# Sets a default category
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
e.update(:is_default => true)
|
||||
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook'
|
||||
|
@ -45,13 +47,32 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_index_grouped_by_category
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:sort_by => 'category'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '#content' do
|
||||
# ascending order of DocumentCategory#id.
|
||||
['Uncategorized', 'Technical documentation'].each_with_index do |text,idx|
|
||||
assert_select "h3:nth-of-type(#{idx + 1})", :text => text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_grouped_by_date
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:sort_by => 'date'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h3', :text => '2007-02-12'
|
||||
assert_select '#content' do
|
||||
# descending order of date.
|
||||
['2007-03-05', '2007-02-12'].each_with_index do |text,idx|
|
||||
assert_select "h3:nth-of-type(#{idx + 1})", :text => text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_grouped_by_title
|
||||
|
@ -60,7 +81,12 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
|||
:sort_by => 'title'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h3', :text => 'T'
|
||||
assert_select '#content' do
|
||||
# ascending order of title.
|
||||
['A', 'T'].each_with_index do |text,idx|
|
||||
assert_select "h3:nth-of-type(#{idx + 1})", :text => text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_grouped_by_author
|
||||
|
@ -69,23 +95,26 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
|||
:sort_by => 'author'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h3', :text => 'John Smith'
|
||||
assert_select '#content' do
|
||||
# ascending order of author.
|
||||
['John Smith', 'Redmine Admin'].each_with_index do |text,idx|
|
||||
assert_select "h3:nth-of-type(#{idx + 1})", :text => text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_with_long_description
|
||||
# adds a long description to the first document
|
||||
doc = documents(:documents_001)
|
||||
doc.update_attributes(:description => <<LOREM)
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut egestas, mi vehicula varius varius, ipsum massa fermentum orci, eget tristique ante sem vel mi. Nulla facilisi. Donec enim libero, luctus ac sagittis sit amet, vehicula sagittis magna. Duis ultrices molestie ante, eget scelerisque sem iaculis vitae. Etiam fermentum mauris vitae metus pharetra condimentum fermentum est pretium. Proin sollicitudin elementum quam quis pharetra. Aenean facilisis nunc quis elit volutpat mollis. Aenean eleifend varius euismod. Ut dolor est, congue eget dapibus eget, elementum eu odio. Integer et lectus neque, nec scelerisque nisi. EndOfLineHere
|
||||
|
||||
Vestibulum non velit mi. Aliquam scelerisque libero ut nulla fringilla a sollicitudin magna rhoncus. Praesent a nunc lorem, ac porttitor eros. Sed ac diam nec neque interdum adipiscing quis quis justo. Donec arcu nunc, fringilla eu dictum at, venenatis ac sem. Vestibulum quis elit urna, ac mattis sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
LOREM
|
||||
doc.update(:description => <<~LOREM)
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut egestas, mi vehicula varius varius, ipsum massa fermentum orci, eget tristique ante sem vel mi. Nulla facilisi. Donec enim libero, luctus ac sagittis sit amet, vehicula sagittis magna. Duis ultrices molestie ante, eget scelerisque sem iaculis vitae. Etiam fermentum mauris vitae metus pharetra condimentum fermentum est pretium. Proin sollicitudin elementum quam quis pharetra. Aenean facilisis nunc quis elit volutpat mollis. Aenean eleifend varius euismod. Ut dolor est, congue eget dapibus eget, elementum eu odio. Integer et lectus neque, nec scelerisque nisi. EndOfLineHere
|
||||
|
||||
Vestibulum non velit mi. Aliquam scelerisque libero ut nulla fringilla a sollicitudin magna rhoncus. Praesent a nunc lorem, ac porttitor eros. Sed ac diam nec neque interdum adipiscing quis quis justo. Donec arcu nunc, fringilla eu dictum at, venenatis ac sem. Vestibulum quis elit urna, ac mattis sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
LOREM
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# should only truncate on new lines to avoid breaking wiki formatting
|
||||
assert_select '.wiki p', :text => (doc.description.split("\n").first + '...')
|
||||
assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere..."))
|
||||
|
@ -118,10 +147,10 @@ LOREM
|
|||
:title => 'DocumentsControllerTest#test_post_new',
|
||||
:description => 'This is a new document',
|
||||
:category_id => 2
|
||||
},
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -132,7 +161,7 @@ LOREM
|
|||
assert_equal Enumeration.find(2), document.category
|
||||
assert_equal 1, document.attachments.size
|
||||
assert_equal 'testfile.txt', document.attachments.first.filename
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
assert_equal 2, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
def test_create_with_failure
|
||||
|
@ -152,14 +181,14 @@ LOREM
|
|||
def test_create_non_default_category
|
||||
@request.session[:user_id] = 2
|
||||
category2 = Enumeration.find_by_name('User documentation')
|
||||
category2.update_attributes(:is_default => true)
|
||||
category2.update(:is_default => true)
|
||||
category1 = Enumeration.find_by_name('Uncategorized')
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:document => {
|
||||
:title => 'no default',
|
||||
:description => 'This is a new document',
|
||||
:category_id => category1.id
|
||||
:category_id => category1.id
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/documents'
|
||||
|
@ -203,6 +232,7 @@ LOREM
|
|||
end
|
||||
|
||||
def test_destroy
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Document.count', -1 do
|
||||
delete :destroy, :params => {
|
||||
|
@ -214,13 +244,14 @@ LOREM
|
|||
end
|
||||
|
||||
def test_add_attachment
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count' do
|
||||
post :add_attachment, :params => {
|
||||
:id => 1,
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -185,7 +187,6 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||
assert [mail.bcc, mail.cc].flatten.include?('another@somenet.foo')
|
||||
end
|
||||
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -82,6 +84,21 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||
assert_equal "sample", Enumeration.find_by(:name => 'Sample').custom_field_values.last.value
|
||||
end
|
||||
|
||||
def test_create_with_multiple_select_list_custom_fields
|
||||
custom_field = IssuePriorityCustomField.generate!(:field_format => 'list', :multiple => true, :possible_values => ['1', '2', '3', '4'])
|
||||
assert_difference 'IssuePriority.count' do
|
||||
post :create, :params => {
|
||||
:enumeration => {
|
||||
:type => 'IssuePriority',
|
||||
:name => 'Sample',
|
||||
:custom_field_values => {custom_field.id.to_s => ['1', '2']}
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/enumerations'
|
||||
assert_equal ['1', '2'].sort, Enumeration.find_by(:name => 'Sample').custom_field_values.last.value.sort
|
||||
end
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'IssuePriority.count' do
|
||||
post :create, :params => {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -82,7 +84,7 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||
:version_id => '',
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
|
@ -109,7 +111,7 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||
:version_id => '2',
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -25,16 +27,42 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||
:member_roles,
|
||||
:members,
|
||||
:enabled_modules,
|
||||
:versions
|
||||
:versions,
|
||||
:email_addresses
|
||||
|
||||
def test_gantt_should_work
|
||||
i2 = Issue.find(2)
|
||||
i2.update_attribute(:due_date, 1.month.from_now)
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
# query form
|
||||
assert_select 'form#query_form' do
|
||||
assert_select 'div#query_form_with_buttons.hide-when-print' do
|
||||
assert_select 'div#query_form_content' do
|
||||
assert_select 'fieldset#filters.collapsible'
|
||||
assert_select 'fieldset#options'
|
||||
end
|
||||
assert_select 'p.contextual' do
|
||||
prev_month, next_month = User.current.today.prev_month, User.current.today.next_month
|
||||
assert_select 'a[accesskey="p"][href=?]', project_gantt_path(:project_id => 1, :month => prev_month.month, :year => prev_month.year)
|
||||
assert_select 'a[accesskey="n"][href=?]', project_gantt_path(:project_id => 1, :month => next_month.month, :year => next_month.year)
|
||||
end
|
||||
assert_select 'p.buttons'
|
||||
end
|
||||
end
|
||||
|
||||
# Assert context menu on issues subject and gantt bar
|
||||
assert_select 'div[class=?]', 'issue-subject hascontextmenu'
|
||||
assert_select 'div.tooltip.hascontextmenu' do
|
||||
assert_select 'img[class="gravatar"]'
|
||||
end
|
||||
assert_select "form[data-cm-url=?]", '/issues/context_menu'
|
||||
|
||||
# Issue with start and due dates
|
||||
i = Issue.find(1)
|
||||
assert_not_nil i.due_date
|
||||
|
@ -127,7 +155,7 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||
assert @response.body.starts_with?('%PDF')
|
||||
end
|
||||
|
||||
if Object.const_defined?(:Magick)
|
||||
if Object.const_defined?(:MiniMagick)
|
||||
def test_gantt_should_export_to_png
|
||||
get :show, :params => {
|
||||
:project_id => 1,
|
||||
|
@ -137,4 +165,28 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'image/png', @response.content_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_gantt_should_respect_gantt_months_limit_setting
|
||||
with_settings :gantt_months_limit => '40' do
|
||||
# `months` parameter can be less than or equal to
|
||||
# `Setting.gantt_months_limit`
|
||||
get :show, :params => {
|
||||
:project_id => 1,
|
||||
:zoom => 4,
|
||||
:months => 40
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'div.gantt_hdr>a', :text => /^[\d-]+$/, :count => 40
|
||||
|
||||
# Displays 6 months (the default value for `months`) if `months` exceeds
|
||||
# gant_months_limit
|
||||
get :show, :params => {
|
||||
:project_id => 1,
|
||||
:zoom => 4,
|
||||
:months => 41
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'div.gantt_hdr>a', :text => /^[\d-]+$/, :count => 6
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -54,6 +56,20 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_show_should_display_custom_fields
|
||||
GroupCustomField.generate!(name: 'field_visible', visible: true)
|
||||
Group.find(10).update(custom_field_values: {GroupCustomField.last.id => 'value_visible'})
|
||||
GroupCustomField.generate!(name: 'field_invisible', visible: false)
|
||||
Group.find(10).update(custom_field_values: {GroupCustomField.last.id => 'value_invisible'})
|
||||
get :show, :params => {:id => 10}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'li', :text => /field_visible/
|
||||
assert_select 'li', :text => /value_visible/
|
||||
assert_select 'li', :text => /field_invisible/, :count => 0
|
||||
assert_select 'li', :text => /value_invisible/, :count => 0
|
||||
end
|
||||
|
||||
def test_show_invalid_should_return_404
|
||||
get :show, :params => {
|
||||
:id => 99
|
||||
|
@ -86,7 +102,7 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||
post :create, :params => {
|
||||
:group => {
|
||||
:name => 'New group'
|
||||
},
|
||||
},
|
||||
:continue => 'Create and continue'
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -19,7 +21,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
|
||||
class ImportsControllerTest < Redmine::ControllerTest
|
||||
fixtures :projects, :enabled_modules,
|
||||
:users, :email_addresses,
|
||||
:users, :email_addresses, :user_preferences,
|
||||
:roles, :members, :member_roles,
|
||||
:issues, :issue_statuses,
|
||||
:trackers, :projects_trackers,
|
||||
|
@ -42,14 +44,16 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_new_should_display_the_upload_form
|
||||
get :new
|
||||
get :new, :params => { :type => 'IssueImport', :project_id => 'subproject1' }
|
||||
assert_response :success
|
||||
assert_select 'input[name=?]', 'file'
|
||||
assert_select 'input[name=?][type=?][value=?]', 'project_id', 'hidden', 'subproject1'
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -172,7 +176,7 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||
:mapping => {
|
||||
:project_id => '1',
|
||||
:tracker_id => '2',
|
||||
:subject => '0'}
|
||||
:subject => '0'}
|
||||
}
|
||||
}
|
||||
assert_redirected_to "/imports/#{import.to_param}/run"
|
||||
|
@ -183,7 +187,42 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||
assert_equal '2', mapping['tracker_id']
|
||||
assert_equal '0', mapping['subject']
|
||||
end
|
||||
|
||||
|
||||
def test_get_mapping_time_entry
|
||||
Role.find(1).add_permission! :log_time_for_other_users
|
||||
import = generate_time_entry_import
|
||||
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
|
||||
import.save!
|
||||
|
||||
get :mapping, :params => {
|
||||
:id => import.to_param
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
# 'user_id' field should be available because User#2 has both
|
||||
# 'import_time_entries' and 'log_time_for_other_users' permissions
|
||||
assert_select 'select[name=?]', 'import_settings[mapping][user_id]' do
|
||||
# Current user should be the default value
|
||||
assert_select 'option[value="value:2"][selected]', :text => User.find(2).name
|
||||
assert_select 'option[value="value:3"]', :text => User.find(3).name
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_mapping_time_entry_for_user_without_log_time_for_other_users_permission
|
||||
import = generate_time_entry_import
|
||||
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
|
||||
import.save!
|
||||
|
||||
get :mapping, :params => {
|
||||
:id => import.to_param
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'import_settings[mapping][user_id]', 0
|
||||
end
|
||||
|
||||
def test_get_run
|
||||
import = generate_import_with_mapping
|
||||
|
||||
|
@ -193,7 +232,7 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
assert_select '#import-progress'
|
||||
end
|
||||
|
||||
|
||||
def test_post_run_should_import_the_file
|
||||
import = generate_import_with_mapping
|
||||
|
||||
|
@ -234,6 +273,44 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||
assert_equal ["Child of existing issue", "Child 1", "First"], issues.map(&:subject)
|
||||
end
|
||||
|
||||
def test_post_run_with_notifications
|
||||
import = generate_import
|
||||
|
||||
post :settings, :params => {
|
||||
:id => import,
|
||||
:import_settings => {
|
||||
:separator => ';',
|
||||
:wrapper => '"',
|
||||
:encoding => 'ISO-8859-1',
|
||||
:notifications => '1',
|
||||
:mapping => {
|
||||
:project_id => '1',
|
||||
:tracker => '13',
|
||||
:subject => '1',
|
||||
:assigned_to => '11',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ActionMailer::Base.deliveries.clear
|
||||
assert_difference 'Issue.count', 3 do
|
||||
post :run, :params => {
|
||||
:id => import,
|
||||
}
|
||||
assert_response :found
|
||||
end
|
||||
actual_email_count = ActionMailer::Base.deliveries.size
|
||||
assert_not_equal 0, actual_email_count
|
||||
|
||||
import.reload
|
||||
issue_ids = import.items.collect(&:obj_id)
|
||||
expected_email_count =
|
||||
Issue.where(:id => issue_ids).inject(0) do |sum, issue|
|
||||
sum + (issue.notified_users | issue.notified_watchers).size
|
||||
end
|
||||
assert_equal expected_email_count, actual_email_count
|
||||
end
|
||||
|
||||
def test_show_without_errors
|
||||
import = generate_import_with_mapping
|
||||
import.run
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -123,7 +125,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 2,
|
||||
:issue_category => {
|
||||
:name => 'Testing'
|
||||
:name => 'Testing'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -135,7 +137,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 2,
|
||||
:issue_category => {
|
||||
:name => ''
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -146,7 +148,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 97,
|
||||
:issue_category => {
|
||||
:name => 'Testing'
|
||||
:name => 'Testing'
|
||||
}
|
||||
}
|
||||
assert_response 404
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -18,7 +20,7 @@
|
|||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IssueStatusesControllerTest < Redmine::ControllerTest
|
||||
fixtures :issue_statuses, :issues, :users, :trackers
|
||||
fixtures :issue_statuses, :issues, :users, :trackers, :workflows
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
|
@ -30,19 +32,34 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
assert_select 'table.issue_statuses'
|
||||
end
|
||||
|
||||
|
||||
def test_index_by_anonymous_should_redirect_to_login_form
|
||||
@request.session[:user_id] = nil
|
||||
get :index
|
||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fissue_statuses'
|
||||
end
|
||||
|
||||
|
||||
def test_index_by_user_should_respond_with_406
|
||||
@request.session[:user_id] = 2
|
||||
get :index
|
||||
assert_response 406
|
||||
end
|
||||
|
||||
def test_index_should_show_warning_when_no_workflow_is_defined
|
||||
status = IssueStatus.new :name => "No workflow"
|
||||
status.save!
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_select 'table.issue_statuses tbody' do
|
||||
assert_select 'tr:not(:last-of-type) span.icon-warning', :count => 0
|
||||
assert_select 'tr:last-of-type' do
|
||||
assert_select 'td.name', :text => status.name
|
||||
assert_select 'td:nth-of-type(3) span.icon-warning',
|
||||
:text => /#{I18n.t(:text_status_no_workflow)}/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_new
|
||||
get :new
|
||||
assert_response :success
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -44,7 +46,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:journal_details,
|
||||
:queries
|
||||
|
||||
self.use_transactional_fixtures = false
|
||||
self.use_transactional_tests = false
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
|
@ -62,12 +64,12 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => 'My notes',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:time_entry => {
|
||||
:hours => '2.5',
|
||||
:comments => '',
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -98,16 +100,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => 'My notes',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
},
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
},
|
||||
:time_entry => {
|
||||
:hours => '2.5',
|
||||
:comments => '',
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -131,7 +133,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -151,8 +153,8 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:last_journal_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -170,8 +172,8 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:last_journal_id => ''
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -190,7 +192,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:lock_version => 2
|
||||
},
|
||||
},
|
||||
:last_journal_id => ''
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -202,7 +204,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:lock_version => 2
|
||||
},
|
||||
},
|
||||
:last_journal_id => ''
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -219,8 +221,8 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => 'overwrite_conflict_resolution',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:conflict_resolution => 'overwrite'
|
||||
}
|
||||
end
|
||||
|
@ -243,8 +245,8 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => 'add_notes_conflict_resolution',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:conflict_resolution => 'add_notes'
|
||||
}
|
||||
end
|
||||
|
@ -269,8 +271,8 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:notes => 'add_privates_notes_conflict_resolution',
|
||||
:private_notes => '1',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:conflict_resolution => 'add_notes'
|
||||
}
|
||||
end
|
||||
|
@ -291,8 +293,8 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
:fixed_version_id => 4,
|
||||
:notes => 'add_notes_conflict_resolution',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:conflict_resolution => 'cancel'
|
||||
}
|
||||
end
|
||||
|
@ -309,12 +311,12 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:subject => ''
|
||||
},
|
||||
:subject => ''
|
||||
},
|
||||
:time_entry => {
|
||||
:hours => '2.5',
|
||||
:comments => 'should not be added',
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -29,11 +31,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:workflows
|
||||
:workflows,
|
||||
:custom_fields, :custom_fields_trackers
|
||||
|
||||
def setup
|
||||
CustomField.delete_all
|
||||
CustomField.destroy_all
|
||||
Issue.delete_all
|
||||
Watcher.delete_all
|
||||
|
||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
||||
@fields = []
|
||||
@fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => true)))
|
||||
|
@ -58,7 +63,7 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
}
|
||||
|
||||
Member.where(:project_id => 1).each do |member|
|
||||
member.destroy unless @users_to_test.keys.include?(member.principal)
|
||||
member.destroy unless @users_to_test.key?(member.principal)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -169,8 +174,8 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => "User#{user.id}Value0",
|
||||
@field2.id.to_s => "User#{user.id}Value1",
|
||||
@field1.id.to_s => "User#{user.id}Value0",
|
||||
@field2.id.to_s => "User#{user.id}Value1",
|
||||
@field3.id.to_s => "User#{user.id}Value2",
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +225,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_index_with_partial_custom_field_visibility
|
||||
CustomValue.delete_all
|
||||
Issue.delete_all
|
||||
|
||||
p1 = Project.generate!
|
||||
p2 = Project.generate!
|
||||
user = User.generate!
|
||||
|
@ -274,15 +281,16 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
:priority_id => 5,
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'
|
||||
},
|
||||
},
|
||||
:watcher_user_ids => users_to_test.keys.map(&:id)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
assert_equal users_to_test.values.uniq.size, ActionMailer::Base.deliveries.size
|
||||
|
||||
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size
|
||||
# tests that each user receives 1 email with the custom fields he is allowed to see only
|
||||
users_to_test.each do |user, fields|
|
||||
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
|
||||
|
@ -313,13 +321,13 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
assert_equal users_to_test.values.uniq.size, ActionMailer::Base.deliveries.size
|
||||
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size
|
||||
# tests that each user receives 1 email with the custom fields he is allowed to see only
|
||||
users_to_test.each do |user, fields|
|
||||
mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
|
||||
|
@ -350,8 +358,8 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -60,6 +62,7 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_index_should_show_visible_custom_fields_only
|
||||
set_tmp_attachments_directory
|
||||
Issue.destroy_all
|
||||
Journal.delete_all
|
||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
||||
|
@ -178,11 +181,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||
@request.session[:user_id] = 2
|
||||
get :new, :params => {
|
||||
:id => 6,
|
||||
:journal_id => 4
|
||||
:journal_id => 4,
|
||||
:journal_indice => 1
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
assert_include 'Redmine Admin wrote in #note-1:', response.body
|
||||
assert_include '> A comment with a private version', response.body
|
||||
end
|
||||
|
||||
|
@ -253,6 +258,8 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'text/javascript', response.content_type
|
||||
assert_equal 'Updated notes', Journal.find(2).notes
|
||||
assert_include 'journal-2-notes', response.body
|
||||
# response should include journal_indice param for quote link
|
||||
assert_include 'journal_indice=2', response.body
|
||||
end
|
||||
|
||||
def test_update_xhr_with_private_notes_checked
|
||||
|
@ -272,7 +279,7 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_update_xhr_with_private_notes_unchecked
|
||||
Journal.find(2).update_attributes(:private_notes => true)
|
||||
Journal.find(2).update(:private_notes => true)
|
||||
@request.session[:user_id] = 1
|
||||
post :update, :params => {
|
||||
:id => 2,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -60,6 +62,22 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||
assert_equal true, issue.is_private
|
||||
end
|
||||
|
||||
def test_should_update_issue
|
||||
# Enable API and set a key
|
||||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
assert_no_difference 'Issue.count' do
|
||||
assert_difference 'Journal.count' do
|
||||
post :index, :params => {
|
||||
:key => 'secret',
|
||||
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_reply.eml'))
|
||||
}
|
||||
end
|
||||
end
|
||||
assert_response 201
|
||||
end
|
||||
|
||||
def test_should_respond_with_422_if_not_created
|
||||
Project.find('onlinestore').destroy
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -33,7 +35,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select 'h2', :text => 'First post'
|
||||
end
|
||||
|
||||
|
||||
def test_show_should_contain_reply_field_tags_for_quoting
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :params => {
|
||||
|
@ -129,6 +131,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
}
|
||||
end
|
||||
assert_equal I18n.t(:notice_successful_create), flash[:notice]
|
||||
message = Message.find_by_subject('Test created message')
|
||||
assert_not_nil message
|
||||
assert_redirected_to "/boards/1/topics/#{message.to_param}"
|
||||
|
@ -136,14 +139,17 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
assert_equal 2, message.author_id
|
||||
assert_equal 1, message.board_id
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_not_nil mail
|
||||
assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject
|
||||
assert_mail_body_match 'Message body', mail
|
||||
mails = ActionMailer::Base.deliveries
|
||||
assert_not_empty mails
|
||||
mails.each do |mail|
|
||||
assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject
|
||||
assert_mail_body_match 'Message body', mail
|
||||
end
|
||||
|
||||
# author
|
||||
assert mail.bcc.include?('jsmith@somenet.foo')
|
||||
assert_equal ['jsmith@somenet.foo'], mails[0].bcc
|
||||
# project member
|
||||
assert mail.bcc.include?('dlopper@somenet.foo')
|
||||
assert_equal ['dlopper@somenet.foo'], mails[1].bcc
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
|
@ -168,6 +174,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
}
|
||||
assert_redirected_to '/boards/1/topics/1'
|
||||
assert_equal I18n.t(:notice_successful_update), flash[:notice]
|
||||
message = Message.find(1)
|
||||
assert_equal 'New subject', message.subject
|
||||
assert_equal 'New body', message.content
|
||||
|
@ -186,6 +193,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
}
|
||||
assert_redirected_to '/boards/1/topics/1'
|
||||
assert_equal I18n.t(:notice_successful_update), flash[:notice]
|
||||
message = Message.find(1)
|
||||
assert_equal true, message.sticky?
|
||||
assert_equal true, message.locked?
|
||||
|
@ -214,15 +222,17 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
:id => 1,
|
||||
:reply => {
|
||||
:content => 'This is a test reply',
|
||||
:subject => 'Test reply'
|
||||
:subject => 'Test reply'
|
||||
}
|
||||
}
|
||||
reply = Message.order('id DESC').first
|
||||
assert_redirected_to "/boards/1/topics/1?r=#{reply.id}"
|
||||
assert_equal I18n.t(:notice_successful_update), flash[:notice]
|
||||
assert Message.find_by_subject('Test reply')
|
||||
end
|
||||
|
||||
def test_destroy_topic
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Message.count', -3 do
|
||||
post :destroy, :params => {
|
||||
|
@ -231,6 +241,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/boards/1'
|
||||
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
|
||||
assert_nil Message.find_by_id(1)
|
||||
end
|
||||
|
||||
|
@ -243,10 +254,26 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
end
|
||||
assert_redirected_to '/boards/1/topics/1?r=2'
|
||||
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
|
||||
assert_nil Message.find_by_id(2)
|
||||
end
|
||||
|
||||
def test_quote
|
||||
def test_quote_if_message_is_root
|
||||
@request.session[:user_id] = 2
|
||||
get :quote, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
|
||||
assert_include 'RE: First post', response.body
|
||||
assert_include "Redmine Admin wrote:", response.body
|
||||
assert_include '> This is the very first post\n> in the forum', response.body
|
||||
end
|
||||
|
||||
def test_quote_if_message_is_not_root
|
||||
@request.session[:user_id] = 2
|
||||
get :quote, :params => {
|
||||
:board_id => 1,
|
||||
|
@ -257,6 +284,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'text/javascript', response.content_type
|
||||
|
||||
assert_include 'RE: First post', response.body
|
||||
assert_include 'John Smith wrote in message#3:', response.body
|
||||
assert_include '> An other reply', response.body
|
||||
end
|
||||
|
||||
|
@ -265,9 +293,9 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
post :preview, :params => {
|
||||
:board_id => 1,
|
||||
:message => {
|
||||
:subject => "",
|
||||
:content => "Previewed text"
|
||||
}
|
||||
:subject => ""
|
||||
},
|
||||
:text => "Previewed text"
|
||||
}
|
||||
assert_response :success
|
||||
assert_include 'Previewed text', response.body
|
||||
|
@ -280,8 +308,8 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||
:board_id => 1,
|
||||
:message => {
|
||||
:subject => "",
|
||||
:content => "Previewed text"
|
||||
}
|
||||
},
|
||||
:text => "Previewed text"
|
||||
}
|
||||
assert_response :success
|
||||
assert_include 'Previewed text', response.body
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -19,7 +21,8 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
|
||||
class MyControllerTest < Redmine::ControllerTest
|
||||
fixtures :users, :email_addresses, :user_preferences, :roles, :projects, :members, :member_roles,
|
||||
:issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources, :queries
|
||||
:issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources, :queries, :enabled_modules,
|
||||
:journals
|
||||
|
||||
def setup
|
||||
@request.session[:user_id] = 2
|
||||
|
@ -95,7 +98,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
assert_select 'table.issues.sort-by-due-date'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_page_with_issuequery_block_and_no_settings
|
||||
user = User.find(2)
|
||||
user.pref.my_page_layout = {'top' => ['issuequery']}
|
||||
|
@ -125,7 +128,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
assert_select '#block-issuequery' do
|
||||
assert_select 'a[href=?]', "/issues?query_id=#{query.id}"
|
||||
# assert number of columns (columns from query + id column + checkbox column)
|
||||
assert_select 'table.issues th', 6
|
||||
assert_select 'table.issues th', 7
|
||||
# assert results limit
|
||||
assert_select 'table.issues tr.issue', 10
|
||||
assert_select 'table.issues td.assigned_to'
|
||||
|
@ -145,7 +148,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
assert_select '#block-issuequery' do
|
||||
assert_select 'a[href=?]', "/projects/ecookbook/issues?query_id=#{query.id}"
|
||||
# assert number of columns (columns from query + id column + checkbox column)
|
||||
assert_select 'table.issues th', 6
|
||||
assert_select 'table.issues th', 7
|
||||
# assert results limit
|
||||
assert_select 'table.issues tr.issue', 10
|
||||
assert_select 'table.issues td.assigned_to'
|
||||
|
@ -164,7 +167,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select '#block-issuequery' do
|
||||
# assert number of columns (columns from query + id column + checkbox column)
|
||||
assert_select 'table.issues th', 4
|
||||
assert_select 'table.issues th', 5
|
||||
assert_select 'table.issues th', :text => 'Due date'
|
||||
end
|
||||
end
|
||||
|
@ -198,6 +201,50 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_page_with_activity
|
||||
user = User.find(2)
|
||||
user.pref.my_page_layout = {'top' => ['activity']}
|
||||
user.pref.time_zone = 'UTC'
|
||||
user.pref.save!
|
||||
|
||||
get :page
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div#block-activity' do
|
||||
assert_select 'h3' do
|
||||
assert_select 'a[href=?]', activity_path(from: User.current.today, user_id: user.id), :text => 'Activity'
|
||||
end
|
||||
assert_select 'div#activity' do
|
||||
assert_select 'dt', 10
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_page_with_updated_issues_block
|
||||
preferences = User.find(2).pref
|
||||
preferences.my_page_layout = {'top' => ['issuesupdatedbyme']}
|
||||
preferences.my_page_settings = {'issuesupdatedbyme' => {}}
|
||||
preferences.save!
|
||||
|
||||
project = Project.find(3)
|
||||
project.close
|
||||
|
||||
get :page
|
||||
|
||||
assert_response :success
|
||||
assert_select '#block-issuesupdatedbyme' do
|
||||
report_url = CGI.unescape(css_select('h3 a').first.attr('href'))
|
||||
assert_match 'f[]=project.status', report_url
|
||||
assert_match 'v[project.status][]=1', report_url
|
||||
assert_match 'f[]=updated_by', report_url
|
||||
assert_match 'v[updated_by][]=me', report_url
|
||||
|
||||
assert_select 'table.issues tbody tr', 2
|
||||
assert_select 'table.issues tbody tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
|
||||
assert_select 'table.issues tbody tr[id=?]', 'issue-14', 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_page_with_all_blocks
|
||||
blocks = Redmine::MyPage.blocks.keys
|
||||
preferences = User.find(2).pref
|
||||
|
@ -209,6 +256,94 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
assert_select 'div.mypage-box', blocks.size
|
||||
end
|
||||
|
||||
def test_page_with_assigned_issues_block_should_not_show_issues_from_closed_projects
|
||||
preferences = User.find(2).pref
|
||||
preferences.my_page_layout = {'top' => ['issuesassignedtome']}
|
||||
preferences.my_page_settings = {'issuesassignedtome' => {}}
|
||||
preferences.save!
|
||||
|
||||
issue = Issue.find(1)
|
||||
issue.assigned_to = User.find(2)
|
||||
issue.save!
|
||||
|
||||
project = Project.find(2)
|
||||
project.close
|
||||
project.save
|
||||
|
||||
get :page
|
||||
|
||||
assert_response :success
|
||||
assert_select '#block-issuesassignedtome table.issues tbody' do
|
||||
report_url = css_select('h3 a').map {|e| e.attr('href')}.first
|
||||
assert_match 'f%5B%5D=project.status', report_url
|
||||
assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url
|
||||
|
||||
assert_select 'tr', 1
|
||||
assert_select 'tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
|
||||
assert_select 'tr[id=?]', 'issue-4', 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_page_with_reported_issues_block_should_not_show_issues_from_closed_projects
|
||||
preferences = User.find(2).pref
|
||||
preferences.my_page_layout = {'top' => ['issuesreportedbyme']}
|
||||
preferences.my_page_settings = {'issuesreportedbyme' => {}}
|
||||
preferences.save!
|
||||
|
||||
issue = Issue.find(1)
|
||||
issue.assigned_to = User.find(2)
|
||||
issue.save!
|
||||
|
||||
project = Project.find(2)
|
||||
project.close
|
||||
project.save
|
||||
|
||||
get :page
|
||||
|
||||
assert_response :success
|
||||
assert_select '#block-issuesreportedbyme' do
|
||||
report_url = css_select('h3 a').map {|e| e.attr('href')}.first
|
||||
assert_match 'f%5B%5D=project.status', report_url
|
||||
assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url
|
||||
|
||||
assert_select 'table.issues tbody tr', 10
|
||||
assert_select 'table.issues tbody tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
|
||||
assert_select 'table.issues tbody tr[id=?]', 'issue-4', 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_page_with_watched_issues_block_should_not_show_issues_from_closed_projects
|
||||
preferences = User.find(2).pref
|
||||
preferences.my_page_layout = {'top' => ['issueswatched']}
|
||||
preferences.my_page_settings = {'issueswatched' => {}}
|
||||
preferences.save!
|
||||
|
||||
issue = Issue.find(1)
|
||||
issue.watcher_user_ids = ['1', '2']
|
||||
issue.save!
|
||||
|
||||
issue2 = Issue.find(4)
|
||||
issue2.watcher_user_ids = ['2']
|
||||
issue2.save!
|
||||
|
||||
project = Project.find(2)
|
||||
project.close
|
||||
project.save
|
||||
|
||||
get :page
|
||||
|
||||
assert_response :success
|
||||
assert_select '#block-issueswatched table.issues tbody' do
|
||||
report_url = css_select('h3 a').map {|e| e.attr('href')}.first
|
||||
assert_match 'f%5B%5D=project.status', report_url
|
||||
assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url
|
||||
|
||||
assert_select 'tr', 1
|
||||
assert_select 'tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
|
||||
assert_select 'tr[id=?]', 'issue-4', 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_my_account_should_show_editable_custom_fields
|
||||
get :account
|
||||
assert_response :success
|
||||
|
@ -229,6 +364,16 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
assert_select 'select[name=?]', 'user[language]'
|
||||
end
|
||||
|
||||
def test_my_account_with_avatar_enabled_should_link_to_edit_avatar
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do
|
||||
get :account
|
||||
assert_response :success
|
||||
assert_select 'a[href=?] img.gravatar', 'https://gravatar.com'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_my_account_should_not_show_language_select_with_force_default_language_for_loggedin
|
||||
with_settings :force_default_language_for_loggedin => '1' do
|
||||
get :account
|
||||
|
@ -238,7 +383,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_update_account
|
||||
post :account, :params => {
|
||||
put :account, :params => {
|
||||
:user => {
|
||||
:firstname => "Joe",
|
||||
:login => "root",
|
||||
|
@ -246,8 +391,8 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
:group_ids => ['10'],
|
||||
:custom_field_values => {
|
||||
"4" => "0100562500"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,10 +408,10 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
|
||||
def test_update_account_should_send_security_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
post :account, :params => {
|
||||
put :account, :params => {
|
||||
:user => {
|
||||
:mail => 'foobar@example.com'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +538,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
post :update_page, :params => {
|
||||
:settings => {
|
||||
'issuesassignedtome' => {
|
||||
'columns' => ['subject', 'due_date']}
|
||||
'columns' => ['subject', 'due_date']}
|
||||
}
|
||||
},
|
||||
:xhr => true
|
||||
|
@ -450,7 +595,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
pref = User.find(2).pref
|
||||
pref.my_page_layout = {'left' => ['news', 'calendar','documents']}
|
||||
pref.save!
|
||||
|
||||
|
||||
post :order_blocks, :params => {
|
||||
:group => 'left',
|
||||
:blocks => ['documents', 'calendar', 'news']
|
||||
|
@ -464,7 +609,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||
pref = User.find(2).pref
|
||||
pref.my_page_layout = {'left' => ['news','documents'], 'right' => ['calendar']}
|
||||
pref.save!
|
||||
|
||||
|
||||
post :order_blocks, :params => {
|
||||
:group => 'left',
|
||||
:blocks => ['news', 'calendar', 'documents']
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -20,7 +22,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class NewsControllerTest < Redmine::ControllerTest
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
:enabled_modules, :news, :comments,
|
||||
:attachments
|
||||
:attachments, :user_preferences
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
|
@ -116,7 +118,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
:news => {
|
||||
:title => 'NewsControllerTest',
|
||||
:description => 'This is the description',
|
||||
:summary => ''
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -127,7 +129,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'This is the description', news.description
|
||||
assert_equal User.find(2), news.author
|
||||
assert_equal Project.find(1), news.project
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
assert_equal 2, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
def test_post_create_with_attachment
|
||||
|
@ -139,11 +141,11 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
:project_id => 1,
|
||||
:news => {
|
||||
:title => 'Test',
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -160,7 +162,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
:news => {
|
||||
:title => '',
|
||||
:description => 'This is the description',
|
||||
:summary => ''
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -181,7 +183,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 1,
|
||||
:news => {
|
||||
:description => 'Description changed by test_post_edit'
|
||||
:description => 'Description changed by test_post_edit'
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/news/1'
|
||||
|
@ -197,11 +199,11 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 1,
|
||||
:news => {
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -215,7 +217,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||
put :update, :params => {
|
||||
:id => 1,
|
||||
:news => {
|
||||
:description => ''
|
||||
:description => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -28,62 +30,36 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||
:journals, :journal_details,
|
||||
:news
|
||||
|
||||
def test_preview_new_issue
|
||||
def test_preview_new_issue_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:issue => {
|
||||
:description => 'Foo'
|
||||
}
|
||||
:text => 'Foo'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset' do
|
||||
assert_select 'legend', :text => 'Description'
|
||||
assert_select 'p', :text => 'Foo'
|
||||
end
|
||||
assert_select 'p', :text => 'Foo'
|
||||
end
|
||||
|
||||
def test_preview_issue_notes_with_no_change_to_description
|
||||
def test_preview_issue_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:issue_id => 1,
|
||||
:text => 'Unable to print recipes'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'p', :text => 'Unable to print recipes'
|
||||
end
|
||||
|
||||
def test_preview_issue_notes
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:description => Issue.find(1).description,
|
||||
:notes => 'Foo'
|
||||
}
|
||||
:text => 'Foo'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Description', :count => 0
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_issue_notes_with_change_to_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:description => 'Changed description',
|
||||
:notes => 'Foo'
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Description'
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_journal_notes_for_update
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:journal => {
|
||||
:notes => 'Foo'
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
assert_select 'p', :text => 'Foo'
|
||||
end
|
||||
|
||||
|
@ -92,53 +68,30 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:notes => 'attachment:foo.bar'
|
||||
}
|
||||
:issue_id => 1,
|
||||
:field => 'notes',
|
||||
:text => 'attachment:foo.bar'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'a.attachment', :text => 'foo.bar'
|
||||
end
|
||||
|
||||
def test_preview_issue_with_project_changed
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:notes => 'notes',
|
||||
:project_id => 2
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_new_news
|
||||
get :news, :params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''
|
||||
}
|
||||
:text => 'News description',
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset.preview', :text => /News description/
|
||||
assert_select 'p', :text => /News description/
|
||||
end
|
||||
|
||||
def test_preview_existing_news
|
||||
get :news, :params => {
|
||||
:project_id => 1,
|
||||
:id => 2,
|
||||
:news => {
|
||||
:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''
|
||||
}
|
||||
:text => 'News description'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset.preview', :text => /News description/
|
||||
assert_select 'p', :text => /News description/
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -114,7 +116,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||
:membership => {
|
||||
:project_ids => [3],
|
||||
:role_ids => [2]
|
||||
},
|
||||
},
|
||||
:format => 'js'
|
||||
},
|
||||
:xhr => true
|
||||
|
@ -134,7 +136,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||
:user_id => 7,
|
||||
:membership => {
|
||||
:project_ids => [3]
|
||||
},
|
||||
},
|
||||
:format => 'js'
|
||||
},
|
||||
:xhr => true
|
||||
|
@ -184,7 +186,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||
:id => 1,
|
||||
:membership => {
|
||||
:role_ids => [2]
|
||||
},
|
||||
},
|
||||
:format => 'js'
|
||||
},
|
||||
:xhr => true
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -29,7 +31,7 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||
:custom_fields_trackers, :custom_values,
|
||||
:time_entries
|
||||
|
||||
self.use_transactional_fixtures = false
|
||||
self.use_transactional_tests = false
|
||||
|
||||
def setup
|
||||
@request.session[:user_id] = nil
|
||||
|
@ -107,7 +109,6 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||
})
|
||||
assert project_activity_two.save
|
||||
|
||||
|
||||
put :update, :params => {
|
||||
:project_id => 1,
|
||||
:enumerations => {
|
||||
|
@ -143,8 +144,8 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||
:enumerations => {
|
||||
"9"=> {
|
||||
"parent_id"=>"9", "custom_field_values"=> {
|
||||
"7" => "1"}, "active"=>"0"} # Design, De-activate
|
||||
|
||||
"7" => "1"}, "active"=>"0"} # Design, De-activate
|
||||
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
|
@ -163,10 +164,11 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||
# TODO: Need to cause an exception on create but these tests
|
||||
# aren't setup for mocking. Just create a record now so the
|
||||
# second one is a dupicate
|
||||
user = User.find(1)
|
||||
parent = TimeEntryActivity.find(9)
|
||||
TimeEntryActivity.create!({:name => parent.name, :project_id => 1,
|
||||
:position => parent.position, :active => true, :parent_id => 9})
|
||||
TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1),
|
||||
TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => user, :author => user,
|
||||
:issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'})
|
||||
assert_equal 3, TimeEntry.where(:activity_id => 9, :project_id => 1).count
|
||||
assert_equal 1, TimeEntry.where(:activity_id => 10, :project_id => 1).count
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -25,6 +27,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:attachments, :custom_fields, :custom_values, :time_entries,
|
||||
:wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
@request.session[:user_id] = nil
|
||||
Setting.default_language = 'en'
|
||||
|
@ -54,6 +58,198 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||
end
|
||||
|
||||
def test_index_with_project_filter_is_my_projects
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :index, :params => {
|
||||
:f => ['id'],
|
||||
:op => {'id' => '='},
|
||||
:v => {'id' => ['mine']}
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div#projects-index ul' do
|
||||
assert_select 'a.project', 3
|
||||
assert_select 'a', :text => 'eCookbook'
|
||||
assert_select 'a', :text => 'OnlineStore'
|
||||
assert_select 'a', :text => 'Private child of eCookbook'
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_with_subproject_filter
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :index, :params => {
|
||||
:f => ['parent_id'],
|
||||
:op => {'parent_id' => '='},
|
||||
:v => {'parent_id' => ['1']}
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div#projects-index ul' do
|
||||
assert_select 'a.project', 3
|
||||
assert_select 'a', :text => 'eCookbook Subproject 1'
|
||||
assert_select 'a', :text => 'eCookbook Subproject 2'
|
||||
assert_select 'a', :text => 'Private child of eCookbook'
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_as_list_should_format_column_value
|
||||
get :index, :params => {
|
||||
:c => ['name', 'status', 'short_description', 'homepage', 'parent_id', 'identifier', 'is_public', 'created_on', 'cf_3'],
|
||||
:display_type => 'list'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
project = Project.find(1)
|
||||
assert_select 'table.projects' do
|
||||
assert_select 'tr[id=?]', 'project-1' do
|
||||
assert_select 'td.name a[href=?]', '/projects/ecookbook', :text => 'eCookbook'
|
||||
assert_select 'td.status', :text => 'active'
|
||||
assert_select 'td.short_description', :text => 'Recipes management application'
|
||||
assert_select 'td.homepage a.external', :text => 'http://ecookbook.somenet.foo/'
|
||||
assert_select 'td.identifier', :text => 'ecookbook'
|
||||
assert_select 'td.is_public', :text => 'Yes'
|
||||
assert_select 'td.created_on', :text => format_time(project.created_on)
|
||||
assert_select 'td.cf_3.list', :text => 'Stable'
|
||||
end
|
||||
assert_select 'tr[id=?]', 'project-4' do
|
||||
assert_select 'td.parent_id a[href=?]', '/projects/ecookbook', :text => 'eCookbook'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_as_list_should_show_my_favourite_projects
|
||||
@request.session[:user_id] = 1
|
||||
get :index, :params => {
|
||||
:display_type => 'list'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'tr[id=?] td.name span[class=?]', 'project-5', 'icon icon-user my-project'
|
||||
end
|
||||
|
||||
def test_index_as_list_should_indent_projects
|
||||
@request.session[:user_id] = 1
|
||||
get :index, :params => {
|
||||
:c => ['name', 'short_description'],
|
||||
:sort => 'parent_id:desc,lft:desc',
|
||||
:display_type => 'list'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
child_level1 = css_select('tr#project-5').map {|e| e.attr('class')}.first.split(' ')
|
||||
child_level2 = css_select('tr#project-6').map {|e| e.attr('class')}.first.split(' ')
|
||||
|
||||
assert_include 'idnt', child_level1
|
||||
assert_include 'idnt-1', child_level1
|
||||
|
||||
assert_include 'idnt', child_level2
|
||||
assert_include 'idnt-2', child_level2
|
||||
end
|
||||
|
||||
def test_index_with_default_query_setting
|
||||
with_settings :project_list_defaults => {'column_names' => %w(name short_description status)} do
|
||||
get :index, :params => {
|
||||
:display_type => 'list'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
assert_equal ['Name', 'Description', 'Status'], columns_in_list
|
||||
end
|
||||
|
||||
def test_index_as_board_should_not_include_csv_export
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :index
|
||||
|
||||
assert_response :success
|
||||
assert_select 'p.other-formats a.csv', 0
|
||||
assert_select '#csv-export-options', 0
|
||||
end
|
||||
|
||||
def test_index_as_list_should_include_csv_export
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :index, :params => {
|
||||
:display_type => 'list',
|
||||
:f => ['parent_id'],
|
||||
:op => {'parent_id' => '='},
|
||||
:v => {'parent_id' => ['1']}
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# Assert CSV export link
|
||||
assert_select 'p.other-formats a.csv'
|
||||
|
||||
# Assert export modal
|
||||
assert_select '#csv-export-options' do
|
||||
assert_select 'form[action=?][method=get]', '/projects.csv' do
|
||||
# filter
|
||||
assert_select 'input[name=?][value=?]', 'f[]', 'parent_id'
|
||||
assert_select 'input[name=?][value=?]', 'op[parent_id]', '='
|
||||
assert_select 'input[name=?][value=?]', 'v[parent_id][]', '1'
|
||||
# columns
|
||||
assert_select 'input[name=?][type=hidden][value=?]', 'c[]', 'name'
|
||||
assert_select 'input[name=?][type=hidden][value=?]', 'c[]', 'identifier'
|
||||
assert_select 'input[name=?][type=hidden][value=?]', 'c[]', 'short_description'
|
||||
assert_select 'input[name=?][type=hidden]', 'c[]', 3
|
||||
assert_select 'input[name=?][value=?]', 'c[]', 'all_inline'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_csv
|
||||
with_settings :date_format => '%m/%d/%Y' do
|
||||
get :index, :params => {:format => 'csv'}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', response.media_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_sort_by_custom_field
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
cf = ProjectCustomField.find(3)
|
||||
CustomValue.create!(:custom_field => cf, :customized => Project.find(2), :value => 'Beta')
|
||||
|
||||
get(
|
||||
:index,
|
||||
:params => {
|
||||
:display_type => 'list',
|
||||
:c => ['name', 'identifier', 'cf_3'],
|
||||
:set_filter => 1,
|
||||
:sort => "cf_#{cf.id}:asc"
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
|
||||
assert_equal(
|
||||
['Beta', 'Stable'],
|
||||
columns_values_in_list('cf_3').reject {|p| p.empty?}
|
||||
)
|
||||
end
|
||||
|
||||
def test_index_with_int_custom_field_total
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
field = ProjectCustomField.generate!(:field_format => 'int')
|
||||
CustomValue.create!(:customized => Project.find(1), :custom_field => field, :value => '2')
|
||||
CustomValue.create!(:customized => Project.find(2), :custom_field => field, :value => '7')
|
||||
get(
|
||||
:index,
|
||||
:params => {
|
||||
:display_type => 'list',
|
||||
:t => ["cf_#{field.id}"]
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
assert_select '.query-totals'
|
||||
assert_select ".total-for-cf-#{field.id} span.value", :text => '9'
|
||||
end
|
||||
|
||||
def test_autocomplete_js
|
||||
get :autocomplete, :params => {
|
||||
:format => 'js',
|
||||
|
@ -64,6 +260,16 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
def test_autocomplete_js_with_blank_search_term
|
||||
get :autocomplete, :params => {
|
||||
:format => 'js',
|
||||
:q => ''
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||||
@request.session[:user_id] = 3
|
||||
get :index
|
||||
|
@ -161,8 +367,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:tracker_ids => ['1', '3'],
|
||||
# an issue custom field that is not for all project
|
||||
:issue_custom_field_ids => ['9'],
|
||||
|
@ -195,10 +401,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 1
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
@ -217,7 +423,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:project => {
|
||||
:name => "blog",
|
||||
:identifier => "blog"
|
||||
},
|
||||
},
|
||||
:continue => 'Create and continue'
|
||||
}
|
||||
end
|
||||
|
@ -235,11 +441,11 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:tracker_ids => ['1', '3'],
|
||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,10 +476,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 1
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -293,10 +499,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 1
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
@ -317,9 +523,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
}
|
||||
|
||||
'3' => 'Beta'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -341,10 +547,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 6
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -365,7 +571,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:name => "blog1",
|
||||
:identifier => "blog1",
|
||||
:enabled_module_names => ["issue_tracking", "repository"]
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -378,7 +584,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:name => "blog2",
|
||||
:identifier => "blog2",
|
||||
:enabled_module_names => ["issue_tracking", "repository"]
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -398,7 +604,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => 'inherited',
|
||||
:parent_id => parent.id,
|
||||
:inherit_members => '1'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
@ -420,7 +626,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:name => "blog",
|
||||
:identifier => "",
|
||||
:enabled_module_names => %w(issue_tracking news)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -467,7 +673,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'li', :text => /Development status/
|
||||
assert_select 'li[class=?]', 'cf_3', :text => /Development status/
|
||||
end
|
||||
|
||||
def test_show_should_not_display_hidden_custom_fields
|
||||
|
@ -514,9 +720,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def show_archived_project_should_be_denied
|
||||
def test_show_archived_project_should_be_denied
|
||||
project = Project.find_by_identifier('ecookbook')
|
||||
project.archive!
|
||||
project.archive
|
||||
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
|
@ -526,6 +732,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_not_include project.name, response.body
|
||||
end
|
||||
|
||||
def test_show_archived_project_should_show_unarchive_link_to_admins
|
||||
@request.session[:user_id] = 1
|
||||
project = Project.find_by_identifier('ecookbook')
|
||||
project.archive
|
||||
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response 403
|
||||
assert_select 'a', :text => "Unarchive"
|
||||
end
|
||||
|
||||
def test_show_should_not_show_private_subprojects_that_are_not_visible
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
|
@ -553,6 +771,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'table.issue-report td.total a', :text => %r{\A[1-9]\d*\z}
|
||||
end
|
||||
|
||||
def test_show_should_spent_and_estimated_time
|
||||
@request.session[:user_id] = 1
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
|
||||
assert_select 'div.spent_time.box>ul' do
|
||||
assert_select '>li:nth-child(1)', :text => 'Estimated time: 203.50 hours'
|
||||
assert_select '>li:nth-child(2)', :text => 'Spent time: 162.90 hours'
|
||||
end
|
||||
end
|
||||
|
||||
def test_settings
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :settings, :params => {
|
||||
|
@ -589,22 +819,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
get :settings, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
def test_setting_with_wiki_module_and_no_wiki
|
||||
Project.find(1).wiki.destroy
|
||||
Role.find(1).add_permission! :manage_wiki
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :settings, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/wiki' do
|
||||
assert_select 'input[name=?]', 'wiki[start_page]'
|
||||
end
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_settings_should_accept_version_status_filter
|
||||
|
@ -646,6 +861,27 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_name=.1&version_status='
|
||||
end
|
||||
|
||||
def test_settings_should_show_default_version_in_versions_tab
|
||||
project = Project.find(1)
|
||||
project.default_version_id = 3
|
||||
project.save!
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :settings, :params => {
|
||||
:id => 'ecookbook',
|
||||
:tab => 'versions',
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.versions tbody' do
|
||||
# asserts that only one version is marked as default
|
||||
assert_select 'td.tick span.icon-checked', 1
|
||||
# asserts which version is marked as default
|
||||
assert_select 'tr:first-child td.tick span.icon-checked', 1
|
||||
end
|
||||
end
|
||||
|
||||
def test_settings_should_show_locked_members
|
||||
user = User.generate!
|
||||
member = User.add_to_project(user, Project.find(1))
|
||||
|
@ -684,6 +920,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'a#tab-activities'
|
||||
end
|
||||
|
||||
def test_settings_should_not_display_custom_fields_not_visible_for_user
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
|
||||
get :settings, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select#project_custom_field_values_3', :count => 0
|
||||
end
|
||||
|
||||
def test_update
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :params => {
|
||||
|
@ -733,7 +981,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:name => 'Closed'
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
assert_response 403
|
||||
assert_equal 'eCookbook', Project.find(1).name
|
||||
end
|
||||
|
||||
|
@ -753,15 +1001,17 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_match /Successful update/, flash[:notice]
|
||||
end
|
||||
|
||||
def test_modules
|
||||
def test_update_modules
|
||||
@request.session[:user_id] = 2
|
||||
Project.find(1).enabled_module_names = ['issue_tracking', 'news']
|
||||
|
||||
post :modules, :params => {
|
||||
post :update, :params => {
|
||||
:id => 1,
|
||||
:enabled_module_names => ['issue_tracking', 'repository', 'documents']
|
||||
:project => {
|
||||
:enabled_module_names => ['issue_tracking', 'repository', 'documents']
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/settings/modules'
|
||||
assert_redirected_to '/projects/ecookbook/settings'
|
||||
assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
|
||||
end
|
||||
|
||||
|
@ -778,6 +1028,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_destroy_without_confirmation_should_show_confirmation_with_subprojects
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 1 # admin
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
|
@ -793,6 +1044,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 1 # admin
|
||||
|
||||
assert_difference 'Project.count', -5 do
|
||||
|
@ -900,10 +1152,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:id => source.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset#project_issue_custom_fields' do
|
||||
assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s
|
||||
assert_select 'input[type=checkbox][value=?]:not([checked])', field2.id.to_s
|
||||
end
|
||||
assert_select 'input[type=hidden][name=?][value=?]', 'project[issue_custom_field_ids][]', field1.id.to_s
|
||||
assert_select 'input[type=hidden][name=?][value=?]', 'project[issue_custom_field_ids][]', field2.id.to_s, 0
|
||||
end
|
||||
|
||||
def test_post_copy_should_copy_requested_items
|
||||
|
@ -918,8 +1168,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
:identifier => 'unique-copy',
|
||||
:tracker_ids => ['1', '2', '3', ''],
|
||||
:enabled_module_names => %w(issue_tracking time_tracking)
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
:only => %w(issues versions)
|
||||
}
|
||||
end
|
||||
|
@ -958,21 +1208,42 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_select_error /Identifier cannot be blank/
|
||||
end
|
||||
|
||||
def test_jump_without_project_id_should_redirect_to_active_tab
|
||||
def test_bookmark_should_create_bookmark
|
||||
@request.session[:user_id] = 3
|
||||
post :bookmark, params: { id: 'ecookbook' }
|
||||
assert_redirected_to controller: 'projects', action: 'show', id: 'ecookbook'
|
||||
jb = Redmine::ProjectJumpBox.new(User.find(3))
|
||||
assert jb.bookmark?(Project.find('ecookbook'))
|
||||
refute jb.bookmark?(Project.find('onlinestore'))
|
||||
end
|
||||
|
||||
def test_bookmark_should_delete_bookmark
|
||||
@request.session[:user_id] = 3
|
||||
jb = Redmine::ProjectJumpBox.new(User.find(3))
|
||||
project = Project.find('ecookbook')
|
||||
jb.bookmark_project project
|
||||
delete :bookmark, params: { id: 'ecookbook' }
|
||||
assert_redirected_to controller: 'projects', action: 'show', id: 'ecookbook'
|
||||
|
||||
jb = Redmine::ProjectJumpBox.new(User.find(3))
|
||||
refute jb.bookmark?(Project.find('ecookbook'))
|
||||
end
|
||||
|
||||
def test_index_jump_without_project_id_should_redirect_to_active_tab
|
||||
get :index, :params => {
|
||||
:jump => 'issues'
|
||||
}
|
||||
assert_redirected_to '/issues'
|
||||
end
|
||||
|
||||
def test_jump_should_not_redirect_to_unknown_tab
|
||||
def test_index_jump_should_not_redirect_to_unknown_tab
|
||||
get :index, :params => {
|
||||
:jump => 'foobar'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_jump_should_redirect_to_active_tab
|
||||
def test_show_jump_should_redirect_to_active_tab
|
||||
get :show, :params => {
|
||||
:id => 1,
|
||||
:jump => 'issues'
|
||||
|
@ -980,7 +1251,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_redirected_to '/projects/ecookbook/issues'
|
||||
end
|
||||
|
||||
def test_jump_should_not_redirect_to_inactive_tab
|
||||
def test_show_jump_should_not_redirect_to_inactive_tab
|
||||
get :show, :params => {
|
||||
:id => 3,
|
||||
:jump => 'documents'
|
||||
|
@ -988,7 +1259,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_jump_should_not_redirect_to_unknown_tab
|
||||
def test_show_jump_should_not_redirect_to_unknown_tab
|
||||
get :show, :params => {
|
||||
:id => 3,
|
||||
:jump => 'foobar'
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -67,6 +69,26 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_response 404
|
||||
end
|
||||
|
||||
def test_new_should_not_render_show_inline_columns_option_for_query_without_available_inline_columns
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :params => {
|
||||
:type => 'ProjectQuery'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'p[class=?]', 'block_columns', 0
|
||||
end
|
||||
|
||||
def test_new_should_not_render_show_totals_option_for_query_without_totable_columns
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :params => {
|
||||
:type => 'ProjectQuery'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'p[class=?]', 'totables_columns', 0
|
||||
end
|
||||
|
||||
def test_new_time_entry_query
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :params => {
|
||||
|
@ -75,6 +97,49 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=type][value=?]', 'TimeEntryQuery'
|
||||
assert_select 'p[class=?]', 'totable_columns', 1
|
||||
assert_select 'p[class=?]', 'block_columns', 0
|
||||
end
|
||||
|
||||
def test_new_project_query_for_projects
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :params => {
|
||||
:type => 'ProjectQuery'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=type][value=?]', 'ProjectQuery'
|
||||
end
|
||||
|
||||
def test_new_project_query_should_not_render_roles_visibility_options
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :params => {
|
||||
:type => 'ProjectQuery'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'input[id=?]', 'query_visibility_0', 1
|
||||
assert_select 'input[id=?]', 'query_visibility_2', 1
|
||||
assert_select 'input[id=?]', 'query_visibility_1', 0
|
||||
end
|
||||
|
||||
def test_new_project_query_should_not_render_for_all_projects_option
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :params => {
|
||||
:type => 'ProjectQuery'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'input[name=?]', 'for_all_projects', 0
|
||||
end
|
||||
|
||||
def test_new_time_entry_query_should_select_spent_time_from_main_menu
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'TimeEntryQuery'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '#main-menu a.time-entries.selected'
|
||||
end
|
||||
|
||||
def test_new_time_entry_query_with_issue_tracking_module_disabled_should_be_allowed
|
||||
|
@ -96,10 +161,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:f => ["status_id", "assigned_to_id"],
|
||||
:op => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
},
|
||||
:v => {
|
||||
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_project_public_query", "visibility" => "2"
|
||||
}
|
||||
|
@ -120,10 +185,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_project_private_query", "visibility" => "0"
|
||||
}
|
||||
|
@ -144,10 +209,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]
|
||||
}
|
||||
|
@ -165,13 +230,13 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["me"], "status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_global_private_query", "visibility" => "0"
|
||||
},
|
||||
},
|
||||
:c => ["", "tracker", "subject", "priority", "category"]
|
||||
}
|
||||
|
||||
|
@ -189,10 +254,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:fields => ["assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "="
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["me"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_global_query"
|
||||
}
|
||||
|
@ -212,15 +277,15 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:default_columns => '1',
|
||||
:operators => {
|
||||
"status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
:name => "test_new_with_sort",
|
||||
:visibility => "2",
|
||||
:sort_criteria => {
|
||||
"0" => ["due_date", "desc"], "1" => ["tracker", ""]}
|
||||
"0" => ["due_date", "desc"], "1" => ["tracker", ""]}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,6 +309,31 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_select 'input[name=?]', 'query[name]'
|
||||
end
|
||||
|
||||
def test_create_query_without_permission_should_fail
|
||||
Role.all.each {|r| r.remove_permission! :save_queries, :manage_public_queries}
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference '::Query.count' do
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query => {:name => 'Foo'}
|
||||
}
|
||||
end
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_create_global_query_without_permission_should_fail
|
||||
Role.all.each {|r| r.remove_permission! :save_queries, :manage_public_queries}
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference '::Query.count' do
|
||||
post :create, :params => {
|
||||
:query => {:name => 'Foo'}
|
||||
}
|
||||
end
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_create_global_query_from_gantt
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'IssueQuery.count' do
|
||||
|
@ -251,14 +341,15 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:gantt => 1,
|
||||
:operators => {
|
||||
"status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
:name => "test_create_from_gantt",
|
||||
:draw_relations => '1',
|
||||
:draw_progress_line => '1'
|
||||
:draw_progress_line => '1',
|
||||
:draw_selected_columns => '1'
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
@ -267,6 +358,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_redirected_to "/issues/gantt?query_id=#{query.id}"
|
||||
assert_equal true, query.draw_relations
|
||||
assert_equal true, query.draw_progress_line
|
||||
assert_equal true, query.draw_selected_columns
|
||||
end
|
||||
|
||||
def test_create_project_query_from_gantt
|
||||
|
@ -277,14 +369,15 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:gantt => 1,
|
||||
:operators => {
|
||||
"status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
:name => "test_create_from_gantt",
|
||||
:draw_relations => '0',
|
||||
:draw_progress_line => '0'
|
||||
:draw_progress_line => '0',
|
||||
:draw_selected_columns => '0'
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
@ -293,6 +386,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}"
|
||||
assert_equal false, query.draw_relations
|
||||
assert_equal false, query.draw_progress_line
|
||||
assert_equal false, query.draw_selected_columns
|
||||
end
|
||||
|
||||
def test_create_project_public_query_should_force_private_without_manage_public_queries_permission
|
||||
|
@ -384,10 +478,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:f => ["spent_on"],
|
||||
:op => {
|
||||
"spent_on" => "="
|
||||
},
|
||||
},
|
||||
:v => {
|
||||
"spent_on" => ["2016-07-14"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_project_public_query", "visibility" => "2"
|
||||
}
|
||||
|
@ -400,6 +494,32 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_create_public_project_query
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
q = new_record(ProjectQuery) do
|
||||
post :create, :params => {
|
||||
:type => 'ProjectQuery',
|
||||
:default_columns => '1',
|
||||
:f => ["status"],
|
||||
:op => {
|
||||
"status" => "="
|
||||
},
|
||||
:v => {
|
||||
"status" => ['1']
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_project_public_query", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to :controller => 'projects', :action => 'index', :query_id => q.id
|
||||
|
||||
assert q.is_public?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_edit_global_public_query
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :params => {
|
||||
|
@ -465,7 +585,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_response 404
|
||||
end
|
||||
|
||||
def test_udpate_global_private_query
|
||||
def test_update_global_private_query
|
||||
@request.session[:user_id] = 3
|
||||
put :update, :params => {
|
||||
:id => 3,
|
||||
|
@ -473,10 +593,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["me"], "status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_edit_global_private_query", "visibility" => "2"
|
||||
}
|
||||
|
@ -497,10 +617,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||
},
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_edit_global_public_query", "visibility" => "2"
|
||||
}
|
||||
|
@ -570,7 +690,10 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_include ["eCookbook - 2.0", "3", "open"], json
|
||||
end
|
||||
|
||||
def test_filter_without_project_id_should_return_filter_values
|
||||
def test_version_filter_without_project_id_should_return_all_visible_fixed_versions
|
||||
# Remove "jsmith" user from "Private child of eCookbook" project
|
||||
Project.find(5).memberships.find_by(:user_id => 2).destroy
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :filter, :params => {
|
||||
:name => 'fixed_version_id'
|
||||
|
@ -579,7 +702,14 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
# response includes visible version
|
||||
assert_include ["eCookbook Subproject 1 - 2.0", "4", "open"], json
|
||||
assert_include ["eCookbook - 0.1", "1", "closed"], json
|
||||
# response includes systemwide visible version
|
||||
assert_include ["OnlineStore - Systemwide visible version", "7", "open"], json
|
||||
# response doesn't include non visible version
|
||||
assert_not_include ["Private child of eCookbook - Private Version of public subproject", "6", "open"], json
|
||||
end
|
||||
|
||||
def test_subproject_filter_time_entries_with_project_id_should_return_filter_values
|
||||
|
@ -596,4 +726,96 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||
assert_equal 4, json.count
|
||||
assert_include ["Private child of eCookbook","5"], json
|
||||
end
|
||||
|
||||
def test_assignee_filter_should_return_active_and_locked_users_grouped_by_status
|
||||
@request.session[:user_id] = 1
|
||||
get :filter, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'IssueQuery',
|
||||
:name => 'assigned_to_id'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
assert_equal 6, json.count
|
||||
# "me" value should not be grouped
|
||||
assert_include ["<< me >>", "me"], json
|
||||
assert_include ["Dave Lopper", "3", "active"], json
|
||||
assert_include ["Dave2 Lopper2", "5", "locked"], json
|
||||
end
|
||||
|
||||
def test_author_filter_should_return_active_and_locked_users_grouped_by_status
|
||||
@request.session[:user_id] = 1
|
||||
get :filter, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'IssueQuery',
|
||||
:name => 'author_id'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
assert_equal 7, json.count
|
||||
# "me" value should not be grouped
|
||||
assert_include ["<< me >>", "me"], json
|
||||
assert_include ["Dave Lopper", "3", "active"], json
|
||||
assert_include ["Dave2 Lopper2", "5", "locked"], json
|
||||
assert_include ["Anonymous", User.anonymous.id.to_s], json
|
||||
end
|
||||
|
||||
def test_user_filter_should_return_active_and_locked_users_grouped_by_status
|
||||
@request.session[:user_id] = 1
|
||||
get :filter, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'TimeEntryQuery',
|
||||
:name => 'user_id'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
assert_equal 7, json.count
|
||||
# "me" value should not be grouped
|
||||
assert_include ["<< me >>", "me"], json
|
||||
assert_include ["Dave Lopper", "3", "active"], json
|
||||
assert_include ["Dave2 Lopper2", "5", "locked"], json
|
||||
end
|
||||
|
||||
def test_watcher_filter_without_permission_should_show_only_me
|
||||
# This user does not have view_issue_watchers permission
|
||||
@request.session[:user_id] = 7
|
||||
|
||||
get :filter, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'IssueQuery',
|
||||
:name => 'watcher_id'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
assert_equal 1, json.count
|
||||
assert_equal [["<< me >>", "me"]], json
|
||||
end
|
||||
|
||||
def test_watcher_filter_with_permission_should_show_members
|
||||
# This user has view_issue_watchers permission
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :filter, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'IssueQuery',
|
||||
:name => 'watcher_id'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
assert_equal 6, json.count
|
||||
# "me" value should not be grouped
|
||||
assert_include ["<< me >>", "me"], json
|
||||
assert_include ["Dave Lopper", "3", "active"], json
|
||||
assert_include ["Dave2 Lopper2", "5", "locked"], json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -25,7 +27,8 @@ class ReportsControllerTest < Redmine::ControllerTest
|
|||
:member_roles,
|
||||
:members,
|
||||
:enabled_modules,
|
||||
:versions
|
||||
:versions,
|
||||
:workflows
|
||||
|
||||
def test_get_issue_report
|
||||
get :issue_report, :params => {
|
||||
|
@ -34,6 +37,38 @@ class ReportsControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_issue_report_with_subprojects_issues
|
||||
Setting.stubs(:display_subprojects_issues?).returns(true)
|
||||
get :issue_report, :params => {
|
||||
:id => 1
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
# Count subprojects issues
|
||||
assert_select 'table.list tbody :nth-child(1):first' do
|
||||
assert_select 'td', :text => 'Bug'
|
||||
assert_select ':nth-child(2)', :text => '5' # open
|
||||
assert_select ':nth-child(3)', :text => '3' # closed
|
||||
assert_select ':nth-child(4)', :text => '8' # total
|
||||
end
|
||||
end
|
||||
|
||||
def test_issue_report_without_subprojects_issues
|
||||
Setting.stubs(:display_subprojects_issues?).returns(false)
|
||||
get :issue_report, :params => {
|
||||
:id => 1
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
# Do not count subprojects issues
|
||||
assert_select 'table.list tbody :nth-child(1):first' do
|
||||
assert_select 'td', :text => 'Bug'
|
||||
assert_select ':nth-child(2)', :text => '3' # open
|
||||
assert_select ':nth-child(3)', :text => '3' # closed
|
||||
assert_select ':nth-child(4)', :text => '6' # total
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_issue_report_details
|
||||
%w(tracker version priority category assigned_to author subproject).each do |detail|
|
||||
get :issue_report_details, :params => {
|
||||
|
@ -44,6 +79,79 @@ class ReportsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_get_issue_report_details_by_tracker_should_show_only_statuses_used_by_the_project
|
||||
Setting.stubs(:display_subprojects_issues?).returns(false)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
|
||||
WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
|
||||
WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 5)
|
||||
WorkflowTransition.create(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 6)
|
||||
|
||||
get :issue_report_details, :params => {
|
||||
:id => 1,
|
||||
:detail => 'tracker'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'table.list tbody :nth-child(1)' do
|
||||
assert_select 'td', :text => 'Bug'
|
||||
assert_select ':nth-child(2)', :text => '3' # status:1
|
||||
assert_select ':nth-child(3)', :text => '-' # status:2
|
||||
assert_select ':nth-child(4)', :text => '-' # status:4
|
||||
assert_select ':nth-child(5)', :text => '3' # status:5
|
||||
assert_select ':nth-child(6)', :text => '-' # status:6
|
||||
assert_select ':nth-child(7)', :text => '3' # open
|
||||
assert_select ':nth-child(8)', :text => '3' # closed
|
||||
assert_select ':nth-child(9)', :text => '6' # total
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_issue_report_details_by_tracker_with_subprojects_issues
|
||||
Setting.stubs(:display_subprojects_issues?).returns(true)
|
||||
get :issue_report_details, :params => {
|
||||
:id => 1,
|
||||
:detail => 'tracker'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
# Count subprojects issues
|
||||
assert_select 'table.list tbody :nth-child(1)' do
|
||||
assert_select 'td', :text => 'Bug'
|
||||
assert_select ':nth-child(2)', :text => '5' # status:1
|
||||
assert_select ':nth-child(3)', :text => '-' # status:2
|
||||
assert_select ':nth-child(4)', :text => '-' # status:3
|
||||
assert_select ':nth-child(5)', :text => '-' # status:4
|
||||
assert_select ':nth-child(6)', :text => '3' # status:5
|
||||
assert_select ':nth-child(7)', :text => '-' # status:6
|
||||
assert_select ':nth-child(8)', :text => '5' # open
|
||||
assert_select ':nth-child(9)', :text => '3' # closed
|
||||
assert_select ':nth-child(10)', :text => '8' # total
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_issue_report_details_by_tracker_without_subprojects_issues
|
||||
Setting.stubs(:display_subprojects_issues?).returns(false)
|
||||
get :issue_report_details, :params => {
|
||||
:id => 1,
|
||||
:detail => 'tracker'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
# Do not count subprojects issues
|
||||
assert_select 'table.list tbody :nth-child(1)' do
|
||||
assert_select 'td', :text => 'Bug'
|
||||
assert_select ':nth-child(2)', :text => '3' # status:1
|
||||
assert_select ':nth-child(3)', :text => '-' # status:2
|
||||
assert_select ':nth-child(4)', :text => '-' # status:3
|
||||
assert_select ':nth-child(5)', :text => '-' # status:4
|
||||
assert_select ':nth-child(6)', :text => '3' # status:5
|
||||
assert_select ':nth-child(7)', :text => '-' # status:6
|
||||
assert_select ':nth-child(8)', :text => '3' # open
|
||||
assert_select ':nth-child(9)', :text => '3' # closed
|
||||
assert_select ':nth-child(10)', :text => '6' # total
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_issue_report_details_by_tracker_should_show_issue_count
|
||||
Issue.delete_all
|
||||
Issue.generate!(:tracker_id => 1)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
|
@ -26,9 +28,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
|
||||
REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk")
|
||||
PRJ_ID = 3
|
||||
CHAR_1_UTF8_HEX = "\xc3\x9c".dup.force_encoding('UTF-8')
|
||||
|
||||
def setup
|
||||
super
|
||||
User.current = nil
|
||||
@project = Project.find(PRJ_ID)
|
||||
@repository = Repository::Bazaar.create(
|
||||
|
@ -67,6 +69,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_browse_directory
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['directory'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -81,6 +84,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_browse_at_given_revision
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash([])[:param],
|
||||
:rev => 3
|
||||
}
|
||||
|
@ -97,6 +101,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_changes
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -106,6 +111,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_entry_show
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -116,6 +122,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_entry_download
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
|
@ -127,6 +134,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_directory_entry
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['directory'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -138,6 +146,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 3,
|
||||
:type => dt
|
||||
}
|
||||
|
@ -150,6 +159,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
def test_annotate
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -213,7 +223,7 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||
assert_select "th.line-num", :text => '1' do
|
||||
assert_select "+ td.revision" do
|
||||
assert_select "a", :text => '2'
|
||||
assert_select "+ td.author", :text => "test #{CHAR_1_UTF8_HEX}" do
|
||||
assert_select "+ td.author", :text => "test Ü" do
|
||||
assert_select "+ td",
|
||||
:text => "author non ASCII test"
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,12 +19,13 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesControllerTest < Redmine::RepositoryControllerTest
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules,
|
||||
:repositories, :issues, :issue_statuses, :changesets, :changes,
|
||||
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
|
||||
|
||||
def setup
|
||||
super
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
|
@ -53,7 +56,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
assert_select 'option[value=Git]:not([selected])'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_get_new_with_type
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :params => {
|
||||
|
@ -179,9 +182,31 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
if repository_configured?('subversion')
|
||||
def test_show_should_show_diff_button_depending_on_browse_repository_permission
|
||||
@request.session[:user_id] = 2
|
||||
role = Role.find(1)
|
||||
|
||||
role.add_permission! :browse_repository
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[value="View differences"]'
|
||||
|
||||
role.remove_permission! :browse_repository
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[value="View differences"]', :count => 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_revisions
|
||||
get :revisions, :params => {
|
||||
:id => 1
|
||||
:id => 1,
|
||||
:repository_id => 10
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.changesets'
|
||||
|
@ -209,6 +234,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
def test_revision
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -221,6 +247,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
with_settings :commit_logs_formatting => '0' do
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -234,11 +261,12 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/repository/revisions/1/issues' do
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/repository/10/revisions/1/issues' do
|
||||
assert_select 'input[name=?]', 'issue_id'
|
||||
end
|
||||
end
|
||||
|
@ -246,6 +274,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
def test_revision_should_not_change_the_project_menu_link
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -256,13 +285,14 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
def test_revision_with_before_nil_and_afer_normal
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div.contextual' do
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/0', 0
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2'
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/10/revisions/0', 0
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/10/revisions/2'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -271,6 +301,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
assert_difference 'Changeset.find(103).issues.size' do
|
||||
post :add_related_issue, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 4,
|
||||
:issue_id => 2,
|
||||
:format => 'js'
|
||||
|
@ -289,6 +320,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
assert_difference 'Changeset.find(103).issues.size' do
|
||||
post :add_related_issue, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 4,
|
||||
:issue_id => "#2",
|
||||
:format => 'js'
|
||||
|
@ -303,6 +335,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
assert_no_difference 'Changeset.find(103).issues.size' do
|
||||
post :add_related_issue, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 4,
|
||||
:issue_id => 9999,
|
||||
:format => 'js'
|
||||
|
@ -322,6 +355,7 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
assert_difference 'Changeset.find(103).issues.size', -1 do
|
||||
delete :remove_related_issue, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 4,
|
||||
:issue_id => 2,
|
||||
:format => 'js'
|
||||
|
@ -342,19 +376,29 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||
|
||||
get :graph, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:graph => 'commits_per_month'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'image/svg+xml', @response.content_type
|
||||
assert_equal 'application/json', response.content_type
|
||||
data = ActiveSupport::JSON.decode(response.body)
|
||||
assert_not_nil data['labels']
|
||||
assert_not_nil data['commits']
|
||||
assert_not_nil data['changes']
|
||||
end
|
||||
|
||||
def test_graph_commits_per_author
|
||||
get :graph, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:graph => 'commits_per_author'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'image/svg+xml', @response.content_type
|
||||
assert_equal 'application/json', response.content_type
|
||||
data = ActiveSupport::JSON.decode(response.body)
|
||||
assert_not_nil data['labels']
|
||||
assert_not_nil data['commits']
|
||||
assert_not_nil data['changes']
|
||||
end
|
||||
|
||||
def test_get_committers
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
|
@ -31,6 +33,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
NUM_REV = 7
|
||||
|
||||
def setup
|
||||
super
|
||||
Setting.default_language = 'en'
|
||||
User.current = nil
|
||||
|
||||
|
@ -85,6 +88,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -104,6 +108,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images'])[:param],
|
||||
:rev => 1
|
||||
}
|
||||
|
@ -123,6 +128,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -138,6 +144,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:rev => 2
|
||||
}
|
||||
|
@ -154,7 +161,8 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'zzz.c'])[:param]
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'zzz.c'])[:param]
|
||||
}
|
||||
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
||||
end
|
||||
|
@ -166,6 +174,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
|
@ -179,6 +188,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -193,6 +203,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 3,
|
||||
:type => dt
|
||||
}
|
||||
|
@ -211,6 +222,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 1,
|
||||
:type => dt
|
||||
}
|
||||
|
@ -231,6 +243,7 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
:repositories, :enabled_modules
|
||||
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
|
||||
PRJ_ID = 3
|
||||
NUM_REV = 6
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(PRJ_ID)
|
||||
@repository = Repository::Darcs.create(
|
||||
:project => @project,
|
||||
:url => REPOSITORY_PATH,
|
||||
:log_encoding => 'UTF-8'
|
||||
)
|
||||
assert @repository
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Darcs'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Darcs'
|
||||
end
|
||||
end
|
||||
|
||||
def test_browse_root
|
||||
assert_equal 0, @repository.changesets.count
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 3
|
||||
assert_select 'tr.dir td.filename a', :text => 'images'
|
||||
assert_select 'tr.dir td.filename a', :text => 'sources'
|
||||
assert_select 'tr.file td.filename a', :text => 'README'
|
||||
end
|
||||
end
|
||||
|
||||
def test_browse_directory
|
||||
assert_equal 0, @repository.changesets.count
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['images'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 2
|
||||
assert_select 'tr.file td.filename a', :text => 'delete.png'
|
||||
assert_select 'tr.file td.filename a', :text => 'edit.png'
|
||||
end
|
||||
end
|
||||
|
||||
def test_browse_at_given_revision
|
||||
assert_equal 0, @repository.changesets.count
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['images'])[:param],
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 1
|
||||
assert_select 'tr.file td.filename a', :text => 'delete.png'
|
||||
end
|
||||
end
|
||||
|
||||
def test_changes
|
||||
assert_equal 0, @repository.changesets.count
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /edit.png/
|
||||
end
|
||||
|
||||
def test_diff
|
||||
assert_equal 0, @repository.changesets.count
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
# Full diff of changeset 5
|
||||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => 5,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
# Line 22 removed
|
||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_valid_repository
|
||||
@request.session[:user_id] = 1 # admin
|
||||
assert_equal 0, @repository.changesets.count
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
assert_nil @project.repository
|
||||
end
|
||||
|
||||
def test_destroy_invalid_repository
|
||||
@request.session[:user_id] = 1 # admin
|
||||
@project.repository.destroy
|
||||
@repository = Repository::Darcs.create!(
|
||||
:project => @project,
|
||||
:url => "/invalid",
|
||||
:log_encoding => 'UTF-8'
|
||||
)
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
assert_nil @project.repository
|
||||
end
|
||||
else
|
||||
puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
|
||||
def test_fake; assert true end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesFilesystemControllerTest < Redmine::RepositoryControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
|
@ -27,6 +29,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
PRJ_ID = 3
|
||||
|
||||
def setup
|
||||
super
|
||||
@ruby19_non_utf8_pass = Encoding.default_external.to_s != 'UTF-8'
|
||||
User.current = nil
|
||||
Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
|
||||
|
@ -78,6 +81,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
def test_show_no_extension
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['test'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -87,6 +91,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
def test_entry_download_no_extension
|
||||
get :raw, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['test'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -97,6 +102,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['japanese', 'euc-jp.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -106,8 +112,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
"when Encoding.default_external is not UTF-8. " +
|
||||
"Current value is '#{Encoding.default_external.to_s}'"
|
||||
else
|
||||
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||||
assert_select 'tr#L3 td.line-code', :text => /#{str_japanese}/
|
||||
assert_select 'tr#L3 td.line-code', :text => /日本語/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -117,6 +122,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
with_settings :repositories_encodings => enc do
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['japanese', 'utf-16.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -128,6 +134,7 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||
with_settings :file_max_size_displayed => 1 do
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['japanese', 'big-file.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
|
@ -26,20 +28,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||
PRJ_ID = 3
|
||||
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8')
|
||||
FELIX_HEX = "Felix Sch\xC3\xA4fer".force_encoding('UTF-8')
|
||||
NUM_REV = 28
|
||||
|
||||
## Git, Mercurial and CVS path encodings are binary.
|
||||
## Subversion supports URL encoding for path.
|
||||
## Redmine Mercurial adapter and extension use URL encoding.
|
||||
## Git accepts only binary path in command line parameter.
|
||||
## So, there is no way to use binary command line parameter in JRuby.
|
||||
JRUBY_SKIP = (RUBY_PLATFORM == 'java')
|
||||
JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
|
||||
|
||||
def setup
|
||||
@ruby19_non_utf8_pass = Encoding.default_external.to_s != 'UTF-8'
|
||||
super
|
||||
@not_utf8_external = Encoding.default_external.to_s != 'UTF-8'
|
||||
|
||||
User.current = nil
|
||||
@project = Project.find(PRJ_ID)
|
||||
|
@ -62,7 +55,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
:is_default => '0',
|
||||
:identifier => 'test-create',
|
||||
:report_last_commit => '1',
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -76,7 +69,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
:id => repository.id,
|
||||
:repository => {
|
||||
:report_last_commit => '0'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
@ -144,6 +137,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 'test_branch'
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -166,12 +160,13 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[
|
||||
[
|
||||
"tag00.lightweight",
|
||||
"tag01.annotated",
|
||||
].each do |t1|
|
||||
].each do |t1|
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => t1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -188,6 +183,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -206,6 +202,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images'])[:param],
|
||||
:rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
|
||||
}
|
||||
|
@ -220,6 +217,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
def test_changes
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -229,6 +227,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
def test_entry_show
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -236,23 +235,33 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
||||
end
|
||||
|
||||
def test_entry_show_should_render_pagination
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['README'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'ul.pages li.next', :text => /next/i
|
||||
assert_select 'ul.pages li.previous', :text => /previous/i
|
||||
end
|
||||
|
||||
def test_entry_show_latin_1
|
||||
if @ruby19_non_utf8_pass
|
||||
puts_ruby19_non_utf8_pass()
|
||||
if @not_utf8_external
|
||||
puts_pass_on_not_utf8
|
||||
elsif WINDOWS_PASS
|
||||
puts WINDOWS_SKIP_STR
|
||||
elsif JRUBY_SKIP
|
||||
puts JRUBY_SKIP_STR
|
||||
else
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -261,6 +270,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
def test_entry_download
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
|
@ -272,13 +282,13 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
def test_directory_entry
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2 a', :text => 'sources'
|
||||
assert_select 'table.entries tbody'
|
||||
assert_select 'div.contextual > a.icon-download', false
|
||||
|
||||
end
|
||||
|
||||
def test_diff
|
||||
|
@ -292,6 +302,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:type => dt
|
||||
}
|
||||
|
@ -312,6 +323,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:type => dt
|
||||
|
@ -336,6 +348,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
with_settings :default_language => 'en' do
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
}
|
||||
|
@ -345,6 +358,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
with_settings :default_language => 'fr' do
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
}
|
||||
|
@ -364,13 +378,14 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
|
||||
:rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /2f9c0091:61b685fb/
|
||||
assert_select 'form[action=?]', '/projects/subproject1/repository/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff'
|
||||
assert_select 'form[action=?]', "/projects/subproject1/repository/#{@repository.id}/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff"
|
||||
assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
end
|
||||
end
|
||||
|
@ -398,21 +413,22 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_diff_latin_1
|
||||
if @ruby19_non_utf8_pass
|
||||
puts_ruby19_non_utf8_pass()
|
||||
if @not_utf8_external
|
||||
puts_pass_on_not_utf8
|
||||
else
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r1,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table' do
|
||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/
|
||||
assert_select 'tbody td.diff_in', :text => /test-#{CHAR_1_HEX}.txt/
|
||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü.txt/
|
||||
assert_select 'tbody td.diff_in', :text => /test-Ü.txt/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -423,6 +439,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
def test_diff_should_show_filenames
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 'deff712f05a90d96edbd70facc47d944be5897e3',
|
||||
:type => 'inline'
|
||||
}
|
||||
|
@ -443,6 +460,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
@request.session[:user_id] = 1 # admin
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -450,6 +468,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_equal "inline", user.pref[:diff_type]
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:type => 'sbs'
|
||||
}
|
||||
|
@ -461,6 +480,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
def test_annotate
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -481,6 +501,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 'deff7',
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
|
@ -492,6 +513,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
with_settings :default_language => 'en' do
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -503,6 +525,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
with_settings :file_max_size_displayed => 1 do
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:rev => 'deff712f'
|
||||
}
|
||||
|
@ -511,6 +534,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['README'])[:param],
|
||||
:rev => '7234cb2'
|
||||
}
|
||||
|
@ -519,18 +543,17 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_annotate_latin_1
|
||||
if @ruby19_non_utf8_pass
|
||||
puts_ruby19_non_utf8_pass()
|
||||
if @not_utf8_external
|
||||
puts_pass_on_not_utf8
|
||||
elsif WINDOWS_PASS
|
||||
puts WINDOWS_SKIP_STR
|
||||
elsif JRUBY_SKIP
|
||||
puts JRUBY_SKIP_STR
|
||||
else
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
|
@ -538,7 +561,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
assert_select "a", :text => '57ca437c'
|
||||
assert_select "+ td.author", :text => "jsmith" do
|
||||
assert_select "+ td",
|
||||
:text => "test-#{CHAR_1_HEX}.txt"
|
||||
:text => "test-Ü.txt"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -551,13 +574,14 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1|
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash([" filename with a leading space.txt "])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
assert_select "+ td.revision" do
|
||||
assert_select "a", :text => '83ca5fd5'
|
||||
assert_select "+ td.author", :text => FELIX_HEX do
|
||||
assert_select "+ td.author", :text => "Felix Schäfer" do
|
||||
assert_select "+ td",
|
||||
:text => "And this is a file with a leading and trailing space..."
|
||||
end
|
||||
|
@ -572,9 +596,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :revisions, :params => {
|
||||
:id => PRJ_ID
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id
|
||||
}
|
||||
assert_select 'form[method=get][action=?]', '/projects/subproject1/repository/revision'
|
||||
assert_select 'form[method=get][action=?]', "/projects/subproject1/repository/#{@repository.id}/revision"
|
||||
end
|
||||
|
||||
def test_revision
|
||||
|
@ -585,6 +610,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -599,6 +625,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
['', ' ', nil].each do |r|
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r
|
||||
}
|
||||
assert_response 404
|
||||
|
@ -647,7 +674,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
|
||||
private
|
||||
|
||||
def puts_ruby19_non_utf8_pass
|
||||
def puts_pass_on_not_utf8
|
||||
puts "TODO: This test fails " +
|
||||
"when Encoding.default_external is not UTF-8. " +
|
||||
"Current value is '#{Encoding.default_external.to_s}'"
|
||||
|
@ -658,10 +685,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def with_cache(&block)
|
||||
before = ActionController::Base.perform_caching
|
||||
ActionController::Base.perform_caching = true
|
||||
block.call
|
||||
yield
|
||||
ActionController::Base.perform_caching = before
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,20 +19,18 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
|
||||
:repositories, :enabled_modules
|
||||
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
|
||||
CHAR_1_HEX = "\xc3\x9c"
|
||||
PRJ_ID = 3
|
||||
NUM_REV = 34
|
||||
|
||||
ruby19_non_utf8_pass = Encoding.default_external.to_s != 'UTF-8'
|
||||
|
||||
def setup
|
||||
super
|
||||
User.current = nil
|
||||
@project = Project.find(PRJ_ID)
|
||||
@repository = Repository::Mercurial.create(
|
||||
|
@ -40,13 +40,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
)
|
||||
assert @repository
|
||||
@diff_c_support = true
|
||||
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8')
|
||||
@tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||||
@branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||||
@branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
|
||||
end
|
||||
|
||||
if ruby19_non_utf8_pass
|
||||
if Encoding.default_external.to_s != 'UTF-8'
|
||||
puts "TODO: Mercurial functional test fails " +
|
||||
"when Encoding.default_external is not UTF-8. " +
|
||||
"Current value is '#{Encoding.default_external.to_s}'"
|
||||
|
@ -96,6 +92,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -119,6 +116,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[0, '0', '0885933ad4f6'].each do |r1|
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images'])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
|
@ -128,7 +126,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
assert_select 'tr', 1
|
||||
assert_select 'tr.file td.filename a', :text => 'delete.png'
|
||||
end
|
||||
|
||||
|
||||
assert_select 'table.changesets tbody' do
|
||||
assert_select 'tr'
|
||||
end
|
||||
|
@ -143,6 +141,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[13, '13', '3a330eb32958'].each do |r1|
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sql_escape', 'percent%dir'])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
|
@ -153,7 +152,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
assert_select 'tr.file td.filename a', :text => 'percent%file1.txt'
|
||||
assert_select 'tr.file td.filename a', :text => 'percentfile1.txt'
|
||||
end
|
||||
|
||||
|
||||
assert_select 'table.changesets tbody' do
|
||||
assert_select 'tr td.id a', :text => /^13:/
|
||||
assert_select 'tr td.id a', :text => /^11:/
|
||||
|
@ -171,6 +170,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[21, '21', 'adf805632193'].each do |r1|
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir'])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
|
@ -179,11 +179,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 4
|
||||
assert_select 'tr.file td.filename a', :text => "make-latin-1-file.rb"
|
||||
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-1.txt"
|
||||
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-2.txt"
|
||||
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}.txt"
|
||||
assert_select 'tr.file td.filename a', :text => "test-Ü-1.txt"
|
||||
assert_select 'tr.file td.filename a', :text => "test-Ü-2.txt"
|
||||
assert_select 'tr.file td.filename a', :text => "test-Ü.txt"
|
||||
end
|
||||
|
||||
|
||||
assert_select 'table.changesets tbody' do
|
||||
assert_select 'tr td.id a', :text => /^21:/
|
||||
assert_select 'tr td.id a', :text => /^20:/
|
||||
|
@ -212,16 +212,17 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[
|
||||
[
|
||||
'default',
|
||||
@branch_char_1,
|
||||
'branch-Ü-01',
|
||||
'branch (1)[2]&,%.-3_4',
|
||||
@branch_char_0,
|
||||
'branch-Ü-00',
|
||||
'test_branch.latin-1',
|
||||
'test-branch-00',
|
||||
].each do |bra|
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => bra
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -236,13 +237,14 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[
|
||||
@tag_char_1,
|
||||
[
|
||||
'tag-Ü-00',
|
||||
'tag_test.00',
|
||||
'tag-init-revision'
|
||||
].each do |tag|
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => tag
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -255,6 +257,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_changes
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -264,6 +267,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_entry_show
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -275,7 +279,8 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[21, '21', 'adf805632193'].each do |r1|
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -288,11 +293,12 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[27, '27', '7bbf4c738e71'].each do |r1|
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -300,6 +306,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_entry_download
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
|
@ -315,6 +322,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_directory_entry
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -332,6 +340,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r1,
|
||||
:type => dt
|
||||
}
|
||||
|
@ -355,6 +364,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r1,
|
||||
:rev_to => r2,
|
||||
:type => dt
|
||||
|
@ -372,12 +382,13 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r1,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table' do
|
||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/
|
||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü-2.txt/
|
||||
assert_select 'tbody td.diff_in', :text => /It is written in Python/
|
||||
end
|
||||
end
|
||||
|
@ -388,6 +399,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_diff_should_show_modified_filenames
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '400bb8672109',
|
||||
:type => 'inline'
|
||||
}
|
||||
|
@ -398,6 +410,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_diff_should_show_deleted_filenames
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 'b3a615152df8',
|
||||
:type => 'inline'
|
||||
}
|
||||
|
@ -408,6 +421,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
def test_annotate
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -428,6 +442,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
|
||||
}
|
||||
assert_response 404
|
||||
|
@ -442,6 +457,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[2, '400bb8672109', '400', 400].each do |r1|
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r1,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
|
@ -454,7 +470,8 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[21, '21', 'adf805632193'].each do |r1|
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -475,10 +492,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
[27, '7bbf4c738e71'].each do |r1|
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -492,12 +510,13 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
with_settings :default_language => "en" do
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'title',
|
||||
:text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -509,6 +528,7 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||
['', ' ', nil].each do |r|
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r
|
||||
}
|
||||
assert_response 404
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest
|
||||
tests RepositoriesController
|
||||
|
||||
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules,
|
||||
|
@ -28,6 +30,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
NUM_REV = 11
|
||||
|
||||
def setup
|
||||
super
|
||||
Setting.default_language = 'en'
|
||||
User.current = nil
|
||||
|
||||
|
@ -64,7 +67,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 1
|
||||
assert_select 'tr.dir td.filename a', :text => 'subversion_test'
|
||||
assert_select 'tr.dir td.filename a[href=?]', '/projects/subproject1/repository/show/subversion_test'
|
||||
assert_select 'tr.dir td.filename a[href=?]', "/projects/subproject1/repository/#{@repository.id}/show/subversion_test"
|
||||
end
|
||||
|
||||
assert_select 'table.changesets tbody' do
|
||||
|
@ -75,7 +78,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_select 'input[name=rev]'
|
||||
assert_select 'a', :text => 'Statistics'
|
||||
assert_select 'a', :text => 'Atom'
|
||||
assert_select 'a[href=?]', '/projects/subproject1/repository', :text => 'root'
|
||||
assert_select 'a[href=?]', "/projects/subproject1/repository/#{@repository.id}", :text => 'root'
|
||||
end
|
||||
|
||||
def test_show_non_default
|
||||
|
@ -101,6 +104,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -124,6 +128,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test'])[:param],
|
||||
:rev => 4
|
||||
}
|
||||
|
@ -146,6 +151,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -173,6 +179,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -195,6 +202,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -211,6 +219,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
with_settings :file_max_size_displayed => 0 do
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -222,10 +231,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
def test_entry_should_display_images
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'img[src=?]', '/projects/subproject1/repository/raw/subversion_test/folder/subfolder/rubylogo.gif'
|
||||
assert_select 'img[src=?]', "/projects/subproject1/repository/#{@repository.id}/raw/subversion_test/folder/subfolder/rubylogo.gif"
|
||||
end
|
||||
|
||||
def test_entry_at_given_revision
|
||||
|
@ -235,6 +245,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param],
|
||||
:rev => 2
|
||||
}
|
||||
|
@ -250,6 +261,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'zzz.c'])[:param]
|
||||
}
|
||||
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
||||
|
@ -262,6 +274,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :raw, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -275,6 +288,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -286,6 +300,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
def test_revision
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 2
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -293,9 +308,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_select 'ul' do
|
||||
assert_select 'li' do
|
||||
# link to the entry at rev 2
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo', :text => 'repo'
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/10/revisions/2/entry/test/some/path/in/the/repo', :text => 'repo'
|
||||
# link to partial diff
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo'
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/10/revisions/2/diff/test/some/path/in/the/repo'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -307,6 +322,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 'something_weird'
|
||||
}
|
||||
assert_response 404
|
||||
|
@ -316,6 +332,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
def test_invalid_revision_diff
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => '1',
|
||||
:rev_to => 'something_weird'
|
||||
}
|
||||
|
@ -331,6 +348,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
['', ' ', nil].each do |r|
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => r
|
||||
}
|
||||
assert_response 404
|
||||
|
@ -346,6 +364,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 10,
|
||||
:rev => 2
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -353,9 +372,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_select 'ul' do
|
||||
assert_select 'li' do
|
||||
# link to the entry at rev 2
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo', :text => 'repo'
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/10/revisions/2/entry/path/in/the/repo', :text => 'repo'
|
||||
# link to partial diff
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo'
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/repository/10/revisions/2/diff/path/in/the/repo'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -368,6 +387,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 3,
|
||||
:type => dt
|
||||
}
|
||||
|
@ -385,6 +405,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 5,
|
||||
:format => 'diff'
|
||||
}
|
||||
|
@ -401,6 +422,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
['inline', 'sbs'].each do |dt|
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 6,
|
||||
:rev_to => 2,
|
||||
:path => repository_path_hash(['subversion_test', 'folder'])[:param],
|
||||
|
@ -423,6 +445,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
@ -448,6 +471,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => @repository.id,
|
||||
:rev => 8,
|
||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -35,6 +37,24 @@ class RolesControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_index_should_show_warning_when_no_workflow_is_defined
|
||||
Role.find_by_name('Developer').workflow_rules.destroy_all
|
||||
Role.find_by_name('Anonymous').workflow_rules.destroy_all
|
||||
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_select 'table.roles' do
|
||||
# Manager
|
||||
assert_select 'tr.givable:nth-of-type(1) span.icon-warning', :count => 0
|
||||
# Developer
|
||||
assert_select 'tr.givable:nth-of-type(2) span.icon-warning', :text => /#{I18n.t(:text_role_no_workflow)}/
|
||||
# Reporter
|
||||
assert_select 'tr.givable:nth-of-type(3) span.icon-warning', :count => 0
|
||||
# No warnings for built-in roles such as Anonymous and Non-member
|
||||
assert_select 'tr.builtin span.icon-warning', :count => 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_new
|
||||
get :new
|
||||
assert_response :success
|
||||
|
@ -138,6 +158,7 @@ class RolesControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select 'input[name=?][value=?]', 'role[name]', 'Manager'
|
||||
assert_select 'select[name=?]', 'role[issues_visibility]'
|
||||
assert_select '#role-permissions-trackers table .delete_issues_shown'
|
||||
end
|
||||
|
||||
def test_edit_anonymous
|
||||
|
@ -146,6 +167,7 @@ class RolesControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select 'input[name=?]', 'role[name]', 0
|
||||
assert_select 'select[name=?]', 'role[issues_visibility]', 0
|
||||
assert_select '#role-permissions-trackers table .delete_issues_shown', 0
|
||||
end
|
||||
|
||||
def test_edit_invalid_should_respond_with_404
|
||||
|
@ -202,11 +224,11 @@ class RolesControllerTest < Redmine::ControllerTest
|
|||
def test_destroy_role_in_use
|
||||
delete :destroy, :params => {:id => 1}
|
||||
assert_redirected_to '/roles'
|
||||
assert_equal 'This role is in use and cannot be deleted.', flash[:error]
|
||||
assert_equal 'This role is in use and cannot be deleted.', flash[:error]
|
||||
assert_not_nil Role.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_get_permissions
|
||||
def test_permissions
|
||||
get :permissions
|
||||
assert_response :success
|
||||
|
||||
|
@ -214,10 +236,20 @@ class RolesControllerTest < Redmine::ControllerTest
|
|||
assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
|
||||
end
|
||||
|
||||
def test_post_permissions
|
||||
post :permissions, :params => {
|
||||
def test_permissions_with_filter
|
||||
get :permissions, :params => {
|
||||
:ids => ['2', '3']
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.permissions thead th', 3
|
||||
assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]'
|
||||
assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
|
||||
end
|
||||
|
||||
def test_update_permissions
|
||||
post :update_permissions, :params => {
|
||||
:permissions => {
|
||||
'0' => '',
|
||||
'1' => ['edit_issues'],
|
||||
'3' => ['add_issues', 'delete_issues']
|
||||
}
|
||||
|
@ -226,13 +258,18 @@ class RolesControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_equal [:edit_issues], Role.find(1).permissions
|
||||
assert_equal [:add_issues, :delete_issues], Role.find(3).permissions
|
||||
assert Role.find(2).permissions.empty?
|
||||
end
|
||||
|
||||
def test_clear_all_permissions
|
||||
post :permissions, :params => {:permissions => { '0' => '' }}
|
||||
assert_redirected_to '/roles'
|
||||
assert Role.find(1).permissions.empty?
|
||||
def test_update_permissions_should_not_update_other_roles
|
||||
assert_no_changes -> { Role.find(2).permissions } do
|
||||
assert_changes -> { Role.find(1).permissions } do
|
||||
post :update_permissions, :params => {
|
||||
:permissions => {
|
||||
'1' => ['edit_issues']
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_move_highest
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -42,10 +44,10 @@ class SearchControllerTest < Redmine::ControllerTest
|
|||
assert_select '#search-results dt.project a', :text => /eCookbook/
|
||||
end
|
||||
|
||||
def test_search_on_archived_project_should_return_404
|
||||
def test_search_on_archived_project_should_return_403
|
||||
Project.find(3).archive
|
||||
get :index, :params => {:id => 3}
|
||||
assert_response 404
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_search_on_invisible_project_by_user_should_be_denied
|
||||
|
@ -408,7 +410,7 @@ class SearchControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_results_should_be_escaped_once
|
||||
assert Issue.find(1).update_attributes(:subject => '<subject> escaped_once', :description => '<description> escaped_once')
|
||||
assert Issue.find(1).update(:subject => '<subject> escaped_once', :description => '<description> escaped_once')
|
||||
get :index, :params => {:q => 'escaped_once'}
|
||||
assert_response :success
|
||||
assert_select '#search-results' do
|
||||
|
@ -418,7 +420,7 @@ class SearchControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_keywords_should_be_highlighted
|
||||
assert Issue.find(1).update_attributes(:subject => 'subject highlighted', :description => 'description highlighted')
|
||||
assert Issue.find(1).update(:subject => 'subject highlighted', :description => 'description highlighted')
|
||||
get :index, :params => {:q => 'highlighted'}
|
||||
assert_response :success
|
||||
assert_select '#search-results' do
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -29,7 +31,8 @@ class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:workflows
|
||||
:workflows,
|
||||
:custom_fields, :custom_fields_trackers
|
||||
|
||||
def setup
|
||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :searchable => true, :trackers => Tracker.all}
|
||||
|
@ -56,7 +59,7 @@ class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
}
|
||||
|
||||
Member.where(:project_id => 1).each do |member|
|
||||
member.destroy unless @users_to_test.keys.include?(member.principal)
|
||||
member.destroy unless @users_to_test.key?(member.principal)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -19,7 +21,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
|
||||
class SettingsControllerTest < Redmine::ControllerTest
|
||||
fixtures :projects, :trackers, :issue_statuses, :issues,
|
||||
:users
|
||||
:users, :email_addresses
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
|
@ -194,11 +196,11 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||
assert_nil (mail = ActionMailer::Base.deliveries.last)
|
||||
end
|
||||
|
||||
|
||||
def test_get_plugin_settings
|
||||
ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins"))
|
||||
Redmine::Plugin.register :foo do
|
||||
settings :partial => "foo_plugin/foo_plugin_settings"
|
||||
directory 'test/fixtures/plugins/foo_plugin'
|
||||
end
|
||||
Setting.plugin_foo = {'sample_setting' => 'Plugin setting value'}
|
||||
|
||||
|
@ -218,7 +220,9 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_get_non_configurable_plugin_settings
|
||||
Redmine::Plugin.register(:foo) {}
|
||||
Redmine::Plugin.register(:foo) do
|
||||
directory 'test/fixtures/plugins/foo_plugin'
|
||||
end
|
||||
|
||||
get :plugin, :params => {:id => 'foo'}
|
||||
assert_response 404
|
||||
|
@ -231,6 +235,7 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||
Redmine::Plugin.register(:foo) do
|
||||
settings :partial => 'not blank', # so that configurable? is true
|
||||
:default => {'sample_setting' => 'Plugin setting value'}
|
||||
directory 'test/fixtures/plugins/foo_plugin'
|
||||
end
|
||||
|
||||
post :plugin, :params => {
|
||||
|
@ -246,6 +251,7 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||
Redmine::Plugin.register(:foo) do
|
||||
settings :partial => 'not blank', # so that configurable? is true
|
||||
:default => {'sample_setting' => 'Plugin setting value'}
|
||||
directory 'test/fixtures/plugins/foo_plugin'
|
||||
end
|
||||
|
||||
post :plugin, :params => {
|
||||
|
@ -257,7 +263,9 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_post_non_configurable_plugin_settings
|
||||
Redmine::Plugin.register(:foo) {}
|
||||
Redmine::Plugin.register(:foo) do
|
||||
directory 'test/fixtures/plugins/foo_plugin'
|
||||
end
|
||||
|
||||
post :plugin, :params => {
|
||||
:id => 'foo',
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -24,10 +25,15 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
:trackers, :enumerations, :issue_statuses,
|
||||
:custom_fields, :custom_values,
|
||||
:projects_trackers, :custom_fields_trackers,
|
||||
:custom_fields_projects
|
||||
:custom_fields_projects, :issue_categories, :versions
|
||||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
super
|
||||
Setting.default_language = 'en'
|
||||
end
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 3
|
||||
get :new
|
||||
|
@ -40,6 +46,8 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
# blank option for project
|
||||
assert_select 'option[value=""]'
|
||||
end
|
||||
assert_select 'label[for=?]', 'time_entry_user_id', 0
|
||||
assert_select 'select[name=?]', 'time_entry[user_id]', 0
|
||||
end
|
||||
|
||||
def test_new_with_project_id
|
||||
|
@ -97,6 +105,40 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_select 'option', :text => 'Inactive Activity', :count => 0
|
||||
end
|
||||
|
||||
def test_new_should_show_user_select_if_user_has_permission
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :new, :params => {:project_id => 1}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'time_entry[user_id]' do
|
||||
assert_select 'option', 3
|
||||
assert_select 'option[value=?]', '2', 2
|
||||
assert_select 'option[value=?]', '3', 1
|
||||
# locked members should not be available
|
||||
assert_select 'option[value=?]', '4', 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_user_select_should_include_current_user_if_is_logged
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :new, :params => {:project_id => 1}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'time_entry[user_id]' do
|
||||
assert_select 'option[value=?]', '1', :text => '<< me >>'
|
||||
assert_select 'option[value=?]', '1', :text => 'Redmine Admin'
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_should_not_show_user_select_if_user_does_not_have_permission
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :new, :params => {:project_id => 1}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'time_entry[user_id]', 0
|
||||
end
|
||||
|
||||
def test_post_new_as_js_should_update_activity_options
|
||||
@request.session[:user_id] = 3
|
||||
post :new, :params => {:time_entry => {:project_id => 1}, :format => 'js'}
|
||||
|
@ -110,6 +152,11 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
|
||||
assert_select 'form[action=?]', '/time_entries/2'
|
||||
|
||||
# Time entry user should be shown as text
|
||||
# for user without permission to log time for other users
|
||||
assert_select 'label[for=?]', 'time_entry_user_id', 1
|
||||
assert_select 'a.user.active', :text => 'Redmine Admin'
|
||||
end
|
||||
|
||||
def test_get_edit_with_an_existing_time_entry_with_inactive_activity
|
||||
|
@ -133,6 +180,56 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_select 'select[name=?]', 'time_entry[project_id]'
|
||||
end
|
||||
|
||||
def test_get_edit_should_validate_back_url
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :edit, :params => {:id => 2, :project_id => nil, :back_url => '/valid'}
|
||||
assert_response :success
|
||||
assert_select 'a[href=?]', '/valid', {:text => 'Cancel'}
|
||||
|
||||
get :edit, :params => {:id => 2, :project_id => nil, :back_url => 'invalid'}
|
||||
assert_response :success
|
||||
assert_select 'a[href=?]', 'invalid', {:text => 'Cancel', :count => 0}
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/time_entries', {:text => 'Cancel'}
|
||||
end
|
||||
|
||||
def test_get_edit_with_an_existing_time_entry_with_locked_user
|
||||
user = User.find(3)
|
||||
entry = TimeEntry.generate!(:user_id => user.id, :comments => "Time entry on a future locked user")
|
||||
entry.save!
|
||||
|
||||
user.status = User::STATUS_LOCKED
|
||||
user.save!
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :edit, :params => {
|
||||
:id => entry.id
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'time_entry[user_id]' do
|
||||
# User with id 3 should be selected even if it's locked
|
||||
assert_select 'option[value="3"][selected=selected]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_edit_for_other_user
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'time_entry[user_id]' do
|
||||
assert_select 'option[value="2"][selected=selected]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_create
|
||||
@request.session[:user_id] = 3
|
||||
assert_difference 'TimeEntry.count' do
|
||||
|
@ -263,6 +360,49 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert !response.body.include?('issue_that_is_not_visible')
|
||||
end
|
||||
|
||||
def test_create_for_other_user
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:time_entry => {:comments => 'Some work on TimelogControllerTest',
|
||||
# Not the default activity
|
||||
:activity_id => '11',
|
||||
:spent_on => '2008-03-14',
|
||||
:issue_id => '1',
|
||||
:hours => '7.3',
|
||||
:user_id => '3'
|
||||
}
|
||||
}
|
||||
|
||||
assert_redirected_to '/projects/ecookbook/time_entries'
|
||||
|
||||
t = TimeEntry.last
|
||||
assert_equal 3, t.user_id
|
||||
assert_equal 2, t.author_id
|
||||
end
|
||||
|
||||
def test_create_for_other_user_should_fail_without_permission
|
||||
Role.find_by_name('Manager').remove_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:time_entry => {:comments => 'Some work on TimelogControllerTest',
|
||||
# Not the default activity
|
||||
:activity_id => '11',
|
||||
:spent_on => '2008-03-14',
|
||||
:issue_id => '1',
|
||||
:hours => '7.3',
|
||||
:user_id => '3'
|
||||
}
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select_error /User is invalid/
|
||||
end
|
||||
|
||||
def test_create_and_continue_at_project_level
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'TimeEntry.count' do
|
||||
|
@ -528,6 +668,41 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_select_error /Issue is invalid/
|
||||
end
|
||||
|
||||
def test_update_should_fail_when_changing_user_without_permission
|
||||
Role.find_by_name('Manager').remove_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
put :update, :params => {
|
||||
:id => 3,
|
||||
:time_entry => {
|
||||
:user_id => '3'
|
||||
}
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select_error /User is invalid/
|
||||
end
|
||||
|
||||
def test_update_should_allow_updating_existing_entry_logged_on_a_locked_user
|
||||
entry = TimeEntry.generate!(:user_id => 2, :hours => 4, :comments => "Time entry on a future locked user")
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
put :update, :params => {
|
||||
:id => entry.id,
|
||||
:time_entry => {
|
||||
:hours => '6'
|
||||
}
|
||||
}
|
||||
|
||||
assert_response :redirect
|
||||
|
||||
entry.reload
|
||||
# Ensure user didn't change
|
||||
assert_equal 2, entry.user_id
|
||||
assert_equal 6.0, entry.hours
|
||||
end
|
||||
|
||||
def test_get_bulk_edit
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
|
@ -536,10 +711,15 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select 'ul#bulk-selection' do
|
||||
assert_select 'li', 2
|
||||
assert_select 'li a', :text => '03/23/2007 - eCookbook: 4.25 hours'
|
||||
assert_select 'li a', :text => '03/23/2007 - eCookbook: 4.25 hours (John Smith)'
|
||||
end
|
||||
|
||||
assert_select 'form#bulk_edit_form[action=?]', '/time_entries/bulk_update' do
|
||||
assert_select 'select[name=?]', 'time_entry[project_id]'
|
||||
|
||||
# Clear issue checkbox
|
||||
assert_select 'input[name=?][value=?]', 'time_entry[issue_id]', 'none'
|
||||
|
||||
# System wide custom field
|
||||
assert_select 'select[name=?]', 'time_entry[custom_field_values][10]'
|
||||
|
||||
|
@ -558,6 +738,34 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bulk_edit_on_different_projects_should_propose_only_common_activites
|
||||
project = Project.find(3)
|
||||
TimeEntryActivity.create!(:name => 'QA', :project => project, :parent => TimeEntryActivity.find_by_name('QA'), :active => false)
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :bulk_edit, :params => {:ids => [1, 2, 4]}
|
||||
assert_response :success
|
||||
assert_select 'select[id=?]', 'time_entry_activity_id' do
|
||||
assert_select 'option', 3
|
||||
assert_select 'option[value=?]', '11', 0, :text => 'QA'
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_bulk_edit_on_same_project_should_propose_project_activities
|
||||
project = Project.find(1)
|
||||
override_activity = TimeEntryActivity.create!({:name => "QA override", :parent => TimeEntryActivity.find_by_name("QA"), :project => project})
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :bulk_edit, :params => {:ids => [1, 2]}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[id=?]', 'time_entry_activity_id' do
|
||||
assert_select 'option', 4
|
||||
assert_select 'option[value=?]', override_activity.id.to_s, :text => 'QA override'
|
||||
end
|
||||
end
|
||||
|
||||
def test_bulk_edit_with_edit_own_time_entries_permission
|
||||
@request.session[:user_id] = 2
|
||||
Role.find_by_name('Manager').remove_permission! :edit_time_entries
|
||||
|
@ -705,6 +913,50 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select '.total-for-hours', :text => 'Hours: 162.90'
|
||||
assert_select 'form#query_form[action=?]', '/time_entries'
|
||||
|
||||
assert_equal ['Project', 'Date', 'User', 'Activity', 'Issue', 'Comment', 'Hours'], columns_in_list
|
||||
assert_select '.query-totals>span', 1
|
||||
end
|
||||
|
||||
def test_index_with_default_query_setting
|
||||
with_settings :time_entry_list_defaults => {'column_names' => %w(spent_on issue user hours), 'totalable_names' => []} do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
assert_select 'table.time-entries thead' do
|
||||
assert_select 'th.project'
|
||||
assert_select 'th.spent_on'
|
||||
assert_select 'th.issue'
|
||||
assert_select 'th.user'
|
||||
assert_select 'th.hours'
|
||||
end
|
||||
assert_select 'table.time-entries tbody' do
|
||||
assert_select 'td.project'
|
||||
assert_select 'td.spent_on'
|
||||
assert_select 'td.issue'
|
||||
assert_select 'td.user'
|
||||
assert_select 'td.hours'
|
||||
end
|
||||
assert_equal ['Project', 'Date', 'Issue', 'User', 'Hours'], columns_in_list
|
||||
end
|
||||
|
||||
def test_index_with_default_query_setting_using_custom_field
|
||||
field = TimeEntryCustomField.create!(:name => 'Foo', :field_format => 'int')
|
||||
|
||||
with_settings :time_entry_list_defaults => {
|
||||
'column_names' => ["spent_on", "user", "hours", "cf_#{field.id}"],
|
||||
'totalable_names' => ["hours", "cf_#{field.id}"]
|
||||
} do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
assert_equal ['Project', 'Date', 'User', 'Hours', 'Foo'], columns_in_list
|
||||
|
||||
assert_select '.total-for-hours'
|
||||
assert_select ".total-for-cf-#{field.id}"
|
||||
assert_select '.query-totals>span', 2
|
||||
end
|
||||
|
||||
def test_index_all_projects_should_show_log_time_link
|
||||
|
@ -852,9 +1104,9 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_index_should_sort_by_spent_on_and_created_on
|
||||
t1 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:00:00', :activity_id => 10)
|
||||
t2 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10)
|
||||
t3 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10)
|
||||
t1 = TimeEntry.create!(:author => User.find(1), :user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:00:00', :activity_id => 10)
|
||||
t2 = TimeEntry.create!(:author => User.find(1), :user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10)
|
||||
t3 = TimeEntry.create!(:author => User.find(1), :user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10)
|
||||
|
||||
get :index, :params => {
|
||||
:project_id => 1,
|
||||
|
@ -904,6 +1156,25 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||
end
|
||||
|
||||
def test_index_with_project_status_filter
|
||||
project = Project.find(3)
|
||||
project.close
|
||||
project.save
|
||||
|
||||
get :index, :params => {
|
||||
:set_filter => 1,
|
||||
:f => ['project.status'],
|
||||
:op => {'project.status' => '='},
|
||||
:v => {'project.status' => ['1']}
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
time_entries = css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||
assert_include '1', time_entries
|
||||
assert_not_include '4', time_entries
|
||||
end
|
||||
|
||||
def test_index_with_issue_status_column
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :status_id => 4)
|
||||
entry = TimeEntry.generate!(:issue => issue)
|
||||
|
@ -912,6 +1183,8 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
:c => %w(project spent_on issue comments hours issue.status)
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'th.issue-status'
|
||||
assert_select 'td.issue-status', :text => issue.status.name
|
||||
end
|
||||
|
||||
|
@ -976,6 +1249,97 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_equal Tracker.where(:id => [1, 2, 3]).sorted.pluck(:name), values
|
||||
end
|
||||
|
||||
def test_index_with_issue_category_filter
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:f => ['issue.category_id'],
|
||||
:op => {'issue.category_id' => '='},
|
||||
:v => {'issue.category_id' => ['1']}
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal ['1', '2'], css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||
end
|
||||
|
||||
def test_index_with_issue_category_column
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:c => %w(project spent_on issue comments hours issue.category)
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'td.issue-category', :text => 'Printing'
|
||||
end
|
||||
|
||||
def test_index_with_issue_fixed_version_column
|
||||
issue = Issue.find(1)
|
||||
issue.fixed_version = Version.find(3)
|
||||
issue.save!
|
||||
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:c => %w(project spent_on issue comments hours issue.fixed_version)
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'td.issue-fixed_version', :text => '2.0'
|
||||
end
|
||||
|
||||
def test_index_with_author_filter
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:f => ['author_id'],
|
||||
:op => {'author_id' => '='},
|
||||
:v => {'author_id' => ['2']}
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal ['1'], css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||
end
|
||||
|
||||
def test_index_with_author_column
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:c => %w(project spent_on issue comments hours author)
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'td.author', :text => 'Redmine Admin'
|
||||
end
|
||||
|
||||
def test_index_with_issue_category_sort
|
||||
issue = Issue.find(3)
|
||||
issue.category_id = 2
|
||||
issue.save!
|
||||
|
||||
get :index, :params => {
|
||||
:c => ["hours", 'issue.category'],
|
||||
:sort => 'issue.category'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# Make sure that values are properly sorted
|
||||
values = css_select("td.issue-category").map(&:text).reject(&:blank?)
|
||||
assert_equal ['Printing', 'Printing', 'Recipes'], values
|
||||
end
|
||||
|
||||
def test_index_with_issue_fixed_version_sort
|
||||
issue = Issue.find(1)
|
||||
issue.fixed_version = Version.find(3)
|
||||
issue.save!
|
||||
|
||||
TimeEntry.generate!(:issue => Issue.find(12))
|
||||
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:c => ["hours", 'issue.fixed_version'],
|
||||
:sort => 'issue.fixed_version'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
# Make sure that values are properly sorted
|
||||
values = css_select("td.issue-fixed_version").map(&:text).reject(&:blank?)
|
||||
assert_equal ['1.0', '2.0', '2.0'], values
|
||||
end
|
||||
|
||||
def test_index_with_filter_on_issue_custom_field
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
|
||||
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
|
||||
|
@ -1024,7 +1388,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
:sort => field_name
|
||||
}
|
||||
assert_response :success
|
||||
assert_select "th a.sort", :text => 'String Field'
|
||||
assert_select "th.cf_#{field.id} a.sort", :text => 'String Field'
|
||||
|
||||
# Make sure that values are properly sorted
|
||||
values = css_select("td.#{field_name}").map(&:text).reject(&:blank?)
|
||||
|
@ -1096,7 +1460,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
with_settings :date_format => '%m/%d/%Y' do
|
||||
get :index, :params => {:format => 'csv'}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', response.content_type
|
||||
assert_equal 'text/csv', response.media_type
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1104,7 +1468,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
with_settings :date_format => '%m/%d/%Y' do
|
||||
get :index, :params => {:project_id => 1, :format => 'csv'}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', response.content_type
|
||||
assert_equal 'text/csv', response.media_type
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1117,4 +1481,46 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
assert_not_nil line
|
||||
assert_include "#{issue.tracker} #1: #{issue.subject}", line
|
||||
end
|
||||
|
||||
def test_index_csv_should_fill_issue_column_with_issue_id_if_issue_that_is_not_visible
|
||||
@request.session[:user_id] = 3
|
||||
issue = Issue.generate!(:author_id => 1, :is_private => true)
|
||||
entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column content test")
|
||||
|
||||
get :index, :params => {:format => 'csv'}
|
||||
assert_not issue.visible?
|
||||
line = response.body.split("\n").detect {|l| l.include?(entry.comments)}
|
||||
assert_not_nil line
|
||||
assert_not_include "#{issue.tracker} ##{issue.id}: #{issue.subject}", line
|
||||
assert_include "##{issue.id}", line
|
||||
end
|
||||
|
||||
def test_index_grouped_by_created_on
|
||||
skip unless TimeEntryQuery.new.groupable_columns.detect {|c| c.name == :created_on}
|
||||
|
||||
get :index, :params => {
|
||||
:set_filter => 1,
|
||||
:group_by => 'created_on'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'tr.group span.name', :text => '03/23/2007' do
|
||||
assert_select '+ span.count', :text => '2'
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_with_inline_issue_long_text_custom_field_column
|
||||
field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :full_width_layout => '1',
|
||||
:tracker_ids => [1], :is_for_all => true)
|
||||
issue = Issue.find(1)
|
||||
issue.custom_field_values = {field.id => 'This is a long text'}
|
||||
issue.save!
|
||||
|
||||
get :index, :params => {
|
||||
:set_filter => 1,
|
||||
:c => ['subject', 'description', "issue.cf_#{field.id}"]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select "td.issue_cf_#{field.id}", :text => 'This is a long text'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -20,48 +22,21 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
tests TimelogController
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:users, :email_addresses,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issue_statuses,
|
||||
:issues, :issue_statuses,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:workflows
|
||||
|
||||
def setup
|
||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
||||
@fields = []
|
||||
@fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => true)))
|
||||
@fields << (@field2 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 2', :visible => false, :role_ids => [1, 2])))
|
||||
@fields << (@field3 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 3', :visible => false, :role_ids => [1, 3])))
|
||||
@issue = Issue.generate!(
|
||||
:author_id => 1,
|
||||
:project_id => 1,
|
||||
:tracker_id => 1,
|
||||
:custom_field_values => {@field1.id => 'Value0', @field2.id => 'Value1', @field3.id => 'Value2'}
|
||||
)
|
||||
TimeEntry.generate!(:issue => @issue)
|
||||
|
||||
@user_with_role_on_other_project = User.generate!
|
||||
User.add_to_project(@user_with_role_on_other_project, Project.find(2), Role.find(3))
|
||||
|
||||
@users_to_test = {
|
||||
User.find(1) => [@field1, @field2, @field3],
|
||||
User.find(3) => [@field1, @field2],
|
||||
@user_with_role_on_other_project => [@field1], # should see field1 only on Project 1
|
||||
User.generate! => [@field1],
|
||||
User.anonymous => [@field1]
|
||||
}
|
||||
|
||||
Member.where(:project_id => 1).each do |member|
|
||||
member.destroy unless @users_to_test.keys.include?(member.principal)
|
||||
end
|
||||
end
|
||||
:time_entries, :enumerations,
|
||||
:workflows,
|
||||
:custom_fields, :custom_values, :custom_fields_trackers
|
||||
|
||||
def test_index_should_show_visible_custom_fields_only
|
||||
prepare_test_data
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :index, :params => {
|
||||
|
@ -80,6 +55,8 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_index_as_csv_should_show_visible_custom_fields_only
|
||||
prepare_test_data
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :index, :params => {
|
||||
|
@ -99,8 +76,11 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
end
|
||||
|
||||
def test_index_with_partial_custom_field_visibility_should_show_visible_custom_fields_only
|
||||
prepare_test_data
|
||||
|
||||
Issue.delete_all
|
||||
TimeEntry.delete_all
|
||||
CustomValue.delete_all
|
||||
p1 = Project.generate!
|
||||
p2 = Project.generate!
|
||||
user = User.generate!
|
||||
|
@ -127,4 +107,53 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||
assert_select 'td', :text => "ValueC"
|
||||
assert_select 'td', :text => "ValueB", :count => 0
|
||||
end
|
||||
|
||||
def test_edit_should_not_show_custom_fields_not_visible_for_user
|
||||
time_entry_cf = TimeEntryCustomField.find(10)
|
||||
time_entry_cf.visible = false
|
||||
time_entry_cf.role_ids = [2]
|
||||
time_entry_cf.save!
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :edit, :params => {
|
||||
:id => 3,
|
||||
:project_id => 1
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'select#time_entry_custom_field_values_10', 0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepare_test_data
|
||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
||||
@fields = []
|
||||
@fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => true)))
|
||||
@fields << (@field2 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 2', :visible => false, :role_ids => [1, 2])))
|
||||
@fields << (@field3 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 3', :visible => false, :role_ids => [1, 3])))
|
||||
@issue = Issue.generate!(
|
||||
:author_id => 1,
|
||||
:project_id => 1,
|
||||
:tracker_id => 1,
|
||||
:custom_field_values => {@field1.id => 'Value0', @field2.id => 'Value1', @field3.id => 'Value2'}
|
||||
)
|
||||
TimeEntry.generate!(:issue => @issue)
|
||||
|
||||
@user_with_role_on_other_project = User.generate!
|
||||
User.add_to_project(@user_with_role_on_other_project, Project.find(2), Role.find(3))
|
||||
|
||||
@users_to_test = {
|
||||
User.find(1) => [@field1, @field2, @field3],
|
||||
User.find(3) => [@field1, @field2],
|
||||
@user_with_role_on_other_project => [@field1], # should see field1 only on Project 1
|
||||
User.generate! => [@field1],
|
||||
User.anonymous => [@field1]
|
||||
}
|
||||
|
||||
Member.where(:project_id => 1).each do |member|
|
||||
member.destroy unless @users_to_test.key?(member.principal)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -18,7 +19,7 @@
|
|||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
||||
class TimelogReportTest < Redmine::ControllerTest
|
||||
tests TimelogController
|
||||
|
||||
fixtures :projects, :enabled_modules, :roles, :members, :member_roles,
|
||||
|
@ -37,6 +38,18 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
def test_report_at_project_level
|
||||
get :report, :params => {:project_id => 'ecookbook'}
|
||||
assert_response :success
|
||||
|
||||
# query form
|
||||
assert_select 'form#query_form' do
|
||||
assert_select 'div#query_form_with_buttons.hide-when-print' do
|
||||
assert_select 'div#query_form_content' do
|
||||
assert_select 'fieldset#filters.collapsible'
|
||||
assert_select 'fieldset#options'
|
||||
end
|
||||
assert_select 'p.buttons'
|
||||
end
|
||||
end
|
||||
|
||||
assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report'
|
||||
end
|
||||
|
||||
|
@ -59,6 +72,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
|
||||
assert_response :success
|
||||
assert_select 'tr.total td:last', :text => '8.65'
|
||||
assert_select 'tr td.name a[href=?]', '/projects/ecookbook', :text => 'eCookbook'
|
||||
end
|
||||
|
||||
def test_report_all_time
|
||||
|
@ -86,6 +100,20 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
assert_select 'tr.total td:last', :text => '162.90'
|
||||
end
|
||||
|
||||
def test_report_should_show_locked_users
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
user = User.find(2)
|
||||
user.status = User::STATUS_LOCKED
|
||||
user.save
|
||||
|
||||
get :report, :params => {:project_id => 1, :columns => 'month', :criteria => ["user", "activity"]}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'td.name a.user.active[href=?]', '/users/1', 1, :text => 'Redmine Admin'
|
||||
assert_select 'td.name a.user.locked[href=?]', '/users/2', 1, :text => 'John Smith'
|
||||
end
|
||||
|
||||
def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
|
||||
field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2'])
|
||||
entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today)
|
||||
|
@ -108,6 +136,18 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_hidden_custom_fields_should_not_be_proposed
|
||||
TimeEntryCustomField.create!(name: 'shown', field_format: 'list', possible_values: ['value1', 'value2'], visible: true)
|
||||
TimeEntryCustomField.create!(name: 'Hidden', field_format: 'list', possible_values: ['value1', 'value2'], visible: false, role_ids: [3])
|
||||
|
||||
get :report, :params => {:project_id => 1}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'criteria[]' do
|
||||
assert_select 'option', :text => 'Shown'
|
||||
assert_select 'option', :text => 'Hidden', :count => 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_report_one_day
|
||||
get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]}
|
||||
assert_response :success
|
||||
|
@ -193,7 +233,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
:format => "csv"
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
assert_equal 'Project,User,Activity,2007-3,2007-4,Total time', lines.first
|
||||
|
@ -207,23 +247,37 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
:columns => 'month',
|
||||
:from => "2007-01-01",
|
||||
:to => "2007-06-30",
|
||||
:criteria => ["project", "user", "activity"],
|
||||
:criteria => ["project", "user", "cf_10"],
|
||||
:format => "csv"
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
assert_equal 'Project,User,Activity,2007-3,2007-4,Total time', lines.first
|
||||
assert_equal 'Project,User,Overtime,2007-3,2007-4,Total time', lines.first
|
||||
# Total row
|
||||
assert_equal 'Total time,"","",154.25,8.65,162.90', lines.last
|
||||
end
|
||||
|
||||
def test_report_csv_should_fill_issue_criteria_with_tracker_id_and_subject
|
||||
get :report, :params => {
|
||||
:project_id => 1,
|
||||
:columns => 'month',
|
||||
:from => "2007-01-01",
|
||||
:to => "2007-06-30",
|
||||
:criteria => ["issue"],
|
||||
:format => "csv"
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
lines = @response.body.chomp.split("\n")
|
||||
assert lines.detect {|line| line.include?('Bug #1: Cannot print recipes')}
|
||||
end
|
||||
|
||||
def test_csv_big_5
|
||||
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
|
||||
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
|
||||
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5')
|
||||
user = User.find_by_id(3)
|
||||
user.firstname = str_utf8
|
||||
user.firstname = "一月"
|
||||
user.lastname = "test-lastname"
|
||||
assert user.save
|
||||
comments = "test_csv_big_5"
|
||||
|
@ -250,27 +304,25 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||||
s2 = "\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||||
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||||
s2 = (+"\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||||
assert_equal s1, lines.first
|
||||
# Total row
|
||||
assert_equal "#{str_big5} #{user.lastname},7.30,7.30", lines[1]
|
||||
assert_equal "#{s2},7.30,7.30", lines[2]
|
||||
|
||||
str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)".force_encoding('UTF-8')
|
||||
assert_equal str_tw, l(:general_lang_name)
|
||||
assert_equal 'Chinese/Traditional (繁體中文)', l(:general_lang_name)
|
||||
assert_equal 'Big5', l(:general_csv_encoding)
|
||||
assert_equal ',', l(:general_csv_separator)
|
||||
assert_equal '.', l(:general_csv_decimal_separator)
|
||||
end
|
||||
|
||||
def test_csv_cannot_convert_should_be_replaced_big_5
|
||||
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
|
||||
user = User.find_by_id(3)
|
||||
user.firstname = str_utf8
|
||||
user.firstname = "以内"
|
||||
user.lastname = "test-lastname"
|
||||
assert user.save
|
||||
comments = "test_replaced"
|
||||
|
@ -297,13 +349,13 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||||
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||||
assert_equal s1, lines.first
|
||||
# Total row
|
||||
s2 = "\xa5H?".force_encoding('Big5')
|
||||
s2 = (+"\xa5H?").force_encoding('Big5')
|
||||
assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1]
|
||||
end
|
||||
|
||||
|
@ -332,18 +384,17 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest
|
|||
:format => "csv"
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
s1 = "Utilisateur;2011-11-11;Temps total".force_encoding('ISO-8859-1')
|
||||
s2 = "Temps total".force_encoding('ISO-8859-1')
|
||||
s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1')
|
||||
s2 = (+"Temps total").force_encoding('ISO-8859-1')
|
||||
assert_equal s1, lines.first
|
||||
# Total row
|
||||
assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1]
|
||||
assert_equal "#{s2};7,30;7,30", lines[2]
|
||||
|
||||
str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8')
|
||||
assert_equal str_fr, l(:general_lang_name)
|
||||
assert_equal 'French (Français)', l(:general_lang_name)
|
||||
assert_equal 'ISO-8859-1', l(:general_csv_encoding)
|
||||
assert_equal ';', l(:general_csv_separator)
|
||||
assert_equal ',', l(:general_csv_decimal_separator)
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -47,6 +49,9 @@ class TrackersControllerTest < Redmine::ControllerTest
|
|||
get :new
|
||||
assert_response :success
|
||||
assert_select 'input[name=?]', 'tracker[name]'
|
||||
assert_select 'select[name=?]', 'tracker[default_status_id]' do
|
||||
assert_select 'option[value=?][selected=selected]', IssueStatus.sorted.first.id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def test_create
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -64,11 +66,55 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_index_csv
|
||||
with_settings :default_language => 'en' do
|
||||
get :index, :params => { :format => 'csv' }
|
||||
assert_response :success
|
||||
|
||||
assert_equal User.logged.status(1).count, response.body.chomp.split("\n").size - 1
|
||||
assert_include 'active', response.body
|
||||
assert_not_include 'locked', response.body
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_csv_with_status_filter
|
||||
with_settings :default_language => 'en' do
|
||||
get :index, :params => { :status => 3, :format => 'csv' }
|
||||
assert_response :success
|
||||
|
||||
assert_equal User.logged.status(3).count, response.body.chomp.split("\n").size - 1
|
||||
assert_include 'locked', response.body
|
||||
assert_not_include 'active', response.body
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_csv_with_name_filter
|
||||
get :index, :params => {:name => 'John', :format => 'csv'}
|
||||
assert_response :success
|
||||
|
||||
assert_equal User.logged.like('John').count, response.body.chomp.split("\n").size - 1
|
||||
assert_include 'John', response.body
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
end
|
||||
|
||||
def test_index_csv_with_group_filter
|
||||
get :index, :params => {:group_id => '10', :format => 'csv'}
|
||||
assert_response :success
|
||||
|
||||
assert_equal Group.find(10).users.count, response.body.chomp.split("\n").size - 1
|
||||
assert_equal 'text/csv', @response.media_type
|
||||
end
|
||||
|
||||
def test_show
|
||||
@request.session[:user_id] = nil
|
||||
get :show, :params => {:id => 2}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /John Smith/
|
||||
|
||||
# groups block should not be rendeder for users which are not part of any group
|
||||
assert_select 'div#groups', 0
|
||||
end
|
||||
|
||||
def test_show_should_display_visible_custom_fields
|
||||
|
@ -77,7 +123,7 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
get :show, :params => {:id => 2}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'li', :text => /Phone number/
|
||||
assert_select 'li[class=?]', 'cf_4', :text => /Phone number/
|
||||
end
|
||||
|
||||
def test_show_should_not_display_hidden_custom_fields
|
||||
|
@ -127,8 +173,20 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
get :show, :params => {:id => 2}
|
||||
assert_response :success
|
||||
|
||||
# membership of private project admin can see
|
||||
assert_select 'li a', :text => "OnlineStore"
|
||||
assert_select 'table.list.projects>tbody' do
|
||||
assert_select 'tr:nth-of-type(1)' do
|
||||
assert_select 'td:nth-of-type(1)>span>a', :text => 'eCookbook'
|
||||
assert_select 'td:nth-of-type(2)', :text => 'Manager'
|
||||
end
|
||||
assert_select 'tr:nth-of-type(2)' do
|
||||
assert_select 'td:nth-of-type(1)>span>a', :text => 'Private child of eCookbook'
|
||||
assert_select 'td:nth-of-type(2)', :text => 'Manager'
|
||||
end
|
||||
assert_select 'tr:nth-of-type(3)' do
|
||||
assert_select 'td:nth-of-type(1)>span>a', :text => 'OnlineStore'
|
||||
assert_select 'td:nth-of-type(2)', :text => 'Developer'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_current_should_require_authentication
|
||||
|
@ -144,6 +202,37 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
assert_select 'h2', :text => /John Smith/
|
||||
end
|
||||
|
||||
def test_show_issues_counts
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :params => {:id => 2}
|
||||
assert_select 'table.list.issue-report>tbody' do
|
||||
assert_select 'tr:nth-of-type(1)' do
|
||||
assert_select 'td:nth-of-type(1)>a', :text => 'Assigned issues'
|
||||
assert_select 'td:nth-of-type(2)>a', :text => '1' # open
|
||||
assert_select 'td:nth-of-type(3)>a', :text => '0' # closed
|
||||
assert_select 'td:nth-of-type(4)>a', :text => '1' # total
|
||||
end
|
||||
assert_select 'tr:nth-of-type(2)' do
|
||||
assert_select 'td:nth-of-type(1)>a', :text => 'Reported issues'
|
||||
assert_select 'td:nth-of-type(2)>a', :text => '11' # open
|
||||
assert_select 'td:nth-of-type(3)>a', :text => '2' # closed
|
||||
assert_select 'td:nth-of-type(4)>a', :text => '13' # total
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_user_should_list_user_groups
|
||||
@request.session[:user_id] = 1
|
||||
get :show, :params => {:id => 8}
|
||||
|
||||
assert_select 'div#groups', 1 do
|
||||
assert_select 'h3', :text => 'Groups'
|
||||
assert_select 'li', 2
|
||||
assert_select 'a[href=?]', '/groups/10/edit', :text => 'A Team'
|
||||
assert_select 'a[href=?]', '/groups/11/edit', :text => 'B Team'
|
||||
end
|
||||
end
|
||||
|
||||
def test_new
|
||||
get :new
|
||||
assert_response :success
|
||||
|
@ -203,7 +292,8 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
'time_zone' => 'Paris',
|
||||
'comments_sorting' => 'desc',
|
||||
'warn_on_leaving_unsaved' => '0',
|
||||
'textarea_font' => 'proportional'
|
||||
'textarea_font' => 'proportional',
|
||||
'history_default_tab' => 'history'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -214,6 +304,7 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
assert_equal 'desc', user.pref[:comments_sorting]
|
||||
assert_equal '0', user.pref[:warn_on_leaving_unsaved]
|
||||
assert_equal 'proportional', user.pref[:textarea_font]
|
||||
assert_equal 'history', user.pref[:history_default_tab]
|
||||
end
|
||||
|
||||
def test_create_with_generate_password_should_email_the_password
|
||||
|
@ -259,7 +350,7 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'User.count' do
|
||||
post :create, :params => {:user => {}}
|
||||
post :create, :params => {:user => {:login => 'foo'}}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /Email cannot be blank/
|
||||
|
@ -268,7 +359,9 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
def test_create_with_failure_sould_preserve_preference
|
||||
assert_no_difference 'User.count' do
|
||||
post :create, :params => {
|
||||
:user => {},
|
||||
:user => {
|
||||
:login => 'foo'
|
||||
},
|
||||
:pref => {
|
||||
'no_self_notified' => '1',
|
||||
'hide_mail' => '1',
|
||||
|
@ -327,10 +420,12 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
assert_nil ActionMailer::Base.deliveries.last
|
||||
end
|
||||
|
||||
|
||||
def test_edit
|
||||
get :edit, :params => {:id => 2}
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
get :edit, :params => {:id => 2}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select 'h2>a+img.gravatar'
|
||||
assert_select 'input[name=?][value=?]', 'user[login]', 'jsmith'
|
||||
end
|
||||
|
||||
|
@ -348,6 +443,14 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||
assert_response 404
|
||||
end
|
||||
|
||||
def test_edit_user_with_full_text_formatting_custom_field_should_not_fail
|
||||
field = UserCustomField.find(4)
|
||||
field.update_attribute :text_formatting, 'full'
|
||||
|
||||
get :edit, :params => {:id => 2}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_update
|
||||
ActionMailer::Base.deliveries.clear
|
||||
put :update, :params => {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -34,7 +36,9 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
|
||||
# Version with no date set appears
|
||||
assert_select 'h3', :text => Version.find(3).name
|
||||
assert_select 'h3', :text => "#{Version.find(3).name}"
|
||||
assert_select 'span[class=?]', 'badge badge-status-open', :text => 'open'
|
||||
|
||||
# Completed version doesn't appear
|
||||
assert_select 'h3', :text => Version.find(1).name, :count => 0
|
||||
|
||||
|
@ -94,11 +98,70 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_index_should_show_issue_assignee
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
Issue.generate!(:project_id => 3, :fixed_version_id => 4, :assigned_to => User.find_by_login('jsmith'))
|
||||
Issue.generate!(:project_id => 3, :fixed_version_id => 4)
|
||||
|
||||
get :index, :params => {:project_id => 3}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.related-issues' do
|
||||
assert_select 'tr.issue', :count => 2 do
|
||||
assert_select 'img.gravatar[title=?]', 'Assignee: John Smith', :count => 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :params => {:id => 2}
|
||||
with_settings :gravatar_enabled => '0' do
|
||||
get :show, :params => {:id => 2}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h2', :text => /1.0/
|
||||
assert_select 'span[class=?]', 'badge badge-status-locked', :text => 'locked'
|
||||
|
||||
# no issue avatar when gravatar is disabled
|
||||
assert_select 'img.gravatar', :count => 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_should_show_issue_assignee
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
get :show, :params => {:id => 2}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.related-issues' do
|
||||
assert_select 'tr.issue td.assigned_to', :count => 2 do
|
||||
assert_select 'img.gravatar[title=?]', 'Assignee: Dave Lopper', :count => 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_issue_calculations_should_take_into_account_only_visible_issues
|
||||
issue_9 = Issue.find(9)
|
||||
issue_9.fixed_version_id = 4
|
||||
issue_9.estimated_hours = 3
|
||||
issue_9.save!
|
||||
|
||||
issue_13 = Issue.find(13)
|
||||
issue_13.fixed_version_id = 4
|
||||
issue_13.estimated_hours = 2
|
||||
issue_13.save!
|
||||
|
||||
@request.session[:user_id] = 7
|
||||
|
||||
get :show, :params => {:id => 4}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h2', :text => /1.0/
|
||||
assert_select 'p.progress-info' do
|
||||
assert_select 'a', :text => '1 issue'
|
||||
assert_select 'a', :text => '1 open'
|
||||
end
|
||||
|
||||
assert_select '.time-tracking td.total-hours a:first-child', :text => '2.00 hours'
|
||||
end
|
||||
|
||||
def test_show_should_link_to_spent_time_on_version
|
||||
|
@ -126,6 +189,33 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_show_should_round_down_progress_percentages
|
||||
issue = Issue.find(12)
|
||||
issue.estimated_hours = 40
|
||||
issue.save!
|
||||
|
||||
with_settings :default_language => 'en' do
|
||||
get :show, :params => {:id => 2}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div.version-overview' do
|
||||
assert_select 'table.progress-98' do
|
||||
assert_select 'td[class=closed][title=?]', 'closed: 98%'
|
||||
assert_select 'td[class=done][title=?]', '% Done: 99%'
|
||||
end
|
||||
assert_select 'p[class=percent]', :text => '99%'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_should_display_link_to_new_issue
|
||||
@request.session[:user_id] = 1
|
||||
get :show, :params => {:id => 3}
|
||||
|
||||
assert_response :success
|
||||
assert_select 'a.icon.icon-add', :text => 'New issue'
|
||||
end
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :params => {:project_id => '1'}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue