mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Removes calls to #assert_template and #assigns in functional tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@15715 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
34828e1816
commit
bb5ccb870c
@ -76,14 +76,8 @@ class ReportsController < ApplicationController
|
||||
@rows = @project.descendants.visible
|
||||
@data = Issue.by_subproject(@project) || []
|
||||
@report_title = l(:field_subproject)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @field
|
||||
format.html {}
|
||||
else
|
||||
format.html { redirect_to :action => 'issue_report', :id => @project }
|
||||
end
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -27,10 +27,8 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
def test_show
|
||||
get :show, :board_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:board)
|
||||
assert_not_nil assigns(:project)
|
||||
assert_not_nil assigns(:topic)
|
||||
|
||||
assert_select 'h2', :text => 'First post'
|
||||
end
|
||||
|
||||
def test_show_should_contain_reply_field_tags_for_quoting
|
||||
@ -54,20 +52,20 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
:board_id => 1)
|
||||
end
|
||||
end
|
||||
get :show, :board_id => 1, :id => 1, :r => message.children.order('id').last.id
|
||||
reply_ids = message.children.map(&:id).sort
|
||||
|
||||
get :show, :board_id => 1, :id => 1, :r => reply_ids.last
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
replies = assigns(:replies)
|
||||
assert_not_nil replies
|
||||
assert_not_include message.children.reorder('id').first, replies
|
||||
assert_include message.children.reorder('id').last, replies
|
||||
|
||||
assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.last}#message-#{reply_ids.last}"
|
||||
assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.first}#message-#{reply_ids.first}", 0
|
||||
end
|
||||
|
||||
def test_show_with_reply_permission
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :board_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
|
||||
assert_select 'div#reply textarea#message_content'
|
||||
end
|
||||
|
||||
@ -85,7 +83,8 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :board_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'input[name=?]', 'message[subject]'
|
||||
end
|
||||
|
||||
def test_get_new_with_invalid_board
|
||||
@ -124,7 +123,8 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :board_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
assert_select 'input[name=?][value=?]', 'message[subject]', 'First post'
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
@ -193,7 +193,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
xhr :get, :quote, :board_id => 1, :id => 3
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
assert_template 'quote'
|
||||
|
||||
assert_include 'RE: First post', response.body
|
||||
assert_include '> An other reply', response.body
|
||||
end
|
||||
@ -204,7 +204,7 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
:board_id => 1,
|
||||
:message => {:subject => "", :content => "Previewed text"}
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_include 'Previewed text', response.body
|
||||
end
|
||||
|
||||
def test_preview_edit
|
||||
@ -214,6 +214,6 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
:board_id => 1,
|
||||
:message => {:subject => "", :content => "Previewed text"}
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_include 'Previewed text', response.body
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,13 +28,13 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'page'
|
||||
assert_select 'h2', 'My page'
|
||||
end
|
||||
|
||||
def test_page
|
||||
get :page
|
||||
assert_response :success
|
||||
assert_template 'page'
|
||||
assert_select 'h2', 'My page'
|
||||
end
|
||||
|
||||
def test_page_with_timelog_block
|
||||
@ -65,9 +65,6 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
def test_my_account_should_show_editable_custom_fields
|
||||
get :account
|
||||
assert_response :success
|
||||
assert_template 'account'
|
||||
assert_equal User.find(2), assigns(:user)
|
||||
|
||||
assert_select 'input[name=?]', 'user[custom_field_values][4]'
|
||||
end
|
||||
|
||||
@ -76,9 +73,6 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :account
|
||||
assert_response :success
|
||||
assert_template 'account'
|
||||
assert_equal User.find(2), assigns(:user)
|
||||
|
||||
assert_select 'input[name=?]', 'user[custom_field_values][4]', 0
|
||||
end
|
||||
|
||||
@ -108,7 +102,6 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
|
||||
assert_redirected_to '/my/account'
|
||||
user = User.find(2)
|
||||
assert_equal user, assigns(:user)
|
||||
assert_equal "Joe", user.firstname
|
||||
assert_equal "jsmith", user.login
|
||||
assert_equal "0100562500", user.custom_value_for(4).value
|
||||
@ -143,7 +136,6 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
def test_get_destroy_should_display_the_destroy_confirmation
|
||||
get :destroy
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_select 'form[action="/my/account/destroy"]' do
|
||||
assert_select 'input[name=confirm]'
|
||||
end
|
||||
@ -154,7 +146,6 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
post :destroy
|
||||
end
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
end
|
||||
|
||||
def test_post_destroy_without_confirmation_should_destroy_account
|
||||
@ -177,25 +168,12 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
def test_change_password
|
||||
get :password
|
||||
assert_response :success
|
||||
assert_template 'password'
|
||||
assert_select 'input[type=password][name=password]'
|
||||
assert_select 'input[type=password][name=new_password]'
|
||||
assert_select 'input[type=password][name=new_password_confirmation]'
|
||||
end
|
||||
|
||||
# non matching password confirmation
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret1234'
|
||||
assert_response :success
|
||||
assert_template 'password'
|
||||
assert_select_error /Password doesn.*t match confirmation/
|
||||
|
||||
# wrong password
|
||||
post :password, :password => 'wrongpassword',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
assert_response :success
|
||||
assert_template 'password'
|
||||
assert_equal 'Wrong password', flash[:error]
|
||||
|
||||
# good password
|
||||
def test_update_password
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
@ -203,6 +181,25 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
assert User.try_to_login('jsmith', 'secret123')
|
||||
end
|
||||
|
||||
def test_update_password_with_non_matching_confirmation
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret1234'
|
||||
assert_response :success
|
||||
assert_select_error /Password doesn.*t match confirmation/
|
||||
assert User.try_to_login('jsmith', 'jsmith')
|
||||
end
|
||||
|
||||
def test_update_password_with_wrong_password
|
||||
# wrong password
|
||||
post :password, :password => 'wrongpassword',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
assert_response :success
|
||||
assert_equal 'Wrong password', flash[:error]
|
||||
assert User.try_to_login('jsmith', 'jsmith')
|
||||
end
|
||||
|
||||
def test_change_password_should_redirect_if_user_cannot_change_its_password
|
||||
User.find(2).update_attribute(:auth_source_id, 1)
|
||||
|
||||
@ -211,7 +208,7 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
assert_redirected_to '/my/account'
|
||||
end
|
||||
|
||||
def test_change_password_should_send_security_notification
|
||||
def test_update_password_should_send_security_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
@ -227,7 +224,6 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
def test_page_layout
|
||||
get :page_layout
|
||||
assert_response :success
|
||||
assert_template 'page_layout'
|
||||
end
|
||||
|
||||
def test_add_block
|
||||
|
||||
@ -29,16 +29,13 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:newss)
|
||||
assert_nil assigns(:project)
|
||||
assert_select 'h3 a', :text => 'eCookbook first release !'
|
||||
end
|
||||
|
||||
def test_index_with_project
|
||||
get :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:newss)
|
||||
assert_select 'h3 a', :text => 'eCookbook first release !'
|
||||
end
|
||||
|
||||
def test_index_with_invalid_project_should_respond_with_404
|
||||
@ -49,8 +46,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
def test_show
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_select 'h2', :text => /eCookbook first release/
|
||||
assert_select 'h2', :text => 'eCookbook first release !'
|
||||
end
|
||||
|
||||
def test_show_should_show_attachments
|
||||
@ -71,7 +67,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_equal News.find(1).comments.to_a.sort_by(&:created_on).reverse, assigns(:comments)
|
||||
|
||||
comments = css_select('#comments .wiki').map(&:text).map(&:strip)
|
||||
assert_equal ["This is an other comment", "my first comment"], comments
|
||||
end
|
||||
|
||||
def test_show_not_found
|
||||
@ -83,7 +81,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_select 'input[name=?]', 'news[title]'
|
||||
end
|
||||
|
||||
def test_post_create
|
||||
@ -126,9 +124,6 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
:description => 'This is the description',
|
||||
:summary => '' }
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_not_nil assigns(:news)
|
||||
assert assigns(:news).new_record?
|
||||
assert_select_error /title cannot be blank/i
|
||||
end
|
||||
|
||||
@ -136,7 +131,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !'
|
||||
end
|
||||
|
||||
def test_put_update
|
||||
@ -165,7 +160,6 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
put :update, :id => 1, :news => { :description => '' }
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_select_error /description cannot be blank/i
|
||||
end
|
||||
|
||||
|
||||
@ -32,25 +32,35 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :issue => {:description => 'Foo'}
|
||||
assert_response :success
|
||||
assert_template 'previews/issue'
|
||||
assert_not_nil assigns(:description)
|
||||
assert_select 'fieldset' do
|
||||
assert_select 'legend', :text => 'Description'
|
||||
assert_select 'p', :text => 'Foo'
|
||||
end
|
||||
end
|
||||
|
||||
def test_preview_issue_notes
|
||||
def test_preview_issue_notes_with_no_change_to_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :id => 1,
|
||||
:issue => {:description => Issue.find(1).description, :notes => 'Foo'}
|
||||
assert_response :success
|
||||
assert_template 'previews/issue'
|
||||
assert_not_nil assigns(:notes)
|
||||
assert_select 'legend', :text => 'Description', :count => 0
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_issue_notes_with_no_change_to_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :id => 1,
|
||||
:issue => {:description => 'Changed description', :notes => 'Foo'}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Description'
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_journal_notes_for_update
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :id => 1, :notes => 'Foo'
|
||||
assert_response :success
|
||||
assert_template 'previews/issue'
|
||||
assert_not_nil assigns(:notes)
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
assert_select 'p', :text => 'Foo'
|
||||
end
|
||||
|
||||
@ -66,8 +76,7 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'notes', :project_id => 2}
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:issue)
|
||||
assert_not_nil assigns(:notes)
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_new_news
|
||||
@ -76,20 +85,15 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
:description => 'News description',
|
||||
:summary => ''}
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_select 'fieldset.preview', :text => /News description/
|
||||
end
|
||||
|
||||
def test_existing_new_news
|
||||
def test_preview_existing_news
|
||||
get :news, :project_id => 1, :id => 2,
|
||||
:news => {:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''}
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_equal News.find(2), assigns(:previewed)
|
||||
assert_not_nil assigns(:attachments)
|
||||
|
||||
assert_select 'fieldset.preview', :text => /News description/
|
||||
end
|
||||
end
|
||||
|
||||
@ -86,7 +86,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_difference 'Member.count' do
|
||||
xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]}, :format => 'js'
|
||||
assert_response :success
|
||||
assert_template 'create'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
member = Member.order('id DESC').first
|
||||
@ -100,7 +99,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Member.count' do
|
||||
xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3]}, :format => 'js'
|
||||
assert_response :success
|
||||
assert_template 'create'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
assert_include 'alert', response.body, "Alert message not sent"
|
||||
@ -119,7 +117,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Member.count' do
|
||||
xhr :put, :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]}, :format => 'js'
|
||||
assert_response :success
|
||||
assert_template 'update'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
assert_equal [2], Member.find(1).role_ids
|
||||
@ -138,7 +135,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_difference 'Member.count', -1 do
|
||||
xhr :delete, :destroy, :user_id => 2, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
assert_nil Member.find_by_id(1)
|
||||
@ -161,7 +157,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_difference 'Group.find(10).members.count' do
|
||||
xhr :post, :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']}
|
||||
assert_response :success
|
||||
assert_template 'create'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
assert_match /OnlineStore/, response.body
|
||||
@ -171,7 +166,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Group.find(10).members.count' do
|
||||
xhr :post, :create, :group_id => 10, :membership => {:project_ids => [999], :role_ids => ['1', '2']}
|
||||
assert_response :success
|
||||
assert_template 'create'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
assert_match /alert/, response.body, "Alert message not sent"
|
||||
@ -187,7 +181,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Group.find(10).members.count' do
|
||||
xhr :post, :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']}
|
||||
assert_response :success
|
||||
assert_template 'update'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
end
|
||||
@ -202,7 +195,6 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
assert_difference 'Group.find(10).members.count', -1 do
|
||||
xhr :delete, :destroy, :group_id => 10, :id => 6
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,10 +33,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_index_by_anonymous_should_not_show_private_projects
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
projects = assigns(:projects)
|
||||
assert_not_nil projects
|
||||
assert projects.all?(&:is_public?)
|
||||
|
||||
assert_select 'ul' do
|
||||
assert_select 'li' do
|
||||
@ -52,7 +48,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_index_atom
|
||||
get :index, :format => 'atom'
|
||||
assert_response :success
|
||||
assert_template 'common/feed'
|
||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||
end
|
||||
@ -60,7 +55,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||||
@request.session[:user_id] = 3
|
||||
get :index
|
||||
assert_template 'index'
|
||||
assert_select 'a[href=?]', '/time_entries'
|
||||
end
|
||||
|
||||
@ -71,15 +65,14 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 3
|
||||
|
||||
get :index
|
||||
assert_template 'index'
|
||||
assert_select 'a[href=?]', '/time_entries', 0
|
||||
end
|
||||
|
||||
test "#index by non-admin user with permission should show add project link" do
|
||||
Role.find(1).add_permission! :add_project
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :index
|
||||
assert_template 'index'
|
||||
assert_select 'a[href=?]', '/projects/new'
|
||||
end
|
||||
|
||||
@ -88,7 +81,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
assert_select 'select[name=?]', 'project[parent_id]'
|
||||
end
|
||||
|
||||
test "#new by non-admin user with add_project permission should accept get" do
|
||||
@ -97,7 +91,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
assert_select 'select[name=?]', 'project[parent_id]', 0
|
||||
end
|
||||
|
||||
@ -108,7 +102,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :new, :parent_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'select[name=?]', 'project[parent_id]' do
|
||||
# parent project selected
|
||||
@ -215,6 +208,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
test "#create by non-admin user with add_project permission should fail with parent_id" do
|
||||
Role.non_member.add_permission! :add_project
|
||||
User.find(9).update! :language => 'en'
|
||||
@request.session[:user_id] = 9
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
@ -227,9 +221,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_kind_of Project, project
|
||||
assert_not_equal [], project.errors[:parent_id]
|
||||
assert_select_error /Subproject of is invalid/
|
||||
end
|
||||
|
||||
test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do
|
||||
@ -246,6 +238,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
project = Project.find_by_name('blog')
|
||||
assert_equal 1, project.parent_id
|
||||
end
|
||||
|
||||
test "#create by non-admin user with add_subprojects permission should fail without parent_id" do
|
||||
@ -262,9 +255,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_kind_of Project, project
|
||||
assert_not_equal [], project.errors[:parent_id]
|
||||
assert_select_error /Subproject of is invalid/
|
||||
end
|
||||
|
||||
test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do
|
||||
@ -283,9 +274,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_kind_of Project, project
|
||||
assert_not_equal [], project.errors[:parent_id]
|
||||
assert_select_error /Subproject of is invalid/
|
||||
end
|
||||
|
||||
def test_create_subproject_with_inherit_members_should_inherit_members
|
||||
@ -318,26 +307,23 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_equal %w(issue_tracking news), project.enabled_module_names.sort
|
||||
%w(issue_tracking news).each do |mod|
|
||||
assert_select 'input[name=?][value=?][checked=checked]', 'project[enabled_module_names][]', mod
|
||||
end
|
||||
assert_select 'input[name=?][checked=checked]', 'project[enabled_module_names][]', :count => 2
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_by_id
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_select '#header h1', :text => "eCookbook"
|
||||
end
|
||||
|
||||
def test_show_by_identifier
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||
|
||||
assert_select 'li', :text => /Development status/
|
||||
assert_select '#header h1', :text => "eCookbook"
|
||||
end
|
||||
|
||||
def test_show_should_not_display_empty_sidebar
|
||||
@ -350,12 +336,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert_select '#main.nosidebar'
|
||||
end
|
||||
|
||||
def test_show_should_display_visible_custom_fields
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
|
||||
assert_select 'li', :text => /Development status/
|
||||
end
|
||||
|
||||
def test_show_should_not_display_hidden_custom_fields
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
|
||||
assert_select 'li', :text => /Development status/, :count => 0
|
||||
end
|
||||
@ -386,9 +378,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
project.custom_values.first.update_attribute(:value, nil)
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||
end
|
||||
|
||||
def show_archived_project_should_be_denied
|
||||
@ -397,14 +386,13 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response 403
|
||||
assert_nil assigns(:project)
|
||||
assert_select 'p', :text => /archived/
|
||||
assert_not_include project.name, response.body
|
||||
end
|
||||
|
||||
def test_show_should_not_show_private_subprojects_that_are_not_visible
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_select 'a', :text => /Private child/, :count => 0
|
||||
end
|
||||
|
||||
@ -412,7 +400,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_select 'a', :text => /Private child/
|
||||
end
|
||||
|
||||
@ -420,14 +407,14 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :settings, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
end
|
||||
|
||||
def test_settings_of_subproject
|
||||
@request.session[:user_id] = 2
|
||||
get :settings, :id => 'private-child'
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
|
||||
assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]'
|
||||
end
|
||||
@ -454,7 +441,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :settings, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/wiki' do
|
||||
assert_select 'input[name=?]', 'wiki[start_page]'
|
||||
@ -474,7 +460,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :id => 1, :project => {:name => ''}
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
|
||||
@ -521,8 +506,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Project.count' do
|
||||
delete :destroy, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
end
|
||||
assert_select '.warning', :text => /Are you sure you want to delete this project/
|
||||
end
|
||||
|
||||
def test_destroy_without_confirmation_should_show_confirmation_with_subprojects
|
||||
@ -531,7 +516,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Project.count' do
|
||||
delete :destroy, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
end
|
||||
assert_select 'strong',
|
||||
:text => ['Private child of eCookbook',
|
||||
@ -603,13 +587,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_copy
|
||||
@request.session[:user_id] = 1 # admin
|
||||
get :copy, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'copy'
|
||||
assert assigns(:project)
|
||||
assert_equal Project.find(1).description, assigns(:project).description
|
||||
assert_nil assigns(:project).id
|
||||
orig = Project.find(1)
|
||||
|
||||
get :copy, :id => orig.id
|
||||
assert_response :success
|
||||
|
||||
assert_select 'textarea[name=?]', 'project[description]', :text => orig.description
|
||||
assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1
|
||||
end
|
||||
|
||||
@ -667,7 +650,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
post :copy, :id => 1, :project => {:name => 'Copy', :identifier => ''}
|
||||
assert_response :success
|
||||
assert_template 'copy'
|
||||
assert_select_error /Identifier cannot be blank/
|
||||
end
|
||||
|
||||
def test_jump_should_redirect_to_active_tab
|
||||
@ -678,13 +661,11 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_jump_should_not_redirect_to_inactive_tab
|
||||
get :show, :id => 3, :jump => 'documents'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
end
|
||||
|
||||
def test_jump_should_not_redirect_to_unknown_tab
|
||||
get :show, :id => 3, :jump => 'foobar'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
end
|
||||
|
||||
def test_body_should_have_project_css_class
|
||||
|
||||
@ -34,7 +34,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]'
|
||||
assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
|
||||
assert_select 'select[name=?]', 'c[]' do
|
||||
@ -47,7 +47,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||
assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])'
|
||||
end
|
||||
@ -169,7 +169,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
post :create, :project_id => 'ecookbook', :query => {:name => ''}
|
||||
end
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'input[name=?]', 'query[name]'
|
||||
end
|
||||
|
||||
@ -294,7 +294,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 4
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
||||
assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]'
|
||||
end
|
||||
@ -303,7 +303,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||
assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]'
|
||||
end
|
||||
@ -312,7 +312,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||
assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])'
|
||||
end
|
||||
@ -321,7 +321,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
||||
assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])'
|
||||
end
|
||||
@ -330,7 +330,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 5
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
assert_select 'select[name=?]', 'query[sort_criteria][0][]' do
|
||||
assert_select 'option[value=priority][selected=selected]'
|
||||
assert_select 'option[value=desc][selected=selected]'
|
||||
@ -381,7 +381,7 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
put :update, :id => 4, :query => {:name => ''}
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_select_error /Name cannot be blank/
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@ -395,7 +395,6 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :subject => 'foo/bar'
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
|
||||
end
|
||||
end
|
||||
|
||||
@ -29,28 +29,13 @@ class ReportsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_issue_report
|
||||
get :issue_report, :id => 1
|
||||
|
||||
assert_response :success
|
||||
assert_template 'issue_report'
|
||||
|
||||
[:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
|
||||
:issues_by_author, :issues_by_subproject, :issues_by_priority].each do |ivar|
|
||||
assert_not_nil assigns(ivar)
|
||||
end
|
||||
|
||||
assert_equal IssuePriority.all.reverse, assigns(:priorities)
|
||||
end
|
||||
|
||||
def test_get_issue_report_details
|
||||
%w(tracker version priority category assigned_to author subproject).each do |detail|
|
||||
get :issue_report_details, :id => 1, :detail => detail
|
||||
|
||||
assert_response :success
|
||||
assert_template 'issue_report_details'
|
||||
assert_not_nil assigns(:field)
|
||||
assert_not_nil assigns(:rows)
|
||||
assert_not_nil assigns(:data)
|
||||
assert_not_nil assigns(:report_title)
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,14 +57,8 @@ class ReportsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_issue_report_details_by_priority
|
||||
get :issue_report_details, :id => 1, :detail => 'priority'
|
||||
assert_equal IssuePriority.all.reverse, assigns(:rows)
|
||||
end
|
||||
|
||||
def test_get_issue_report_details_with_an_invalid_detail
|
||||
get :issue_report_details, :id => 1, :detail => 'invalid'
|
||||
|
||||
assert_redirected_to '/projects/ecookbook/issues/report'
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user