Skip to content

Commit

Permalink
Replace grape-route-helpers with our own grape-path-helpers
Browse files Browse the repository at this point in the history
This gem (https://gitlab.com/gitlab-org/grape-path-helpers) makes a number of changes:

1. Brings in @mdelaossa's changes in reprah/grape-route-helpers#21
2. Fixes some broken specs and code for Grape 1.0+
3. Optimizes the generation of paths by bringing in @dblessing's
   HashWithIndifferentAccess changes in https://gitlab.com/gitlab-org/gitlab-ce/issues/45718#note_70123793

Closes #45718
  • Loading branch information
stanhu committed May 30, 2018
1 parent 5b1416a commit 990af4f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gem 'mysql2', '~> 0.4.10', group: :mysql
gem 'pg', '~> 0.18.2', group: :postgres

gem 'rugged', '~> 0.27'
gem 'grape-route-helpers', '~> 2.1.0'
gem 'grape-path-helpers', '~> 1.0'

gem 'faraday', '~> 0.12'

Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ GEM
signet (~> 0.7)
gpgme (2.0.13)
mini_portile2 (~> 2.1)
grape (1.0.2)
grape (1.0.3)
activesupport
builder
mustermann-grape (~> 1.0.0)
Expand All @@ -358,10 +358,10 @@ GEM
grape-entity (0.7.1)
activesupport (>= 4.0)
multi_json (>= 1.3.2)
grape-route-helpers (2.1.0)
activesupport
grape (>= 0.16.0)
rake
grape-path-helpers (1.0.1)
activesupport (~> 4)
grape (~> 1.0)
rake (~> 12)
grape_logging (1.7.0)
grape
grpc (1.11.0)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ DEPENDENCIES
gpgme
grape (~> 1.0)
grape-entity (~> 0.7.1)
grape-route-helpers (~> 2.1.0)
grape-path-helpers (~> 1.0)
grape_logging (~> 1.7)
grpc (~> 1.11.0)
haml_lint (~> 0.26.0)
Expand Down
5 changes: 5 additions & 0 deletions changelogs/unreleased/sh-use-grape-path-helpers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Replace grape-route-helpers with our own grape-path-helpers
merge_request:
author:
type: performance
51 changes: 0 additions & 51 deletions config/initializers/grape_route_helpers_fix.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/api/helpers/related_resources_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module API
module Helpers
module RelatedResourcesHelpers
include GrapeRouteHelpers::NamedRouteMatcher
include GrapePathHelpers::NamedRouteMatcher

def issues_available?(project, options)
available?(:issues, project, options[:current_user])
Expand Down
14 changes: 0 additions & 14 deletions spec/initializers/grape_route_helpers_fix_spec.rb

This file was deleted.

12 changes: 12 additions & 0 deletions spec/requests/api/merge_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
project.add_reporter(user)
end

describe 'route shadowing' do
include GrapePathHelpers::NamedRouteMatcher

it 'does not occur' do
path = api_v4_projects_merge_requests_path(id: 1)
expect(path).to eq('/api/v4/projects/1/merge_requests')

path = api_v4_projects_merge_requests_path(id: 1, merge_request_iid: 3)
expect(path).to eq('/api/v4/projects/1/merge_requests/3')
end
end

describe 'GET /merge_requests' do
context 'when unauthenticated' do
it 'returns an array of all merge requests' do
Expand Down

0 comments on commit 990af4f

Please sign in to comment.