Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -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
|
||||
|
@ -41,6 +43,10 @@ Redmine::SudoMode.disable!
|
|||
$redmine_tmp_attachments_directory = "#{Rails.root}/tmp/test/attachments"
|
||||
FileUtils.mkdir_p $redmine_tmp_attachments_directory
|
||||
|
||||
$redmine_tmp_pdf_directory = "#{Rails.root}/tmp/test/pdf"
|
||||
FileUtils.mkdir_p $redmine_tmp_pdf_directory
|
||||
FileUtils.rm Dir.glob('#$redmine_tmp_pdf_directory/*.pdf')
|
||||
|
||||
class ActionView::TestCase
|
||||
helper :application
|
||||
include ApplicationHelper
|
||||
|
@ -49,7 +55,7 @@ end
|
|||
class ActiveSupport::TestCase
|
||||
include ActionDispatch::TestProcess
|
||||
|
||||
self.use_transactional_fixtures = true
|
||||
self.use_transactional_tests = true
|
||||
self.use_instantiated_fixtures = false
|
||||
|
||||
def uploaded_test_file(name, mime)
|
||||
|
@ -81,7 +87,8 @@ class ActiveSupport::TestCase
|
|||
|
||||
def with_settings(options, &block)
|
||||
saved_settings = options.keys.inject({}) do |h, k|
|
||||
h[k] = case Setting[k]
|
||||
h[k] =
|
||||
case Setting[k]
|
||||
when Symbol, false, true, nil
|
||||
Setting[k]
|
||||
else
|
||||
|
@ -115,7 +122,7 @@ class ActiveSupport::TestCase
|
|||
def self.ldap_configured?
|
||||
@test_ldap = Net::LDAP.new(:host => $redmine_test_ldap_server, :port => 389)
|
||||
return @test_ldap.bind
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
# LDAP is not listening
|
||||
return nil
|
||||
end
|
||||
|
@ -128,6 +135,14 @@ class ActiveSupport::TestCase
|
|||
self.class.convert_installed?
|
||||
end
|
||||
|
||||
def self.gs_installed?
|
||||
Redmine::Thumbnail.gs_available?
|
||||
end
|
||||
|
||||
def gs_installed?
|
||||
self.class.gs_installed?
|
||||
end
|
||||
|
||||
# Returns the path to the test +vendor+ repository
|
||||
def self.repository_path(vendor)
|
||||
path = Rails.root.join("tmp/test/#{vendor.downcase}_repository").to_s
|
||||
|
@ -190,7 +205,7 @@ class ActiveSupport::TestCase
|
|||
saved = object.save
|
||||
message = "#{object.class} could not be saved"
|
||||
errors = object.errors.full_messages.map {|m| "- #{m}"}
|
||||
message << ":\n#{errors.join("\n")}" if errors.any?
|
||||
message += ":\n#{errors.join("\n")}" if errors.any?
|
||||
assert_equal true, saved, message
|
||||
end
|
||||
|
||||
|
@ -236,7 +251,7 @@ class ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def mail_body(mail)
|
||||
mail.parts.first.body.encoded
|
||||
(mail.multipart? ? mail.parts.first : mail).body.encoded
|
||||
end
|
||||
|
||||
# Returns the lft value for a new root issue
|
||||
|
@ -248,14 +263,14 @@ end
|
|||
module Redmine
|
||||
class MockFile
|
||||
attr_reader :size, :original_filename, :content_type
|
||||
|
||||
|
||||
def initialize(options={})
|
||||
@size = options[:size] || 32
|
||||
@original_filename = options[:original_filename] || options[:filename]
|
||||
@content_type = options[:content_type]
|
||||
@content = options[:content] || 'x'*size
|
||||
end
|
||||
|
||||
|
||||
def read(*args)
|
||||
if @eof
|
||||
false
|
||||
|
@ -302,17 +317,27 @@ module Redmine
|
|||
ids = css_select('tr.issue td.id').map(&:text).map(&:to_i)
|
||||
Issue.where(:id => ids).sort_by {|issue| ids.index(issue.id)}
|
||||
end
|
||||
|
||||
# Return the columns that are displayed in the list
|
||||
|
||||
# Return the columns that are displayed in the issue list
|
||||
def columns_in_issues_list
|
||||
css_select('table.issues thead th:not(.checkbox)').map(&:text)
|
||||
css_select('table.issues thead th:not(.checkbox)').map(&:text).select(&:present?)
|
||||
end
|
||||
|
||||
|
||||
# Return the columns that are displayed in the list
|
||||
def columns_in_list
|
||||
css_select('table.list thead th:not(.checkbox)').map(&:text).select(&:present?)
|
||||
end
|
||||
|
||||
# Returns the values that are displayed in tds with the given css class
|
||||
def columns_values_in_list(css_class)
|
||||
css_select("table.list tbody td.#{css_class}").map(&:text)
|
||||
end
|
||||
|
||||
# Verifies that the query filters match the expected filters
|
||||
def assert_query_filters(expected_filters)
|
||||
response.body =~ /initFilters\(\);\s*((addFilter\(.+\);\s*)*)/
|
||||
filter_init = $1.to_s
|
||||
|
||||
|
||||
expected_filters.each do |field, operator, values|
|
||||
s = "addFilter(#{field.to_json}, #{operator.to_json}, #{Array(values).to_json});"
|
||||
assert_include s, filter_init
|
||||
|
@ -320,18 +345,27 @@ module Redmine
|
|||
assert_equal expected_filters.size, filter_init.scan("addFilter").size, "filters counts don't match"
|
||||
end
|
||||
|
||||
def process(action, http_method = 'GET', *args)
|
||||
parameters, session, flash = *args
|
||||
if args.size == 1 && parameters[:xhr] == true
|
||||
xhr http_method.downcase.to_sym, action, parameters.except(:xhr)
|
||||
elsif parameters && (parameters.key?(:params) || parameters.key?(:session) || parameters.key?(:flash))
|
||||
super action, http_method, parameters[:params], parameters[:session], parameters[:flash]
|
||||
else
|
||||
super
|
||||
# Saves the generated PDF in tmp/test/pdf
|
||||
def save_pdf
|
||||
assert_equal 'application/pdf', response.content_type
|
||||
filename = "#{self.class.name.underscore}__#{method_name}.pdf"
|
||||
File.open(File.join($redmine_tmp_pdf_directory, filename), "wb") do |f|
|
||||
f.write response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class RepositoryControllerTest < ControllerTest
|
||||
def setup
|
||||
super
|
||||
# We need to explicitly set Accept header to html otherwise
|
||||
# requests that ends with a known format like:
|
||||
# GET /projects/foo/repository/entry/image.png would be
|
||||
# treated as image/png requests, resulting in a 406 error.
|
||||
request.env["HTTP_ACCEPT"] = "text/html"
|
||||
end
|
||||
end
|
||||
|
||||
class IntegrationTest < ActionDispatch::IntegrationTest
|
||||
def log_user(login, password)
|
||||
User.anonymous
|
||||
|
@ -339,21 +373,13 @@ module Redmine
|
|||
assert_nil session[:user_id]
|
||||
assert_response :success
|
||||
|
||||
post "/login", :username => login, :password => password
|
||||
post "/login", :params => {
|
||||
:username => login,
|
||||
:password => password
|
||||
}
|
||||
assert_equal login, User.find(session[:user_id]).login
|
||||
end
|
||||
|
||||
%w(get post patch put delete head).each do |http_method|
|
||||
class_eval %Q"
|
||||
def #{http_method}(path, parameters = nil, headers_or_env = nil)
|
||||
if headers_or_env.nil? && parameters.is_a?(Hash) && (parameters.key?(:params) || parameters.key?(:headers))
|
||||
super path, parameters[:params], parameters[:headers]
|
||||
else
|
||||
super
|
||||
end
|
||||
end"
|
||||
end
|
||||
|
||||
def credentials(user, password=nil)
|
||||
{'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)}
|
||||
end
|
||||
|
@ -385,7 +411,9 @@ module Redmine
|
|||
def upload(format, content, credentials)
|
||||
set_tmp_attachments_directory
|
||||
assert_difference 'Attachment.count' do
|
||||
post "/uploads.#{format}", content, {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials)
|
||||
post "/uploads.#{format}",
|
||||
:params => content,
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials)
|
||||
assert_response :created
|
||||
end
|
||||
data = response_data
|
||||
|
@ -418,7 +446,7 @@ module Redmine
|
|||
request = arg.keys.detect {|key| key.is_a?(String)}
|
||||
raise ArgumentError unless request
|
||||
options = arg.slice!(request)
|
||||
|
||||
|
||||
API_FORMATS.each do |format|
|
||||
format_request = request.sub /$/, ".#{format}"
|
||||
super options.merge(format_request => arg[request], :format => format)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue