From faf9543827450fcdeb463c8461ef4d483b03f84e Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 11 Jul 2017 08:01:10 -0700 Subject: [PATCH] Use view=simple for simplifying merge requests API --- doc/api/merge_requests.md | 2 +- lib/api/merge_requests.rb | 6 +++--- spec/requests/api/merge_requests_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index fc68e1ee0cf..c90d95e4dd0 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -25,7 +25,7 @@ Parameters: | `order_by`| string | no | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` | | `sort` | string | no | Return requests sorted in `asc` or `desc` order. Default is `desc` | | `milestone` | string | no | Return merge requests for a specific milestone | -| `simple` | boolean | no | Returns the `iid`, URL, title, description, and basic state of merge request | +| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request | | `labels` | string | no | Return merge requests matching a comma separated list of labels | | `created_after` | datetime | no | Return merge requests created after the given time (inclusive) | | `created_before` | datetime | no | Return merge requests created before the given time (inclusive) | diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index aace6553e2e..ac33b2b801c 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -48,7 +48,7 @@ module API merge_requests = paginate(merge_requests) .preload(:target_project) - return merge_requests if params[:simple] + return merge_requests if args[:view] == 'simple' merge_requests .preload(:notes, :author, :assignee, :milestone, :merge_request_diff, :labels) @@ -82,7 +82,7 @@ module API optional :labels, type: String, desc: 'Comma-separated list of label names' optional :created_after, type: DateTime, desc: 'Return merge requests created after the specified time' optional :created_before, type: DateTime, desc: 'Return merge requests created before the specified time' - optional :simple, type: Boolean, default: false, desc: 'Returns the `iid`, URL, title, description, and basic state of merge request' + optional :view, type: String, values: %w[simple], desc: 'If simple, returns the `iid`, URL, title, description, and basic state of merge request' use :pagination end get ":id/merge_requests" do @@ -94,7 +94,7 @@ module API current_user: current_user, project: user_project } - if params[:simple] + if params[:view] == 'simple' options[:with] = Entities::MergeRequestSimple else options[:issuable_metadata] = issuable_meta_data(merge_requests, 'MergeRequest') diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 850c22ff07f..9098ae6bcda 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -70,7 +70,7 @@ describe API::MergeRequests do end it "returns an array of all merge_requests using simple mode" do - get api("/projects/#{project.id}/merge_requests?simple=true", user) + get api("/projects/#{project.id}/merge_requests?view=simple", user) expect(response).to have_http_status(200) expect(response).to include_pagination_headers