mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-24 01:11:12 +00:00
cleanup: rubocop: fix Layout/IndentFirstHashElement in test/functional/news_controller_test.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@19222 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
05fd9af7f6
commit
15e8297d81
@ -35,17 +35,13 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
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
|
||||
|
||||
@ -58,9 +54,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
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
|
||||
@ -70,9 +64,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
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
|
||||
@ -83,9 +75,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
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)
|
||||
@ -93,17 +83,13 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
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
|
||||
@ -113,7 +99,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@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',
|
||||
@ -121,6 +109,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/news'
|
||||
|
||||
@ -137,7 +126,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@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',
|
||||
@ -145,9 +136,11 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
},
|
||||
: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
|
||||
@ -157,7 +150,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_create_with_validation_failure
|
||||
@request.session[:user_id] = 2
|
||||
post :create, :params => {
|
||||
post(
|
||||
:create,
|
||||
:params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => '',
|
||||
@ -165,27 +160,29 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
: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
|
||||
@ -196,16 +193,20 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@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
|
||||
@ -214,21 +215,22 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user