summaryrefslogtreecommitdiffstats
path: root/test/integration/api_test/time_entries_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/api_test/time_entries_test.rb')
-rw-r--r--test/integration/api_test/time_entries_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb
index 70369c079..832619437 100644
--- a/test/integration/api_test/time_entries_test.rb
+++ b/test/integration/api_test/time_entries_test.rb
@@ -59,6 +59,11 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_select 'time_entry id', :text => '2'
end
+ test "GET /time_entries/:id.xml with invalid id should 404" do
+ get '/time_entries/999.xml', :headers => credentials('jsmith')
+ assert_response 404
+ end
+
test "POST /time_entries.xml with issue_id should create time entry" do
assert_difference 'TimeEntry.count' do
post '/time_entries.xml',
@@ -147,6 +152,14 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_select 'errors error', :text => "Hours cannot be blank"
end
+ test "PUT /time_entries/:id.xml without permissions should fail" do
+ put '/time_entries/2.xml',
+ :params => {:time_entry => {:hours => '2.3', :comments => 'API Update'}},
+ :headers => credentials('dlopper')
+
+ assert_response 403
+ end
+
test "DELETE /time_entries/:id.xml should destroy time entry" do
assert_difference 'TimeEntry.count', -1 do
delete '/time_entries/2.xml', :headers => credentials('jsmith')
@@ -155,4 +168,15 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_equal '', @response.body
assert_nil TimeEntry.find_by_id(2)
end
+
+ test "DELETE /time_entries/:id.xml with failure should return errors" do
+ TimeEntry.any_instance.stubs(:destroy).returns(false)
+
+ assert_no_difference 'TimeEntry.count' do
+ delete '/time_entries/2.xml', :headers => credentials('jsmith')
+ end
+ assert_response :unprocessable_entity
+ assert_equal 'application/xml', @response.content_type
+ assert_select 'errors'
+ end
end