Enable global time logging at /time_entries/new (#10020).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8691 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-01-21 14:26:51 +00:00
parent 94b621a99f
commit 41eab6615b
6 changed files with 130 additions and 9 deletions
+95 -1
View File
@@ -51,7 +51,24 @@ class TimelogControllerTest < ActionController::TestCase
get :new, :project_id => 1
assert_response :success
assert_template 'new'
assert_no_tag :tag => 'option', :content => 'Inactive Activity'
assert_no_tag 'select', :attributes => {:name => 'time_entry[project_id]'}
assert_no_tag 'option', :content => 'Inactive Activity'
end
def test_new_without_project
@request.session[:user_id] = 3
get :new
assert_response :success
assert_template 'new'
assert_tag 'select', :attributes => {:name => 'time_entry[project_id]'}
end
def test_new_without_project_should_deny_without_permission
Role.all.each {|role| role.remove_permission! :log_time}
@request.session[:user_id] = 3
get :new
assert_response 403
end
def test_get_edit_existing_time
@@ -141,6 +158,18 @@ class TimelogControllerTest < ActionController::TestCase
assert_redirected_to '/projects/ecookbook/issues/1/time_entries/new'
end
def test_create_and_continue_without_project
@request.session[:user_id] = 2
post :create, :time_entry => {:project_id => '1',
:activity_id => '11',
:issue_id => '',
:spent_on => '2008-03-14',
:hours => '7.3'},
:continue => '1'
assert_redirected_to '/time_entries/new'
end
def test_create_without_log_time_permission_should_be_denied
@request.session[:user_id] = 2
Role.find_by_name('Manager').remove_permission! :log_time
@@ -153,6 +182,63 @@ class TimelogControllerTest < ActionController::TestCase
assert_response 403
end
def test_create_with_failure
@request.session[:user_id] = 2
post :create, :project_id => 1,
:time_entry => {:activity_id => '',
:issue_id => '',
:spent_on => '2008-03-14',
:hours => '7.3'}
assert_response :success
assert_template 'new'
end
def test_create_without_project
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do
post :create, :time_entry => {:project_id => '1',
:activity_id => '11',
:issue_id => '',
:spent_on => '2008-03-14',
:hours => '7.3'}
end
assert_redirected_to '/projects/ecookbook/time_entries'
time_entry = TimeEntry.first(:order => 'id DESC')
assert_equal 1, time_entry.project_id
end
def test_create_without_project_should_deny_without_permission
@request.session[:user_id] = 2
Project.find(3).disable_module!(:time_tracking)
assert_no_difference 'TimeEntry.count' do
post :create, :time_entry => {:project_id => '3',
:activity_id => '11',
:issue_id => '',
:spent_on => '2008-03-14',
:hours => '7.3'}
end
assert_response 403
end
def test_create_without_project_with_failure
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
post :create, :time_entry => {:project_id => '1',
:activity_id => '11',
:issue_id => '',
:spent_on => '2008-03-14',
:hours => ''}
end
assert_response :success
assert_tag 'select', :attributes => {:name => 'time_entry[project_id]'},
:child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
end
def test_update
entry = TimeEntry.find(1)
assert_equal 1, entry.issue_id
@@ -289,6 +375,14 @@ class TimelogControllerTest < ActionController::TestCase
:attributes => {:action => "/time_entries", :id => 'query_form'}
end
def test_index_all_projects_should_show_log_time_link
@request.session[:user_id] = 2
get :index
assert_response :success
assert_template 'index'
assert_tag 'a', :attributes => {:href => '/time_entries/new'}, :content => /Log time/
end
def test_index_at_project_level
get :index, :project_id => 'ecookbook'
assert_response :success