summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-04-12 07:37:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-04-12 07:37:18 +0000
commit3d1c40cd525feebb0818a29c0940d45ae58203b9 (patch)
tree5172fe6fbcdaa5f655771c15be7096c53981ae0b /test
parent8c6e5513a1c1748f0768944822cc607ed93fd24c (diff)
downloadredmine-3d1c40cd525feebb0818a29c0940d45ae58203b9.tar.gz
redmine-3d1c40cd525feebb0818a29c0940d45ae58203b9.zip
Fixed validation when logging time on issue (#19464).
git-svn-id: http://svn.redmine.org/redmine/trunk@14162 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/timelog_controller_test.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 5f73e5874..38ffcfa2b 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -162,6 +162,56 @@ class TimelogControllerTest < ActionController::TestCase
assert_equal 3, t.user_id
end
+ def test_create_on_project_with_time_tracking_disabled_should_fail
+ Project.find(1).disable_module! :time_tracking
+
+ @request.session[:user_id] = 2
+ assert_no_difference 'TimeEntry.count' do
+ post :create, :time_entry => {
+ :project_id => '1', :issue_id => '',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
+ end
+ end
+
+ def test_create_on_project_without_permission_should_fail
+ Role.find(1).remove_permission! :log_time
+
+ @request.session[:user_id] = 2
+ assert_no_difference 'TimeEntry.count' do
+ post :create, :time_entry => {
+ :project_id => '1', :issue_id => '',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
+ end
+ end
+
+ def test_create_on_issue_in_project_with_time_tracking_disabled_should_fail
+ Project.find(1).disable_module! :time_tracking
+
+ @request.session[:user_id] = 2
+ assert_no_difference 'TimeEntry.count' do
+ post :create, :time_entry => {
+ :project_id => '', :issue_id => '1',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
+ assert_select_error /Issue is invalid/
+ end
+ end
+
+ def test_create_on_issue_in_project_without_permission_should_fail
+ Role.find(1).remove_permission! :log_time
+
+ @request.session[:user_id] = 2
+ assert_no_difference 'TimeEntry.count' do
+ post :create, :time_entry => {
+ :project_id => '', :issue_id => '1',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
+ assert_select_error /Issue is invalid/
+ end
+ end
+
def test_create_and_continue_at_project_level
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do