Skip to content

Expose merge_request.closed, .merged, merge_request/:id/commits to API

Created by: doublerebel

Hello,

This is a more complete version of PR #2179 I submitted earlier this year. It exposes a few attributes of MergeRequest which are needed for "pretty" PR merging, as with jresig/pulley, creating pulley-gitlab.

I have rebased the PR against master branch and added RSpec tests for the new features.

Although I learned a ton about RoR while adding this feature, I am stumped by the 2nd test. It fails with:

Failure/Error: get api("/projects/#{project.id}/merge_request/#{merge_request.id}/commits", user)
    ActionController::RoutingError:
       No route matches [GET] "/api/v3/projects/785/merge_request/395/commits"

I have written a rake task helper to show me the API routes:

lib/task/gitlab/api_routes.rake

desc "API Routes"
task api_routes: :environment do
  API::API.routes.each do |api|
    method = api.route_method.ljust(10)
    path = api.route_path
    puts "     #{method} #{path}"
  end
end

Which shows me that my new route does exist in the test environment:

$ sudo -u git -H bundle exec rake api_routes RAILS_ENV=test
...
GET   /:version/projects/:id/merge_request/:merge_request_id/commits(.:format)
...

Does GitLab cache routes? Have I implemented the test incorrectly? I have pored over the sources and tried other solutions to no avail.

Many thanks for GitLab! I am happy to continue work on this PR and appreciate any help or hints from the community.

Best,

Charles

Merge request reports