mirror of
https://github.com/redmine/redmine.git
synced 2025-11-18 03:00:52 +01:00
Adds a few tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@16940 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user