Project

General

Profile

Feature #19828 » rest-api-filter-on-project-status.diff

naoki takaesu, 2019-07-03 07:30

View differences:

app/controllers/projects_controller.rb
@projects = scope.to_a
}
format.api {
if params[:status]
scope = scope.status(params[:status])
end
@offset, @limit = api_offset_and_limit
@project_count = scope.count
@projects = scope.offset(@offset).limit(@limit).to_a
test/integration/api_test/projects_test.rb
assert json['projects'].first.has_key?('id')
end
test "GET /projects.json with status=1 should return active projects" do
Project.find_by_name('eCookbook').update_attribute :status, Project::STATUS_CLOSED
get '/projects.json?status=1'
assert_response :success
json = ActiveSupport::JSON.decode(response.body)
assert json['projects'].all? {|p| p['status'] == 1}
end
test "GET /projects.xml with include=issue_categories should return categories" do
get '/projects.xml?include=issue_categories'
assert_response :success
(1-1/2)