Browse Source

Fix test failure due to missing call to set_tmp_attachments_directory (#32122).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@18593 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.1.0
Go MAEDA 4 years ago
parent
commit
5ce4a363a9

+ 2
- 0
test/functional/documents_controller_test.rb View File

end end


def test_destroy def test_destroy
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Document.count', -1 do assert_difference 'Document.count', -1 do
delete :destroy, :params => { delete :destroy, :params => {
end end


def test_add_attachment def test_add_attachment
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Attachment.count' do assert_difference 'Attachment.count' do
post :add_attachment, :params => { post :add_attachment, :params => {

+ 20
- 8
test/functional/issues_controller_test.rb View File

end end


def test_index_grouped_by_due_date def test_index_grouped_by_due_date
set_tmp_attachments_directory
Issue.destroy_all Issue.destroy_all
Issue.generate!(:due_date => '2018-08-10') Issue.generate!(:due_date => '2018-08-10')
Issue.generate!(:due_date => '2018-08-10') Issue.generate!(:due_date => '2018-08-10')
end end


def test_create_as_copy_with_attachments_should_also_add_new_files def test_create_as_copy_with_attachments_should_also_add_new_files
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
issue = Issue.find(3) issue = Issue.find(3)
count = issue.attachments.count count = issue.attachments.count
end end


def test_destroy_issue_with_no_time_entries_should_delete_the_issues def test_destroy_issue_with_no_time_entries_should_delete_the_issues
set_tmp_attachments_directory
assert_nil TimeEntry.find_by_issue_id(2) assert_nil TimeEntry.find_by_issue_id(2)
@request.session[:user_id] = 2 @request.session[:user_id] = 2


end end


def test_destroy_issues_with_time_entries_should_show_the_reassign_form def test_destroy_issues_with_time_entries_should_show_the_reassign_form
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


with_settings :timelog_required_fields => [] do with_settings :timelog_required_fields => [] do
end end


def test_destroy_issues_with_time_entries_should_not_show_the_nullify_option_when_issue_is_required_for_time_entries def test_destroy_issues_with_time_entries_should_not_show_the_nullify_option_when_issue_is_required_for_time_entries
set_tmp_attachments_directory
with_settings :timelog_required_fields => ['issue_id'] do with_settings :timelog_required_fields => ['issue_id'] do
@request.session[:user_id] = 2 @request.session[:user_id] = 2


assert_no_difference 'Issue.count' do
delete :destroy, :params => {
:ids => [1, 3]
}
end
assert_response :success
assert_no_difference 'Issue.count' do
delete :destroy, :params => {
:ids => [1, 3]
}
end
assert_response :success


assert_select 'form' do
assert_select 'input[name=_method][value=delete]'
assert_select 'form' do
assert_select 'input[name=_method][value=delete]'
assert_select 'input[name=todo][value=destroy]' assert_select 'input[name=todo][value=destroy]'
assert_select 'input[name=todo][value=nullify]', 0 assert_select 'input[name=todo][value=nullify]', 0
assert_select 'input[name=todo][value=reassign]' assert_select 'input[name=todo][value=reassign]'
end end


def test_destroy_issues_and_destroy_time_entries def test_destroy_issues_and_destroy_time_entries
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


assert_difference 'Issue.count', -2 do assert_difference 'Issue.count', -2 do
end end


def test_destroy_issues_and_assign_time_entries_to_project def test_destroy_issues_and_assign_time_entries_to_project
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


with_settings :timelog_required_fields => [] do with_settings :timelog_required_fields => [] do
end end


def test_destroy_issues_and_reassign_time_entries_to_another_issue def test_destroy_issues_and_reassign_time_entries_to_another_issue
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


assert_difference 'Issue.count', -2 do assert_difference 'Issue.count', -2 do
end end


def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


assert_no_difference 'Issue.count' do assert_no_difference 'Issue.count' do
end end


def test_destroy_issues_and_reassign_time_entries_to_an_issue_to_delete_should_fail def test_destroy_issues_and_reassign_time_entries_to_an_issue_to_delete_should_fail
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


assert_no_difference 'Issue.count' do assert_no_difference 'Issue.count' do
end end


def test_destroy_issues_and_nullify_time_entries_should_fail_when_issue_is_required_for_time_entries def test_destroy_issues_and_nullify_time_entries_should_fail_when_issue_is_required_for_time_entries
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


with_settings :timelog_required_fields => ['issue_id'] do with_settings :timelog_required_fields => ['issue_id'] do
end end


def test_destroy_issues_from_different_projects def test_destroy_issues_from_different_projects
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2


assert_difference 'Issue.count', -3 do assert_difference 'Issue.count', -3 do

+ 1
- 0
test/functional/journals_controller_test.rb View File

end end


def test_index_should_show_visible_custom_fields_only def test_index_should_show_visible_custom_fields_only
set_tmp_attachments_directory
Issue.destroy_all Issue.destroy_all
Journal.delete_all Journal.delete_all
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all} field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}

+ 1
- 0
test/functional/messages_controller_test.rb View File

end end


def test_destroy_topic def test_destroy_topic
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Message.count', -3 do assert_difference 'Message.count', -3 do
post :destroy, :params => { post :destroy, :params => {

+ 2
- 0
test/functional/projects_controller_test.rb View File

end end


def test_destroy_without_confirmation_should_show_confirmation_with_subprojects def test_destroy_without_confirmation_should_show_confirmation_with_subprojects
set_tmp_attachments_directory
@request.session[:user_id] = 1 # admin @request.session[:user_id] = 1 # admin


assert_no_difference 'Project.count' do assert_no_difference 'Project.count' do
end end


def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects
set_tmp_attachments_directory
@request.session[:user_id] = 1 # admin @request.session[:user_id] = 1 # admin


assert_difference 'Project.count', -5 do assert_difference 'Project.count', -5 do

+ 3
- 0
test/functional/wiki_controller_test.rb View File

end end


def test_create_page_with_attachments def test_create_page_with_attachments
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'WikiPage.count' do assert_difference 'WikiPage.count' do
assert_difference 'Attachment.count' do assert_difference 'Attachment.count' do
end end


def test_update_page_with_attachments_only_should_not_create_content_version def test_update_page_with_attachments_only_should_not_create_content_version
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_no_difference 'WikiPage.count' do assert_no_difference 'WikiPage.count' do
assert_no_difference 'WikiContent.count' do assert_no_difference 'WikiContent.count' do
end end


def test_add_attachment def test_add_attachment
set_tmp_attachments_directory
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Attachment.count' do assert_difference 'Attachment.count' do
post :add_attachment, :params => { post :add_attachment, :params => {

+ 2
- 0
test/functional/wikis_controller_test.rb View File

end end


def test_get_destroy_should_ask_confirmation def test_get_destroy_should_ask_confirmation
set_tmp_attachments_directory
@request.session[:user_id] = 1 @request.session[:user_id] = 1
assert_no_difference 'Wiki.count' do assert_no_difference 'Wiki.count' do
get :destroy, :params => {:id => 1} get :destroy, :params => {:id => 1}
end end


def test_post_destroy_should_delete_wiki def test_post_destroy_should_delete_wiki
set_tmp_attachments_directory
@request.session[:user_id] = 1 @request.session[:user_id] = 1
post :destroy, :params => {:id => 1, :confirm => 1} post :destroy, :params => {:id => 1, :confirm => 1}
assert_redirected_to :controller => 'projects', assert_redirected_to :controller => 'projects',

+ 1
- 2
test/helpers/application_helper_test.rb View File

end end


def test_attached_images_filename_extension def test_attached_images_filename_extension
set_tmp_attachments_directory
a1 = Attachment.new( a1 = Attachment.new(
:container => Issue.find(1), :container => Issue.find(1),
:file => mock_file_with_options({:original_filename => "testtest.JPG"}), :file => mock_file_with_options({:original_filename => "testtest.JPG"}),
} }
attachments = [a1, a2] attachments = [a1, a2]
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
ensure
set_tmp_attachments_directory set_tmp_attachments_directory
end end


end end


def test_attachment_link_should_link_to_latest_attachment def test_attachment_link_should_link_to_latest_attachment
set_tmp_attachments_directory
a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago)
a2 = Attachment.generate!(:filename => "test.txt") a2 = Attachment.generate!(:filename => "test.txt")
result = link_to("test.txt", "/attachments/#{a2.id}", result = link_to("test.txt", "/attachments/#{a2.id}",

+ 1
- 0
test/helpers/journals_helper_test.rb View File

:versions :versions


def test_journal_thumbnail_attachments_should_return_thumbnailable_attachments def test_journal_thumbnail_attachments_should_return_thumbnailable_attachments
set_tmp_attachments_directory
issue = Issue.generate! issue = Issue.generate!


journal = new_record(Journal) do journal = new_record(Journal) do

+ 0
- 1
test/integration/attachments_test.rb View File

get "/attachments/download/4" get "/attachments/download/4"
assert_response :success assert_response :success
assert_not_nil response.headers["X-Sendfile"] assert_not_nil response.headers["X-Sendfile"]

ensure ensure
set_tmp_attachments_directory set_tmp_attachments_directory
end end

+ 0
- 2
test/system/issues_test.rb View File

end end
assert_equal 1, issue.attachments.count assert_equal 1, issue.attachments.count
assert_equal 'Some description', issue.attachments.first.description assert_equal 'Some description', issue.attachments.first.description
ensure
set_fixtures_attachments_directory
end end


def test_create_issue_with_new_target_version def test_create_issue_with_new_target_version

+ 9
- 1
test/unit/attachment_test.rb View File

assert attachment.readable? assert attachment.readable?
attachment.update_digest_to_sha256! attachment.update_digest_to_sha256!
assert_equal 'ac5c6e99a21ae74b2e3f5b8e5b568be1b9107cd7153d139e822b9fe5caf50938', attachment.digest assert_equal 'ac5c6e99a21ae74b2e3f5b8e5b568be1b9107cd7153d139e822b9fe5caf50938', attachment.digest
ensure
set_tmp_attachments_directory
end end


def test_update_attachments def test_update_attachments
assert_equal 17, la1.id assert_equal 17, la1.id
la2 = Attachment.latest_attach([a1, a2], "Testfile.PNG") la2 = Attachment.latest_attach([a1, a2], "Testfile.PNG")
assert_equal 17, la2.id assert_equal 17, la2.id
ensure
set_tmp_attachments_directory set_tmp_attachments_directory
end end


assert File.exist?(thumbnail) assert File.exist?(thumbnail)
end end
end end
ensure
set_tmp_attachments_directory
end end


def test_should_reuse_thumbnail def test_should_reuse_thumbnail
set_fixtures_attachments_directory set_fixtures_attachments_directory
attachment = Attachment.find(16) attachment = Attachment.find(16)
assert_nil attachment.thumbnail assert_nil attachment.thumbnail
ensure
set_tmp_attachments_directory
end end


def test_thumbnail_should_be_at_least_of_requested_size def test_thumbnail_should_be_at_least_of_requested_size
assert_equal "8e0294de2441577c529f170b6fb8f638_2654_#{generated_size}.thumb", assert_equal "8e0294de2441577c529f170b6fb8f638_2654_#{generated_size}.thumb",
File.basename(thumbnail) File.basename(thumbnail)
end end
ensure
set_tmp_attachments_directory
end end
else else
puts '(ImageMagick convert not available)' puts '(ImageMagick convert not available)'

+ 1
- 0
test/unit/board_test.rb View File

end end


def test_destroy def test_destroy
set_tmp_attachments_directory
board = Board.find(1) board = Board.find(1)
assert_difference 'Message.count', -6 do assert_difference 'Message.count', -6 do
assert_difference 'Attachment.count', -1 do assert_difference 'Attachment.count', -1 do

+ 3
- 4
test/unit/lib/redmine/export/pdf_test.rb View File

end end


def test_attach def test_attach
set_fixtures_attachments_directory
["CP932", "SJIS"].each do |encoding| ["CP932", "SJIS"].each do |encoding|
set_fixtures_attachments_directory

str2 = "\x83e\x83X\x83g".b str2 = "\x83e\x83X\x83g".b


a1 = Attachment.find(17) a1 = Attachment.find(17)
assert_nil aa1 assert_nil aa1
aa2 = Redmine::Export::PDF::RDMPdfEncoding::attach(Attachment.all, "test#{str2}.png", encoding) aa2 = Redmine::Export::PDF::RDMPdfEncoding::attach(Attachment.all, "test#{str2}.png", encoding)
assert_nil aa2 assert_nil aa2

set_tmp_attachments_directory
end end
ensure
set_tmp_attachments_directory
end end
end end

+ 7
- 0
test/unit/mail_handler_test.rb View File

end end


def test_add_issue_from_apple_mail def test_add_issue_from_apple_mail
set_tmp_attachments_directory
issue = submit_email( issue = submit_email(
'apple_mail_with_attachment.eml', 'apple_mail_with_attachment.eml',
:issue => {:project => 'ecookbook'} :issue => {:project => 'ecookbook'}
end end


def test_thunderbird_with_attachment_ja def test_thunderbird_with_attachment_ja
set_tmp_attachments_directory
issue = submit_email( issue = submit_email(
'thunderbird_with_attachment_ja.eml', 'thunderbird_with_attachment_ja.eml',
:issue => {:project => 'ecookbook'} :issue => {:project => 'ecookbook'}
end end


def test_gmail_with_attachment_ja def test_gmail_with_attachment_ja
set_tmp_attachments_directory
issue = submit_email( issue = submit_email(
'gmail_with_attachment_ja.eml', 'gmail_with_attachment_ja.eml',
:issue => {:project => 'ecookbook'} :issue => {:project => 'ecookbook'}
end end


def test_thunderbird_with_attachment_latin1 def test_thunderbird_with_attachment_latin1
set_tmp_attachments_directory
issue = submit_email( issue = submit_email(
'thunderbird_with_attachment_iso-8859-1.eml', 'thunderbird_with_attachment_iso-8859-1.eml',
:issue => {:project => 'ecookbook'} :issue => {:project => 'ecookbook'}
end end


def test_gmail_with_attachment_latin1 def test_gmail_with_attachment_latin1
set_tmp_attachments_directory
issue = submit_email( issue = submit_email(
'gmail_with_attachment_iso-8859-1.eml', 'gmail_with_attachment_iso-8859-1.eml',
:issue => {:project => 'ecookbook'} :issue => {:project => 'ecookbook'}
end end


def test_mail_with_attachment_latin2 def test_mail_with_attachment_latin2
set_tmp_attachments_directory
issue = submit_email( issue = submit_email(
'ticket_with_text_attachment_iso-8859-2.eml', 'ticket_with_text_attachment_iso-8859-2.eml',
:issue => {:project => 'ecookbook'} :issue => {:project => 'ecookbook'}
end end


def test_reply_to_a_nonexistent_issue def test_reply_to_a_nonexistent_issue
set_tmp_attachments_directory
Issue.find(2).destroy Issue.find(2).destroy
assert_no_difference 'Issue.count' do assert_no_difference 'Issue.count' do
assert_no_difference 'Journal.count' do assert_no_difference 'Journal.count' do

+ 1
- 0
test/unit/message_test.rb View File

end end


def test_destroy_topic def test_destroy_topic
set_tmp_attachments_directory
message = Message.find(1) message = Message.find(1)
board = message.board board = message.board
topics_count, messages_count = board.topics_count, board.messages_count topics_count, messages_count = board.topics_count, board.messages_count

+ 4
- 0
test/unit/project_copy_test.rb View File

end end


test "#copy should copy project attachments" do test "#copy should copy project attachments" do
set_tmp_attachments_directory
Attachment.create!(:container => @source_project, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) Attachment.create!(:container => @source_project, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
assert @project.copy(@source_project) assert @project.copy(@source_project)


end end


test "#copy should copy issue attachments" do test "#copy should copy issue attachments" do
set_tmp_attachments_directory
issue = Issue.generate!(:subject => "copy with attachment", :tracker_id => 1, :project_id => @source_project.id) issue = Issue.generate!(:subject => "copy with attachment", :tracker_id => 1, :project_id => @source_project.id)
Attachment.create!(:container => issue, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) Attachment.create!(:container => issue, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
@source_project.issues << issue @source_project.issues << issue
end end


test "#copy should copy version attachments" do test "#copy should copy version attachments" do
set_tmp_attachments_directory
version = Version.generate!(:name => "copy with attachment") version = Version.generate!(:name => "copy with attachment")
Attachment.create!(:container => version, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) Attachment.create!(:container => version, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
@source_project.versions << version @source_project.versions << version
end end


test "#copy should copy document attachments" do test "#copy should copy document attachments" do
set_tmp_attachments_directory
document = Document.generate!(:title => "copy with attachment", :category_id => 1, :project_id => @source_project.id) document = Document.generate!(:title => "copy with attachment", :category_id => 1, :project_id => @source_project.id)
Attachment.create!(:container => document, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) Attachment.create!(:container => document, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
@source_project.documents << document @source_project.documents << document

+ 1
- 0
test/unit/user_test.rb View File

end end


def test_destroy_should_update_attachments def test_destroy_should_update_attachments
set_tmp_attachments_directory
attachment = Attachment.create!(:container => Project.find(1), attachment = Attachment.create!(:container => Project.find(1),
:file => uploaded_test_file("testfile.txt", "text/plain"), :file => uploaded_test_file("testfile.txt", "text/plain"),
:author_id => 2) :author_id => 2)

+ 1
- 0
test/unit/wiki_page_test.rb View File

end end


def test_destroy_should_delete_content_and_its_versions def test_destroy_should_delete_content_and_its_versions
set_tmp_attachments_directory
page = WikiPage.find(1) page = WikiPage.find(1)
assert_difference 'WikiPage.count', -1 do assert_difference 'WikiPage.count', -1 do
assert_difference 'WikiContent.count', -1 do assert_difference 'WikiContent.count', -1 do

+ 2
- 0
test/unit/wiki_test.rb View File

end end


def test_destroy_should_remove_redirects_from_the_wiki def test_destroy_should_remove_redirects_from_the_wiki
set_tmp_attachments_directory
WikiRedirect.create!(:wiki_id => 1, :title => 'Foo', :redirects_to_wiki_id => 2, :redirects_to => 'Bar') WikiRedirect.create!(:wiki_id => 1, :title => 'Foo', :redirects_to_wiki_id => 2, :redirects_to => 'Bar')


Wiki.find(1).destroy Wiki.find(1).destroy
end end


def test_destroy_should_remove_redirects_to_the_wiki def test_destroy_should_remove_redirects_to_the_wiki
set_tmp_attachments_directory
WikiRedirect.create!(:wiki_id => 2, :title => 'Foo', :redirects_to_wiki_id => 1, :redirects_to => 'Bar') WikiRedirect.create!(:wiki_id => 2, :title => 'Foo', :redirects_to_wiki_id => 1, :redirects_to => 'Bar')


Wiki.find(1).destroy Wiki.find(1).destroy

Loading…
Cancel
Save