From 0b4ce8c248eea7a66c9f4f2e422ba0d2596ebbed Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Thu, 4 Jul 2024 10:38:17 +0100 Subject: [PATCH 1/2] Remove support for Ruby v2.7, v3.0 --- .github/workflows/test.yml | 1 - CHANGELOG.md | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1b7861..8035759 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,6 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} - rubygems: 3.4.10 bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run tests run: bundle exec rspec diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a427d7..b212042 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Test controller/view to allow apps to log in without having to interact with the RPF Global Nav component. (#70) +### Removed +- Support for Ruby 2.7, 3.0. + ## [v3.5.0] ### Added From a499587ea0ef213adbca5042f58c51915b89cddf Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Thu, 4 Jul 2024 10:41:59 +0100 Subject: [PATCH 2/2] Somehow I missed this the first time --- .github/workflows/test.yml | 2 +- .rubocop.yml | 2 +- .rubocop_todo.yml | 6 ++--- .tool-versions | 2 +- CHANGELOG.md | 3 --- app/controllers/rpi_auth/test_controller.rb | 2 +- gemfiles/rails_6.1.gemfile.lock | 23 ++++++++++--------- gemfiles/rails_7.0.gemfile.lock | 23 ++++++++++--------- gemfiles/rails_7.1.gemfile.lock | 23 ++++++++++--------- lib/rpi_auth/spec_helpers.rb | 6 ++--- lib/rpi_auth_bypass.rb | 8 +++---- rpi_auth.gemspec | 2 +- spec/dummy/spec/requests/auth_request_spec.rb | 14 +++++------ spec/dummy/spec/requests/home_request_spec.rb | 2 +- .../requests/rpi_auth_test_request_spec.rb | 2 +- spec/dummy/spec/system/login_flow_spec.rb | 4 ++-- spec/rpi_auth_bypass_spec.rb | 2 +- 17 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8035759..58d6498 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.7', '3.1', '3.2'] + ruby-version: ['3.1', '3.2'] gemfile: [ rails_6.1, rails_7.0, rails_7.1 ] env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile diff --git a/.rubocop.yml b/.rubocop.yml index a6b42bc..f115c68 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,7 +11,7 @@ inherit_mode: AllCops: NewCops: enable - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.1 Exclude: - 'spec/dummy/config/**/*' - 'spec/dummy/app/**/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 701fff0..2d74bf3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-07-02 19:48:59 UTC using RuboCop version 1.64.1. +# on 2024-07-04 09:30:17 UTC using RuboCop version 1.64.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,7 +14,7 @@ Gemspec/DevelopmentDependencies: Exclude: - 'rpi_auth.gemspec' -# Offense count: 1 +# Offense count: 2 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 23 @@ -33,7 +33,7 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 6 -# Offense count: 10 +# Offense count: 12 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 diff --git a/.tool-versions b/.tool-versions index 59511e1..13369f6 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -ruby 2.7.8 +ruby 3.1.6 diff --git a/CHANGELOG.md b/CHANGELOG.md index b212042..4a427d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Test controller/view to allow apps to log in without having to interact with the RPF Global Nav component. (#70) -### Removed -- Support for Ruby 2.7, 3.0. - ## [v3.5.0] ### Added diff --git a/app/controllers/rpi_auth/test_controller.rb b/app/controllers/rpi_auth/test_controller.rb index f95a472..4bc0a05 100644 --- a/app/controllers/rpi_auth/test_controller.rb +++ b/app/controllers/rpi_auth/test_controller.rb @@ -10,7 +10,7 @@ class TestController < ActionController::Base layout false def show - render locals: { login_params: login_params, logout_params: logout_params } + render locals: { login_params:, logout_params: } end private diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index aa5fa4e..4231049 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -77,11 +77,11 @@ GEM bindata (2.5.0) builder (3.3.0) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -95,13 +95,12 @@ GEM email_validator (2.2.4) activemodel erubi (1.13.0) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + faraday (2.9.2) + faraday-net_http (>= 2.0, < 3.2) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.0.2) + faraday-net_http (3.1.0) + net-http ffi (1.17.0) globalid (1.2.1) activesupport (>= 6.1) @@ -134,6 +133,8 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.24.1) + net-http (0.4.1) + uri net-imap (0.4.14) date net-protocol @@ -144,7 +145,7 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.15.6) + nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) omniauth (2.1.2) @@ -180,7 +181,7 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (5.1.1) + public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) racc (1.8.0) @@ -273,10 +274,9 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (3.0.1) + rubocop-rspec (3.0.2) rubocop (~> 1.61) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -301,6 +301,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 26e5e5d..8841cea 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -83,11 +83,11 @@ GEM bindata (2.5.0) builder (3.3.0) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -101,13 +101,12 @@ GEM email_validator (2.2.4) activemodel erubi (1.13.0) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + faraday (2.9.2) + faraday-net_http (>= 2.0, < 3.2) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.0.2) + faraday-net_http (3.1.0) + net-http ffi (1.17.0) globalid (1.2.1) activesupport (>= 6.1) @@ -140,6 +139,8 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.24.1) + net-http (0.4.1) + uri net-imap (0.4.14) date net-protocol @@ -150,7 +151,7 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.15.6) + nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) omniauth (2.1.2) @@ -186,7 +187,7 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (5.1.1) + public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) racc (1.8.0) @@ -279,10 +280,9 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (3.0.1) + rubocop-rspec (3.0.2) rubocop (~> 1.61) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -300,6 +300,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 94f47ae..ebb1794 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -93,11 +93,11 @@ GEM bindata (2.5.0) builder (3.3.0) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -113,13 +113,12 @@ GEM email_validator (2.2.4) activemodel erubi (1.13.0) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + faraday (2.9.2) + faraday-net_http (>= 2.0, < 3.2) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.0.2) + faraday-net_http (3.1.0) + net-http ffi (1.17.0) globalid (1.2.1) activesupport (>= 6.1) @@ -157,6 +156,8 @@ GEM mini_portile2 (2.8.7) minitest (5.24.1) mutex_m (0.2.0) + net-http (0.4.1) + uri net-imap (0.4.14) date net-protocol @@ -167,7 +168,7 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.15.6) + nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) omniauth (2.1.2) @@ -205,7 +206,7 @@ GEM pry (>= 0.13, < 0.15) psych (5.1.2) stringio - public_suffix (5.1.1) + public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) racc (1.8.0) @@ -308,10 +309,9 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (3.0.1) + rubocop-rspec (3.0.2) rubocop (~> 1.61) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -330,6 +330,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix diff --git a/lib/rpi_auth/spec_helpers.rb b/lib/rpi_auth/spec_helpers.rb index f371d26..5733fed 100644 --- a/lib/rpi_auth/spec_helpers.rb +++ b/lib/rpi_auth/spec_helpers.rb @@ -5,7 +5,7 @@ module SpecHelpers # This sets up the OmniAuth mock for the given user. It assumes the User # model has an `:user_id` method which returns the users ID, but this can # be changed by setting the `id_param` option. - def stub_auth_for(user:, id_param: :user_id) # rubocop:disable Metrics/AbcSize + def stub_auth_for(user:, id_param: :user_id) expires_in = user.respond_to?(:expires_at) ? user.expires_at.to_i - Time.zone.now.to_i : 3600 token = user.respond_to?(:access_token) ? user.access_token : SecureRandom.hex(16) refresh_token = user.respond_to?(:refresh_token) ? user.refresh_token : SecureRandom.hex(16) @@ -14,7 +14,7 @@ def stub_auth_for(user:, id_param: :user_id) # rubocop:disable Metrics/AbcSize OmniAuth.config.add_mock(:rpi, uid: user.send(id_param), credentials: { - token: token, refresh_token: refresh_token, expires_in: expires_in + token:, refresh_token:, expires_in: }.compact, extra: { raw_info: user.serializable_hash(except: id_param) }) end @@ -24,7 +24,7 @@ def stub_auth_for(user:, id_param: :user_id) # rubocop:disable Metrics/AbcSize # In request specs, we just post directly to `/auth/rpi`, so this can be # called without any prep. def log_in(user:) - stub_auth_for(user: user) + stub_auth_for(user:) # This is a bit grotty, but see if we can call `click_on` (from Capybara, # i.e. system specs) first, and then if that fails fall back to using diff --git a/lib/rpi_auth_bypass.rb b/lib/rpi_auth_bypass.rb index 71807cb..0056346 100644 --- a/lib/rpi_auth_bypass.rb +++ b/lib/rpi_auth_bypass.rb @@ -69,10 +69,10 @@ def add_rpi_mock(uid: RpiAuthBypass::DEFAULT_UID, credentials: RpiAuthBypass::DEFAULT_CREDENTIALS) add_mock(:rpi, { provider: :rpi, - uid: uid, - info: info, - extra: extra, - credentials: credentials + uid:, + info:, + extra:, + credentials: }) end diff --git a/rpi_auth.gemspec b/rpi_auth.gemspec index 4b68211..6200330 100644 --- a/rpi_auth.gemspec +++ b/rpi_auth.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] - spec.required_ruby_version = '>= 2.7.7' + spec.required_ruby_version = '~> 3.1' spec.add_dependency 'omniauth_openid_connect', '~> 0.7.1' spec.add_dependency 'omniauth-rails_csrf_protection', '~> 1.0.0' diff --git a/spec/dummy/spec/requests/auth_request_spec.rb b/spec/dummy/spec/requests/auth_request_spec.rb index 1eafd3b..93b547e 100644 --- a/spec/dummy/spec/requests/auth_request_spec.rb +++ b/spec/dummy/spec/requests/auth_request_spec.rb @@ -36,7 +36,7 @@ describe 'GET /rpi_auth/logout' do it 'clears the current session and redirects to profile' do - log_in(user: user) + log_in(user:) expect(session['current_user']).not_to be_nil previous_id = session.id @@ -51,7 +51,7 @@ let(:return_to) { '/next/page' } it 'redirects to the correct URL' do - log_in(user: user) + log_in(user:) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -62,7 +62,7 @@ let(:return_to) { 'https://a.bad.actor.com/bad/page' } it 'redirects to the correct URL' do - log_in(user: user) + log_in(user:) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -92,7 +92,7 @@ let(:return_to) { '/next/page' } it 'redirects to the correct URL' do - log_in(user: user) + log_in(user:) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -152,7 +152,7 @@ describe 'On successful authentication' do before do - stub_auth_for(user: user) + stub_auth_for(user:) end it 'sets the user in the session and redirects to root path' do @@ -256,7 +256,7 @@ expect(response).to redirect_to('/') end - context 'when the proc resolves to something other than nil' do # rubocop:disable RSpec/NestedGroups + context 'when the proc resolves to something other than nil' do # We use `current_user` and `request.env` here as they're available # in the context of the controller. We use `let!` to make sure the # proc is defined straightaway, rather than later, when `request` and @@ -274,7 +274,7 @@ end end - context 'when the proc raises an exception' do # rubocop:disable RSpec/NestedGroups + context 'when the proc raises an exception' do # We use `current_user` and `request.env` here as they're available # in the context of the controller. We use `let!` to make sure the # proc is defined straightaway, rather than later, when `request` and diff --git a/spec/dummy/spec/requests/home_request_spec.rb b/spec/dummy/spec/requests/home_request_spec.rb index 7763adb..6c2c024 100644 --- a/spec/dummy/spec/requests/home_request_spec.rb +++ b/spec/dummy/spec/requests/home_request_spec.rb @@ -22,7 +22,7 @@ context 'when logged in' do before do - log_in(user: user) + log_in(user:) end it 'displays the user ID' do diff --git a/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb b/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb index d81f6ec..abb4c09 100644 --- a/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb +++ b/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb @@ -22,7 +22,7 @@ context 'when logged in' do before do - log_in(user: user) + log_in(user:) end it 'displays the user ID' do diff --git a/spec/dummy/spec/system/login_flow_spec.rb b/spec/dummy/spec/system/login_flow_spec.rb index e286230..ee5defa 100644 --- a/spec/dummy/spec/system/login_flow_spec.rb +++ b/spec/dummy/spec/system/login_flow_spec.rb @@ -34,7 +34,7 @@ describe 'logging in' do before do - stub_auth_for(user: user) + stub_auth_for(user:) end it do @@ -49,7 +49,7 @@ describe 'Logging out' do before do - log_in(user: user) + log_in(user:) end it do diff --git a/spec/rpi_auth_bypass_spec.rb b/spec/rpi_auth_bypass_spec.rb index 7ca0a35..68bdb90 100644 --- a/spec/rpi_auth_bypass_spec.rb +++ b/spec/rpi_auth_bypass_spec.rb @@ -142,7 +142,7 @@ username: info[:username] } } end - let(:args) { { uid: uid, info: info, extra: extra } } + let(:args) { { uid:, info:, extra: } } it_behaves_like 'a mocked auth object' end