end
def test_index
- get :index, :params => {
+ get(
+ :index,
+ :params => {
:project_id => 1
}
+ )
assert_response :success
# file attached to the project
def test_new
@request.session[:user_id] = 2
- get :new, :params => {
+ get(
+ :new,
+ :params => {
:project_id => 1
}
+ )
assert_response :success
-
assert_select 'select[name=?]', 'version_id'
end
def test_new_without_versions
Version.delete_all
@request.session[:user_id] = 2
- get :new, :params => {
+ get(
+ :new,
+ :params => {
:project_id => 1
}
+ )
assert_response :success
-
assert_select 'select[name=?]', 'version_id', 0
end
set_tmp_attachments_directory
@request.session[:user_id] = 2
ActionMailer::Base.deliveries.clear
-
with_settings :notified_events => %w(file_added) do
assert_difference 'Attachment.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 1,
:version_id => '',
:attachments => {
'1' => {
- 'file' => uploaded_test_file('testfile.txt', 'text/plain')}
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain')
+ }
}
}
+ )
assert_response :redirect
end
end
def test_create_version_file
set_tmp_attachments_directory
@request.session[:user_id] = 2
-
assert_difference 'Attachment.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 1,
:version_id => '2',
:attachments => {
'1' => {
- 'file' => uploaded_test_file('testfile.txt', 'text/plain')}
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain')
+ }
}
}
+ )
assert_response :redirect
end
assert_redirected_to '/projects/ecookbook/files'
def test_create_without_file
set_tmp_attachments_directory
@request.session[:user_id] = 2
-
assert_no_difference 'Attachment.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 1,
:version_id => ''
}
+ )
assert_response :success
end
assert_select 'div.error', 'File is invalid'