Feature #19828 » rest-api-filter-on-project-status.diff
app/controllers/projects_controller.rb | ||
---|---|---|
51 | 51 |
@projects = scope.to_a |
52 | 52 |
} |
53 | 53 |
format.api { |
54 |
if params[:status] |
|
55 |
scope = scope.status(params[:status]) |
|
56 |
end |
|
54 | 57 |
@offset, @limit = api_offset_and_limit |
55 | 58 |
@project_count = scope.count |
56 | 59 |
@projects = scope.offset(@offset).limit(@limit).to_a |
test/integration/api_test/projects_test.rb | ||
---|---|---|
49 | 49 |
assert json['projects'].first.has_key?('id') |
50 | 50 |
end |
51 | 51 | |
52 |
test "GET /projects.json with status=1 should return active projects" do |
|
53 |
Project.find_by_name('eCookbook').update_attribute :status, Project::STATUS_CLOSED |
|
54 | ||
55 |
get '/projects.json?status=1' |
|
56 |
assert_response :success |
|
57 |
json = ActiveSupport::JSON.decode(response.body) |
|
58 |
assert json['projects'].all? {|p| p['status'] == 1} |
|
59 |
end |
|
60 | ||
52 | 61 |
test "GET /projects.xml with include=issue_categories should return categories" do |
53 | 62 |
get '/projects.xml?include=issue_categories' |
54 | 63 |
assert_response :success |