Merged trunk r1773.

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1774 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-08-30 14:41:07 +00:00
parent ab83ed5d8e
commit a377069fb2
398 changed files with 14736 additions and 5683 deletions
@@ -29,24 +29,27 @@ class ProjectsControllerTest < Test::Unit::TestCase
@controller = ProjectsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.session[:user_id] = nil
end
def test_index
get :index
assert_response :success
assert_template 'list'
end
def test_list
get :list
assert_response :success
assert_template 'list'
assert_template 'index'
assert_not_nil assigns(:project_tree)
# Root project as hash key
assert assigns(:project_tree).has_key?(Project.find(1))
assert assigns(:project_tree).keys.include?(Project.find(1))
# Subproject in corresponding value
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
end
def test_index_atom
get :index, :format => 'atom'
assert_response :success
assert_template 'common/feed.atom.rxml'
assert_select 'feed>title', :text => 'Redmine: Latest projects'
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
end
def test_show_by_id
get :show, :id => 1
@@ -63,6 +66,21 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
end
def test_private_subprojects_hidden
get :show, :id => 'ecookbook'
assert_response :success
assert_template 'show'
assert_no_tag :tag => 'a', :content => /Private child/
end
def test_private_subprojects_visible
@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_tag :tag => 'a', :content => /Private child/
end
def test_settings
@request.session[:user_id] = 2 # manager
get :settings, :id => 1
@@ -73,7 +91,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
def test_edit
@request.session[:user_id] = 2 # manager
post :edit, :id => 1, :project => {:name => 'Test changed name',
:custom_field_ids => ['']}
:issue_custom_field_ids => ['']}
assert_redirected_to 'projects/settings/ecookbook'
project = Project.find(1)
assert_equal 'Test changed name', project.name
@@ -135,22 +153,20 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_response :success
assert_template 'activity'
assert_not_nil assigns(:events_by_day)
assert_not_nil assigns(:events)
# subproject issue not included by default
assert !assigns(:events).include?(Issue.find(5))
assert_tag :tag => "h3",
:content => /#{2.days.ago.to_date.day}/,
:sibling => { :tag => "dl",
:child => { :tag => "dt",
:attributes => { :class => 'issue-edit' },
:attributes => { :class => /issue-edit/ },
:child => { :tag => "a",
:content => /(#{IssueStatus.find(2).name})/,
}
}
}
end
def test_previous_project_activity
get :activity, :id => 1, :from => 3.days.ago.to_date
assert_response :success
assert_template 'activity'
@@ -160,7 +176,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
:content => /#{3.day.ago.to_date.day}/,
:sibling => { :tag => "dl",
:child => { :tag => "dt",
:attributes => { :class => 'issue' },
:attributes => { :class => /issue/ },
:child => { :tag => "a",
:content => /#{Issue.find(1).subject}/,
}
@@ -168,53 +184,30 @@ class ProjectsControllerTest < Test::Unit::TestCase
}
end
def test_activity_with_subprojects
get :activity, :id => 1, :with_subprojects => 1
assert_response :success
assert_template 'activity'
assert_not_nil assigns(:events)
assert assigns(:events).include?(Issue.find(1))
assert !assigns(:events).include?(Issue.find(4))
# subproject issue
assert assigns(:events).include?(Issue.find(5))
end
def test_global_activity_anonymous
def test_global_activity
get :activity
assert_response :success
assert_template 'activity'
assert_not_nil assigns(:events)
assert_not_nil assigns(:events_by_day)
assert assigns(:events).include?(Issue.find(1))
# Issue of a private project
assert !assigns(:events).include?(Issue.find(4))
assert_tag :tag => "h3",
:content => /#{5.day.ago.to_date.day}/,
:sibling => { :tag => "dl",
:child => { :tag => "dt",
:attributes => { :class => /issue/ },
:child => { :tag => "a",
:content => /#{Issue.find(5).subject}/,
}
}
}
end
def test_global_activity_logged_user
@request.session[:user_id] = 2 # manager
get :activity
def test_activity_atom_feed
get :activity, :format => 'atom'
assert_response :success
assert_template 'activity'
assert_not_nil assigns(:events)
assert assigns(:events).include?(Issue.find(1))
# Issue of a private project the user belongs to
assert assigns(:events).include?(Issue.find(4))
assert_template 'common/feed.atom.rxml'
end
def test_global_activity_with_all_types
get :activity, :show_issues => 1, :show_news => 1, :show_files => 1, :show_documents => 1, :show_changesets => 1, :show_wiki_pages => 1, :show_messages => 1
assert_response :success
assert_template 'activity'
assert_not_nil assigns(:events)
assert assigns(:events).include?(Issue.find(1))
assert !assigns(:events).include?(Issue.find(4))
assert assigns(:events).include?(Message.find(5))
end
def test_calendar
get :calendar, :id => 1
assert_response :success
@@ -222,27 +215,56 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_not_nil assigns(:calendar)
end
def test_calendar_with_subprojects
def test_calendar_with_subprojects_should_not_show_private_subprojects
get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
assert_response :success
assert_template 'calendar'
assert_not_nil assigns(:calendar)
assert_no_tag :tag => 'a', :content => /#6/
end
def test_calendar_with_subprojects_should_show_private_subprojects
@request.session[:user_id] = 2
get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
assert_response :success
assert_template 'calendar'
assert_not_nil assigns(:calendar)
assert_tag :tag => 'a', :content => /#6/
end
def test_gantt
get :gantt, :id => 1
assert_response :success
assert_template 'gantt.rhtml'
assert_not_nil assigns(:events)
events = assigns(:events)
assert_not_nil events
# Issue with start and due dates
i = Issue.find(1)
assert_not_nil i.due_date
assert events.include?(Issue.find(1))
# Issue with without due date but targeted to a version with date
i = Issue.find(2)
assert_nil i.due_date
assert events.include?(i)
end
def test_gantt_with_subprojects
def test_gantt_with_subprojects_should_not_show_private_subprojects
get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
assert_response :success
assert_template 'gantt.rhtml'
assert_not_nil assigns(:events)
assert_no_tag :tag => 'a', :content => /#6/
end
def test_gantt_with_subprojects_should_show_private_subprojects
@request.session[:user_id] = 2
get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
assert_response :success
assert_template 'gantt.rhtml'
assert_not_nil assigns(:events)
assert_tag :tag => 'a', :content => /#6/
end
def test_gantt_export_to_pdf
get :gantt, :id => 1, :format => 'pdf'
assert_response :success
@@ -265,4 +287,33 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_redirected_to 'admin/projects'
assert Project.find(1).active?
end
def test_project_menu
assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
Redmine::MenuManager.map :project_menu do |menu|
menu.push :foo, { :controller => 'projects', :action => 'show' }, :cation => 'Foo'
menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
end
get :show, :id => 1
assert_tag :div, :attributes => { :id => 'main-menu' },
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo' } }
assert_tag :div, :attributes => { :id => 'main-menu' },
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar' },
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
assert_tag :div, :attributes => { :id => 'main-menu' },
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' },
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
# Remove the menu items
Redmine::MenuManager.map :project_menu do |menu|
menu.delete :foo
menu.delete :bar
menu.delete :hello
end
end
end
end