Defect #30073 » 30073-v2.diff
| app/controllers/application_controller.rb (working copy) | ||
|---|---|---|
|
render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
|
||
|
end
|
||
|
# Renders a 200 response for successful updates or deletions via the API
|
||
|
# Renders a 204 response for successful updates or deletions via the API
|
||
|
def render_api_ok
|
||
|
render_api_head :ok
|
||
|
render_api_head :no_content
|
||
|
end
|
||
|
# Renders a head API response
|
||
| test/integration/api_test/api_test.rb (working copy) | ||
|---|---|---|
|
def test_head_response_should_have_empty_body
|
||
|
put '/users/7.xml', :params => {:user => {:login => 'foo'}}, :headers => credentials('admin')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
end
|
||
| test/integration/api_test/attachments_test.rb (working copy) | ||
|---|---|---|
|
test "DELETE /attachments/:id.xml should return ok and delete Attachment" do
|
||
|
assert_difference 'Attachment.count', -1 do
|
||
|
delete '/attachments/7.xml', :headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
assert_nil Attachment.find_by_id(7)
|
||
| ... | ... | |
|
test "DELETE /attachments/:id.json should return ok and delete Attachment" do
|
||
|
assert_difference 'Attachment.count', -1 do
|
||
|
delete '/attachments/7.json', :headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
assert_nil Attachment.find_by_id(7)
|
||
| ... | ... | |
|
:params => {:attachment => {:filename => 'renamed.zip', :description => 'updated'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_equal 'application/json', response.content_type
|
||
|
assert_response :no_content
|
||
|
assert_nil response.content_type
|
||
|
attachment = Attachment.find(7)
|
||
|
assert_equal 'renamed.zip', attachment.filename
|
||
|
assert_equal 'updated', attachment.description
|
||
| test/integration/api_test/groups_test.rb (working copy) | ||
|---|---|---|
|
put "/groups/#{group.id}.xml",
|
||
|
:params => {:group => {:name => 'New name', :user_ids => [2, 3]}},
|
||
|
:headers => credentials('admin')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_equal 'New name', group.reload.name
|
||
| ... | ... | |
|
group = Group.generate!
|
||
|
assert_difference 'Group.count', -1 do
|
||
|
delete "/groups/#{group.id}.xml", :headers => credentials('admin')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
post "/groups/#{group.id}/users.xml",
|
||
|
:params => {:user_id => 5},
|
||
|
:headers => credentials('admin')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
|
assert_include User.find(5), group.reload.users
|
||
| ... | ... | |
|
assert_difference 'group.reload.users.count', -1 do
|
||
|
delete "/groups/#{group.id}/users/8.xml", :headers => credentials('admin')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
|
assert_not_include User.find(8), group.reload.users
|
||
| test/integration/api_test/issue_categories_test.rb (working copy) | ||
|---|---|---|
|
:params => {:issue_category => {:name => 'API Update'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_equal 'API Update', IssueCategory.find(2).name
|
||
|
end
|
||
| ... | ... | |
|
assert_difference 'IssueCategory.count', -1 do
|
||
|
delete '/issue_categories/1.xml', :headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_nil IssueCategory.find_by_id(1)
|
||
|
end
|
||
| ... | ... | |
|
:headers => credentials('jsmith')
|
||
|
end
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_nil IssueCategory.find_by_id(1)
|
||
|
end
|
||
| test/integration/api_test/issue_relations_test.rb (working copy) | ||
|---|---|---|
|
delete '/relations/2.xml', :headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_nil IssueRelation.find_by_id(2)
|
||
|
end
|
||
| test/integration/api_test/issues_test.rb (working copy) | ||
|---|---|---|
|
:params => {:issue => {:subject => 'API update', :notes => 'A new note'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
| ... | ... | |
|
assert_difference('Issue.count', -1) do
|
||
|
delete '/issues/6.xml', :headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
assert_nil Issue.find_by_id(6)
|
||
| ... | ... | |
|
assert_difference('Issue.count', -1) do
|
||
|
delete '/issues/6.json', :headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
assert_nil Issue.find_by_id(6)
|
||
| ... | ... | |
|
:params => {:user_id => 3},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
watcher = Watcher.order('id desc').first
|
||
| ... | ... | |
|
assert_difference 'Watcher.count', -1 do
|
||
|
delete '/issues/1/watchers/3.xml', :headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', response.body
|
||
|
end
|
||
|
assert_equal false, Issue.find(1).watched_by?(User.find(3))
|
||
| ... | ... | |
|
:uploads => [{:token => token, :filename => 'test.txt',
|
||
|
:content_type => 'text/plain'}]}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
| test/integration/api_test/memberships_test.rb (working copy) | ||
|---|---|---|
|
:params => {:membership => {:user_id => 3, :role_ids => [1,2]}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
|
member = Member.find(2)
|
||
| ... | ... | |
|
assert_difference 'Member.count', -1 do
|
||
|
delete '/memberships/2.xml', :headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
|
assert_nil Member.find_by_id(2)
|
||
| test/integration/api_test/projects_test.rb (working copy) | ||
|---|---|---|
|
:params => {:project => {:name => 'API update'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_equal 'application/xml', @response.content_type
|
||
|
assert_nil @response.content_type
|
||
|
project = Project.find(2)
|
||
|
assert_equal 'API update', project.name
|
||
|
end
|
||
| ... | ... | |
|
:params => {:project => {:name => 'API update', :enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}},
|
||
|
:headers => credentials('admin')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
project = Project.find(2)
|
||
|
assert_equal ['issue_tracking', 'news', 'time_tracking'], project.enabled_module_names.sort
|
||
| ... | ... | |
|
:params => {:project => {:name => 'API update', :tracker_ids => [1, 3]}},
|
||
|
:headers => credentials('admin')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
project = Project.find(2)
|
||
|
assert_equal [1, 3], project.trackers.map(&:id).sort
|
||
| ... | ... | |
|
assert_difference('Project.count',-1) do
|
||
|
delete '/projects/2.xml', :headers => credentials('admin')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_nil Project.find_by_id(2)
|
||
|
end
|
||
| test/integration/api_test/time_entries_test.rb (working copy) | ||
|---|---|---|
|
:params => {:time_entry => {:comments => 'API Update'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_equal 'API Update', TimeEntry.find(2).comments
|
||
|
end
|
||
| ... | ... | |
|
assert_difference 'TimeEntry.count', -1 do
|
||
|
delete '/time_entries/2.xml', :headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_nil TimeEntry.find_by_id(2)
|
||
|
end
|
||
| test/integration/api_test/users_test.rb (working copy) | ||
|---|---|---|
|
assert_equal 'jsmith@somenet.foo', user.mail
|
||
|
assert !user.admin?
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
| ... | ... | |
|
assert_equal 'jsmith@somenet.foo', user.mail
|
||
|
assert !user.admin?
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
| ... | ... | |
|
delete '/users/2.xml', :headers => credentials('admin')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
| ... | ... | |
|
delete '/users/2.json', :headers => credentials('admin')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
end
|
||
|
end
|
||
| test/integration/api_test/versions_test.rb (working copy) | ||
|---|---|---|
|
:params => {:version => {:name => 'API update'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_equal 'API update', Version.find(2).name
|
||
|
end
|
||
| ... | ... | |
|
delete '/versions/3.xml', :headers => credentials('jsmith')
|
||
|
end
|
||
|
assert_response :ok
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert_nil Version.find_by_id(3)
|
||
|
end
|
||
| test/integration/api_test/wiki_pages_test.rb (working copy) | ||
|---|---|---|
|
put '/projects/ecookbook/wiki/CookBook_documentation.xml',
|
||
|
:params => {:wiki_page => {:text => 'New content from API', :comments => 'API update'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response 200
|
||
|
assert_response :no_content
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
put '/projects/ecookbook/wiki/CookBook_documentation.xml',
|
||
|
:params => {:wiki_page => {:text => 'New content from API', :comments => 'API update', :version => '3'}},
|
||
|
:headers => credentials('jsmith')
|
||
|
assert_response 200
|
||
|
assert_response :no_content
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
test "DELETE /projects/:project_id/wiki/:title.xml should destroy the page" do
|
||
|
assert_difference 'WikiPage.count', -1 do
|
||
|
delete '/projects/ecookbook/wiki/CookBook_documentation.xml', :headers => credentials('jsmith')
|
||
|
assert_response 200
|
||
|
assert_response :no_content
|
||
|
end
|
||
|
assert_nil WikiPage.find_by_id(1)
|
||
- « Previous
- 1
- 2
- Next »