Project

General

Profile

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

naoki takaesu, 2019-07-06 04:24

View differences:

app/controllers/projects_controller.rb
54 54
        @projects = scope.to_a
55 55
      }
56 56
      format.api  {
57
        if params[:status]
58
          scope = scope.status(params[:status])
59
        end
57 60
        @offset, @limit = api_offset_and_limit
58 61
        @project_count = scope.count
59 62
        @projects = scope.offset(@offset).limit(@limit).to_a
test/integration/api_test/projects_test.rb
51 51
    assert json['projects'].first.has_key?('id')
52 52
  end
53 53

  
54
  test "GET /projects.json with status=1 should return active projects" do
55
    Project.find_by_name('eCookbook').update_attribute :status, Project::STATUS_CLOSED
56

  
57
    get '/projects.json?status=1'
58
    assert_response :success
59
    json = ActiveSupport::JSON.decode(response.body)
60
    assert json['projects'].any?
61
    assert json['projects'].all? {|p| p['status'] == 1}
62
  end
63

  
54 64
  test "GET /projects.xml with include=issue_categories should return categories" do
55 65
    get '/projects.xml?include=issue_categories'
56 66
    assert_response :success
(2-2/2)