##// END OF EJS Templates
Rails4 compatibility of Setting model...
Rails4 compatibility of Setting model git-svn-id: http://svn.redmine.org/redmine/trunk@12423 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r11122:dbe7d6fbfb5b
r12148:3e4d4a0c1af0
Show More
files_controller_test.rb
109 lines | 3.6 KiB | text/x-ruby | RubyLexer
/ test / functional / files_controller_test.rb
Jean-Philippe Lang
Functional tests cleanup....
r10709 # Redmine - project management software
Jean-Philippe Lang
Copyright for 2013 (#12788)....
r10939 # Copyright (C) 2006-2013 Jean-Philippe Lang
Jean-Philippe Lang
Functional tests cleanup....
r10709 #
# 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.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Eric Davis
Refactor: move method, ProjectsController#list_files to FilesController#index....
r3937
class FilesControllerTest < ActionController::TestCase
Toshi MARUYAMA
Rails3: replace "all" fixtures at test/functional/files_controller_test.rb...
r7402 fixtures :projects, :trackers, :issue_statuses, :issues,
:enumerations, :users, :issue_categories,
:projects_trackers,
:roles,
:member_roles,
:members,
:enabled_modules,
:journals, :journal_details,
:attachments,
:versions
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Eric Davis
Refactor: move method, ProjectsController#list_files to FilesController#index....
r3937 def setup
@request.session[:user_id] = nil
Setting.default_language = 'en'
end
def test_index
Eric Davis
Refactor: convert FilesController to a restful resource....
r3971 get :index, :project_id => 1
Eric Davis
Refactor: move method, ProjectsController#list_files to FilesController#index....
r3937 assert_response :success
assert_template 'index'
assert_not_nil assigns(:containers)
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Eric Davis
Refactor: move method, ProjectsController#list_files to FilesController#index....
r3937 # file attached to the project
assert_tag :a, :content => 'project_file.zip',
:attributes => { :href => '/attachments/download/8/project_file.zip' }
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Eric Davis
Refactor: move method, ProjectsController#list_files to FilesController#index....
r3937 # file attached to a project's version
assert_tag :a, :content => 'version_file.zip',
:attributes => { :href => '/attachments/download/9/version_file.zip' }
end
Jean-Philippe Lang
Adds functional tests....
r8834 def test_new
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
assert_template 'new'
assert_tag 'select', :attributes => {:name => 'version_id'}
end
def test_new_without_versions
Version.delete_all
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
assert_template 'new'
assert_no_tag 'select', :attributes => {:name => 'version_id'}
end
Eric Davis
Refactor: split FilesController#new into #new and #create....
r3970 def test_create_file
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 set_tmp_attachments_directory
@request.session[:user_id] = 2
ActionMailer::Base.deliveries.clear
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Jean-Philippe Lang
Tests should not change settings....
r9766 with_settings :notified_events => %w(file_added) do
assert_difference 'Attachment.count' do
post :create, :project_id => 1, :version_id => '',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
assert_response :redirect
end
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 end
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/projects/ecookbook/files'
Jean-Philippe Lang
Replaces find(:first) calls....
r10701 a = Attachment.order('created_on DESC').first
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 assert_equal 'testfile.txt', a.filename
assert_equal Project.find(1), a.container
mail = ActionMailer::Base.deliveries.last
Jean-Philippe Lang
Do not do assertions on mail class....
r8871 assert_not_nil mail
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 assert_equal "[eCookbook] New file", mail.subject
Jean-Philippe Lang
Adds helpers for testing email body....
r8966 assert_mail_body_match 'testfile.txt', mail
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Eric Davis
Refactor: split FilesController#new into #new and #create....
r3970 def test_create_version_file
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 set_tmp_attachments_directory
@request.session[:user_id] = 2
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 assert_difference 'Attachment.count' do
Eric Davis
Refactor: convert FilesController to a restful resource....
r3971 post :create, :project_id => 1, :version_id => '2',
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
assert_response :redirect
end
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/projects/ecookbook/files'
Jean-Philippe Lang
Replaces find(:first) calls....
r10701 a = Attachment.order('created_on DESC').first
Eric Davis
Refactor: move method, ProjectsController#add_file to FilesController#new....
r3938 assert_equal 'testfile.txt', a.filename
assert_equal Version.find(2), a.container
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/files_controller_test.rb....
r6698
Eric Davis
Refactor: move method, ProjectsController#list_files to FilesController#index....
r3937 end