end
def test_index_with_project
- get :index, :params => {
- :project_id => 1
- }
+ get(:index, :params => {:project_id => 1})
assert_response :success
assert_select 'h3 a', :text => 'eCookbook first release !'
end
def test_index_with_invalid_project_should_respond_with_404
- get :index, :params => {
- :project_id => 999
- }
+ get(:index, :params => {:project_id => 999})
assert_response 404
end
end
def test_show
- get :show, :params => {
- :id => 1
- }
+ get(:show, :params => {:id => 1})
assert_response :success
assert_select 'h2', :text => 'eCookbook first release !'
end
attachment.container = News.find(1)
attachment.save!
- get :show, :params => {
- :id => 1
- }
+ get(:show, :params => {:id => 1})
assert_response :success
assert_select 'a', :text => attachment.filename
end
user.pref.save!
@request.session[:user_id] = 1
- get :show, :params => {
- :id => 1
- }
+ get(:show, :params => {:id => 1})
assert_response :success
comments = css_select('#comments .wiki').map(&:text).map(&:strip)
end
def test_show_not_found
- get :show, :params => {
- :id => 999
- }
+ get(:show, :params => {:id => 999})
assert_response 404
end
def test_get_new
@request.session[:user_id] = 2
- get :new, :params => {
- :project_id => 1
- }
+ get(:new, :params => {:project_id => 1})
assert_response :success
assert_select 'input[name=?]', 'news[title]'
end
@request.session[:user_id] = 2
with_settings :notified_events => %w(news_added) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 1,
:news => {
:title => 'NewsControllerTest',
:summary => ''
}
}
+ )
end
assert_redirected_to '/projects/ecookbook/news'
@request.session[:user_id] = 2
assert_difference 'News.count' do
assert_difference 'Attachment.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 1,
:news => {
:title => 'Test',
},
:attachments => {
'1' => {
- 'file' => uploaded_test_file('testfile.txt', 'text/plain')}
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain')
+ }
}
}
+ )
end
end
attachment = Attachment.order('id DESC').first
def test_post_create_with_validation_failure
@request.session[:user_id] = 2
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 1,
:news => {
:title => '',
:summary => ''
}
}
+ )
assert_response :success
assert_select_error /title cannot be blank/i
end
def test_get_edit
@request.session[:user_id] = 2
- get :edit, :params => {
- :id => 1
- }
+ get(:edit, :params => {:id => 1})
assert_response :success
assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !'
end
def test_put_update
@request.session[:user_id] = 2
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => 1,
:news => {
:description => 'Description changed by test_post_edit'
}
}
+ )
assert_redirected_to '/news/1'
news = News.find(1)
assert_equal 'Description changed by test_post_edit', news.description
@request.session[:user_id] = 2
assert_no_difference 'News.count' do
assert_difference 'Attachment.count' do
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => 1,
:news => {
:description => 'This is the description'
},
:attachments => {
'1' => {
- 'file' => uploaded_test_file('testfile.txt', 'text/plain')}
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain')
+ }
}
}
+ )
end
end
attachment = Attachment.order('id DESC').first
def test_update_with_failure
@request.session[:user_id] = 2
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => 1,
:news => {
:description => ''
}
}
+ )
assert_response :success
assert_select_error /description cannot be blank/i
end
def test_destroy
@request.session[:user_id] = 2
- delete :destroy, :params => {
- :id => 1
- }
+ delete(:destroy, :params => {:id => 1})
assert_redirected_to '/projects/ecookbook/news'
assert_nil News.find_by_id(1)
end