Skip to content

Commit

Permalink
ci: update tested rails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Oct 14, 2023
1 parent 9a7815c commit 5320885
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 53 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
- rack_3
- rack_2
- rack_1
- rails_7_1
- rails_7_0
- rails_6_1
- rails_6_0
- rails_5_2
- rails_4_2
- dalli3
- dalli2
- redis_5
Expand All @@ -45,34 +45,30 @@ jobs:
ruby: 3.2.2
- gemfile: rails_5_2
ruby: 3.2.2
- gemfile: rails_4_2
ruby: 3.2.2
- gemfile: dalli2
ruby: 3.2.2
- gemfile: rack_1
ruby: 3.1.4
- gemfile: rails_5_2
ruby: 3.1.4
- gemfile: rails_4_2
ruby: 3.1.4
- gemfile: dalli2
ruby: 3.1.4
- gemfile: rack_1
ruby: 3.0.6
- gemfile: rails_5_2
ruby: 3.0.6
- gemfile: rails_4_2
ruby: 3.0.6
- gemfile: dalli2
ruby: 3.0.6
- gemfile: rack_1
ruby: 2.7.8
- gemfile: rails_4_2
ruby: 2.7.8
- gemfile: rails_7_0
ruby: 2.6.10
- gemfile: rails_7_1
ruby: 2.6.10
- gemfile: rails_7_0
ruby: 2.5.8
- gemfile: rails_7_1
ruby: 2.5.8
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
Expand Down
12 changes: 4 additions & 8 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ appraise "rack_1" do
gem "rack-test", ">= 0.6"
end

appraise 'rails_7-1' do
gem 'railties', '~> 7.1.0'
end

appraise 'rails_7-0' do
gem 'railties', '~> 7.0.0'
end
Expand All @@ -37,14 +41,6 @@ appraise 'rails_5-2' do
gem 'railties', '~> 5.2.0'
end

appraise 'rails_4-2' do
gem 'railties', '~> 4.2.0'

# Override rack-test version constraint by making it more loose
# so it's compatible with actionpack 4.2.x
gem "rack-test", ">= 0.6"
end

appraise 'dalli2' do
gem 'dalli', '~> 2.0'
end
Expand Down
8 changes: 0 additions & 8 deletions gemfiles/rails_4_2.gemfile

This file was deleted.

12 changes: 12 additions & 0 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "railties", "~> 7.1.0"

group :maintenance, optional: true do
gem "bake"
gem "bake-gem"
end

gemspec path: "../"
53 changes: 25 additions & 28 deletions spec/rack_attack_instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,38 @@
require_relative "spec_helper"
require 'active_support'

# ActiveSupport::Subscribers added in ~> 4.0.2.0
if ActiveSupport::VERSION::MAJOR > 3
require_relative 'spec_helper'
require 'active_support/subscriber'
class CustomSubscriber < ActiveSupport::Subscriber
@notification_count = 0
require_relative 'spec_helper'
require 'active_support/subscriber'
class CustomSubscriber < ActiveSupport::Subscriber
@notification_count = 0

class << self
attr_accessor :notification_count
end
class << self
attr_accessor :notification_count
end

def throttle(_event)
self.class.notification_count += 1
end
def throttle(_event)
self.class.notification_count += 1
end
end

describe 'Rack::Attack.instrument' do
before do
@period = 60 # Use a long period; failures due to cache key rotation less likely
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
Rack::Attack.throttle('ip/sec', limit: 1, period: @period) { |req| req.ip }
end
describe 'Rack::Attack.instrument' do
before do
@period = 60 # Use a long period; failures due to cache key rotation less likely
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
Rack::Attack.throttle('ip/sec', limit: 1, period: @period) { |req| req.ip }
end

describe "with throttling" do
before do
ActiveSupport::Notifications.stub(:notifier, ActiveSupport::Notifications::Fanout.new) do
CustomSubscriber.attach_to("rack_attack")
2.times { get '/', {}, 'REMOTE_ADDR' => '1.2.3.4' }
end
describe "with throttling" do
before do
ActiveSupport::Notifications.stub(:notifier, ActiveSupport::Notifications::Fanout.new) do
CustomSubscriber.attach_to("rack_attack")
2.times { get '/', {}, 'REMOTE_ADDR' => '1.2.3.4' }
end
end

it 'should instrument without error' do
_(last_response.status).must_equal 429
assert_equal 1, CustomSubscriber.notification_count
end
it 'should instrument without error' do
_(last_response.status).must_equal 429
assert_equal 1, CustomSubscriber.notification_count
end
end
end

0 comments on commit 5320885

Please sign in to comment.