Skip to content

Commit

Permalink
Update to grape 0.16.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ekampp committed Apr 6, 2016
1 parent 0084963 commit cb95a06
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
47 changes: 26 additions & 21 deletions Gemfile.lock
Expand Up @@ -2,13 +2,13 @@ PATH
remote: .
specs:
grape-throttle (0.0.5)
grape (>= 0.10.0)
grape (>= 0.16.0)
redis (~> 3.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.5)
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
Expand All @@ -24,46 +24,48 @@ GEM
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.2.5)
enumerable-lazy (0.0.1)
equalizer (0.0.11)
fakeredis (0.5.0)
redis (~> 3.0)
grape (0.13.0)
grape (0.16.1)
activesupport
builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
mustermann19 (~> 0.4.3)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)
hashie (3.4.3)
i18n (0.7.0)
ice_nine (0.11.1)
ice_nine (0.11.2)
json (1.8.3)
minitest (5.8.3)
minitest (5.8.4)
multi_json (1.11.2)
multi_xml (0.5.5)
rack (1.6.0)
mustermann19 (0.4.3)
enumerable-lazy
rack (1.6.4)
rack-accept (0.4.5)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-test (0.6.2)
rack-test (0.6.3)
rack (>= 1.0)
redis (3.2.2)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
Expand All @@ -82,3 +84,6 @@ DEPENDENCIES
grape-throttle!
rack-test
rspec (~> 3.0)

BUNDLED WITH
1.11.2
2 changes: 1 addition & 1 deletion grape-throttle.gemspec
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'bundler'
s.add_development_dependency 'fakeredis', '~> 0.5.0'

s.add_runtime_dependency 'grape', '>= 0.10.0'
s.add_runtime_dependency 'grape', '>= 0.16.0'
s.add_runtime_dependency 'redis', '~>3.2'

s.files = ["lib/grape-throttle.rb", "lib/grape/extensions/throttle_extension.rb", "lib/grape/middleware/throttle_middleware.rb"]
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/middleware/throttle_middleware.rb
Expand Up @@ -29,7 +29,7 @@ def before
user_value ||= "ip:#{env['REMOTE_ADDR']}"

r = endpoint.routes.first
rate_key = "#{r.route_method}:#{r.route_path}:#{user_value}"
rate_key = "#{r.request_method}:#{r.path}:#{user_value}"

redis = options[:cache]
begin
Expand Down
2 changes: 1 addition & 1 deletion spec/simple_api_spec.rb
Expand Up @@ -90,7 +90,7 @@ def app
end

it "throws an error if period or limit is missing" do
expect { get("wrong-configuration") }.to raise_exception
expect { get("wrong-configuration") }.to raise_exception ArgumentError, 'Please set a period and limit (see documentation)'
end

it "only throttles if explicitly specified" do
Expand Down

0 comments on commit cb95a06

Please sign in to comment.