From 63d1b20dba78bc99a4f3f9fb57e8262dad7e29d4 Mon Sep 17 00:00:00 2001 From: masayuki oguni Date: Fri, 19 Jan 2024 18:11:00 +0900 Subject: [PATCH] Upgraded to ruby 3.3.0 rails 7.0 fastly-ruby 3.0.0 Add github workflows test --- .github/workflows/ruby.yml | 12 +++++------ .gitignore | 2 ++ .travis.yml | 3 +-- Appraisals | 18 +++++----------- README.md | 8 +++---- Rakefile | 7 +++--- fastly-rails.gemspec | 7 +++--- gemfiles/rails_3.gemfile | 8 ------- gemfiles/rails_4.gemfile | 7 ------ gemfiles/rails_41.gemfile | 7 ------ gemfiles/{rails_5.gemfile => rails_7.gemfile} | 4 ++-- gemfiles/rails_7_1.gemfile | 8 +++++++ .../dummy/app/controllers/books_controller.rb | 4 ++-- test/dummy/config/boot.rb | 2 +- test/dummy/db/test.sqlite3-shm | Bin 0 -> 32768 bytes test/dummy/db/test.sqlite3-wal | Bin 0 -> 560352 bytes .../test/controllers/books_controller_test.rb | 7 +++--- test/dummy/test/factories/books.rb | 6 +++--- .../test/integration/fastly_headers_test.rb | 5 ++--- .../test/lib/remove_set_cookie_header_test.rb | 4 ++-- test/dummy/test/models/book_test.rb | 5 +++-- test/test_helper.rb | 20 +++++++----------- 22 files changed, 59 insertions(+), 85 deletions(-) delete mode 100644 gemfiles/rails_3.gemfile delete mode 100644 gemfiles/rails_4.gemfile delete mode 100644 gemfiles/rails_41.gemfile rename gemfiles/{rails_5.gemfile => rails_7.gemfile} (69%) create mode 100644 gemfiles/rails_7_1.gemfile create mode 100644 test/dummy/db/test.sqlite3-shm create mode 100644 test/dummy/db/test.sqlite3-wal diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 20dafd3..a660de7 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -9,28 +9,28 @@ name: Ruby on: push: - branches: [ "master" ] pull_request: - branches: [ "master" ] + types: + - opened + - synchronize + - reopened permissions: contents: read jobs: test: - runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.6', '2.7', '3.0'] + ruby-version: ['3.2', '3.3'] steps: - uses: actions/checkout@v3 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically diff --git a/.gitignore b/.gitignore index 316a815..75bf929 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ test/dummy/tmp/ test/dummy/.sass-cache gemfiles/*.lock Gemfile.lock +gemfiles/vendor/ +vendor diff --git a/.travis.yml b/.travis.yml index 5458bea..68d7601 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,4 @@ before_script: 'bundle exec rake test:setup' script: 'bundle exec rake test:all' cache: bundler rvm: - - 2.3.3 - - 2.2.2 + - 3.3.0 diff --git a/Appraisals b/Appraisals index dc4de30..e04d285 100644 --- a/Appraisals +++ b/Appraisals @@ -1,17 +1,9 @@ -appraise 'rails-3' do - gem 'rails', '~> 3.2.18' - gem 'test-unit', '~> 3.0' -end - -appraise 'rails-4' do - gem 'rails', '~> 4.0.5' -end - -appraise 'rails-41' do - gem 'rails', '~> 4.1.1' +appraise 'rails-7' do + gem 'rails', '~> 7.0.0' + gem 'rails-controller-testing' end -appraise 'rails-5' do - gem 'rails', '~> 5.0' +appraise 'rails-7_1' do + gem 'rails', '~> 7.1.0' gem 'rails-controller-testing' end diff --git a/README.md b/README.md index 70506ce..6d49497 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ end ### Headers -This plugin adds a `set_cache_control_headers` method to ActionController. You'll need to add this in a `before_filter` or `after_filter` [see note on cookies below](https://github.com/fastly/fastly-rails#sessions-cookies-and-private-data) to any controller action that you wish to edge cache (see example below). The method sets Cache-Control and Surrogate-Control HTTP Headers with a default of 30 days (remember you can configure this, see the initializer setup above). +This plugin adds a `set_cache_control_headers` method to ActionController. You'll need to add this in a `before_action` or `after_filter` [see note on cookies below](https://github.com/fastly/fastly-rails#sessions-cookies-and-private-data) to any controller action that you wish to edge cache (see example below). The method sets Cache-Control and Surrogate-Control HTTP Headers with a default of 30 days (remember you can configure this, see the initializer setup above). It's up to you to set Surrogate-Key headers for objects that you want to be able to purge. @@ -82,10 +82,10 @@ To do this use the `set_surrogate_key_header` method on GET actions. ````ruby class BooksController < ApplicationController - # include this before_filter in controller endpoints that you wish to edge cache - before_filter :set_cache_control_headers, only: [:index, :show] + # include this before_action in controller endpoints that you wish to edge cache + before_action :set_cache_control_headers, only: [:index, :show] # This can be used with any customer actions. Set these headers for GETs that you want to cache - # e.g. before_filter :set_cache_control_headers, only: [:index, :show, :my_custom_action] + # e.g. before_action :set_cache_control_headers, only: [:index, :show, :my_custom_action] def index @books = Book.all diff --git a/Rakefile b/Rakefile index d032fe9..d04190d 100644 --- a/Rakefile +++ b/Rakefile @@ -22,13 +22,13 @@ Bundler::GemHelper.install_tasks namespace :test do desc 'Install dependencies for all tests with appraisal' task :setup do - sh 'bin/rails db:environment:set RAILS_ENV=test 2>&1 >/dev/null || exit 0' - sh 'appraisal install' + sh 'bundle exec appraisal install' end desc 'Run all tests with appraisal' task :all do - sh 'appraisal rake test' + sh 'bundle exec appraisal install' + sh 'bundle exec appraisal rake test' end end @@ -41,5 +41,4 @@ Rake::TestTask.new(:test) do |t| t.verbose = false end - task default: :test diff --git a/fastly-rails.gemspec b/fastly-rails.gemspec index 47c8bb8..e2f4e66 100644 --- a/fastly-rails.gemspec +++ b/fastly-rails.gemspec @@ -15,14 +15,13 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] s.add_dependency "railties", '> 2', '< 8' - s.add_dependency 'fastly', '~> 1.6' + s.add_dependency 'fastly', '~> 3.0.0' s.add_development_dependency "sqlite3" - s.add_development_dependency "database_cleaner" - s.add_development_dependency "factory_girl_rails" + s.add_development_dependency "database_cleaner-active_record" + s.add_development_dependency "factory_bot" s.add_development_dependency "ffaker" s.add_development_dependency "minitest-spec-rails" s.add_development_dependency "appraisal" s.add_development_dependency 'webmock', ((RUBY_VERSION <= '1.9.3') ? '2.2.0' : '>= 2.3.0') - s.add_development_dependency 'rails' end diff --git a/gemfiles/rails_3.gemfile b/gemfiles/rails_3.gemfile deleted file mode 100644 index bbd9aa2..0000000 --- a/gemfiles/rails_3.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 3.2.18" -gem "test-unit", "~> 3.0" - -gemspec :path => "../" diff --git a/gemfiles/rails_4.gemfile b/gemfiles/rails_4.gemfile deleted file mode 100644 index 39a1bd6..0000000 --- a/gemfiles/rails_4.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 4.0.5" - -gemspec :path => "../" diff --git a/gemfiles/rails_41.gemfile b/gemfiles/rails_41.gemfile deleted file mode 100644 index 8dfe1fe..0000000 --- a/gemfiles/rails_41.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 4.1.1" - -gemspec :path => "../" diff --git a/gemfiles/rails_5.gemfile b/gemfiles/rails_7.gemfile similarity index 69% rename from gemfiles/rails_5.gemfile rename to gemfiles/rails_7.gemfile index 265a9a1..2be2eae 100644 --- a/gemfiles/rails_5.gemfile +++ b/gemfiles/rails_7.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "rails", "~> 5.0" +gem "rails", "~> 7.0.0" gem "rails-controller-testing" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_7_1.gemfile b/gemfiles/rails_7_1.gemfile new file mode 100644 index 0000000..45820b6 --- /dev/null +++ b/gemfiles/rails_7_1.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 7.1.0" +gem "rails-controller-testing" + +gemspec path: "../" diff --git a/test/dummy/app/controllers/books_controller.rb b/test/dummy/app/controllers/books_controller.rb index 91aea7f..b527103 100644 --- a/test/dummy/app/controllers/books_controller.rb +++ b/test/dummy/app/controllers/books_controller.rb @@ -1,6 +1,6 @@ class BooksController < ApplicationController - before_filter :set_cache_control_headers, only: [:index, :show] - before_filter :find_book, :only => [:show, :edit, :update, :destroy] + before_action :set_cache_control_headers, only: [:index, :show] + before_action :find_book, :only => [:show, :edit, :update, :destroy] def index @books = Book.all diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index ef36047..6266cfc 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,5 +1,5 @@ # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/db/test.sqlite3-shm b/test/dummy/db/test.sqlite3-shm new file mode 100644 index 0000000000000000000000000000000000000000..2011f03869d0fbb410318c0e4930789c9410fcf6 GIT binary patch literal 32768 zcmeI)M^98y6u|L6f(;9x4vZBW0_s??fCcO#HW09PETC9u_KK)GmoE4QEQl+Y`W;-D zxOL|jFz)b<8I#FmlBbDbVg5I{IrqJL-+AZ#^42H*H9>N02{Q)@Uxzq8%rCKTAKnao z9Q^z#??-1r{kyXF!*2&-ZQtX6c|N52HIjKp(njhwJ5!4>A&$n(O}*z&W3r~qv*~qa z?nPavKO42q%$2Q{Y-ghKj@Eu=ZBf_RzVCOfso%t)fC36Apnw7jD4>7>3Mim}0tzUg zfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7> z3Mim}0tzUgz<(o<6FRQslE+xag`O`Hm`Fa8n9LNWQa~X^Ok+ATh*3-lab_}$Im}}| z3t7w(%Bf@-%So_;Rji?k^=zbuO>7SRWVTXE9oyK>j?m?07kj8@ANx7TVVXEXGcB}o zlw%y{1SdJgY0hw#bDZY_7ir@Xm$|}K+UejL*XiU2H@U@ay6C2dUhZ&@2Rz~l&v?!Y zUh;}$rx}L=Q3A7>ODPLjL>UzsJ z0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7j UD4>7>3Mim}0tzUgz&{Z933mfg0{{R3 literal 0 HcmV?d00001 diff --git a/test/dummy/db/test.sqlite3-wal b/test/dummy/db/test.sqlite3-wal new file mode 100644 index 0000000000000000000000000000000000000000..12130249dbc31cdb0887330a656c91f8f7c08f3b GIT binary patch literal 560352 zcmeI*eQ;IvnFsJ2Kp_G~Q3MvKR6#Tvyt#QLtahny69KCNV%Zf73n;QNDpo;(DvXR< zMHH)*DpGu_h%b>U>UJ$v+Uoj-fP}HaDzd&%Y*CSz3hE}!a=UkOFJq?n%sGKiCU=H& zPB`axKF|5c1Qv@lUtRGRt7*eT;DHr!K6F7Wx_ z2R9`So-*5gG)cvunLvAXVKK0RjXF5FkK+009C72oQ*dK(M*MwymRc#~g6bopOO_RNE>D5FkK+ z009C72oNAZfIzB1u(`nMhXp z+SOO(Rn~OeQv2Da!c*xc#L#cz!2Jf|rasEg&* zMdrpWga82o1PBlyK!5-N0t5&U$c8{}hn%+Ea>rFyPoC0nx;71;WG+zmeE#}t54wA< z_Xx59?HmLM5FkK+009C72oNAZAlm}L_6tnEzTc?NW-iJ}<^uW!vRy#uBS3%v0RjXF z5FkK+009Ew3N-H*NX{4d;rbbuJ%7n-FPSe8Zi!r-009C72oNAZfB*pk1PG)TXi2|7 zNy)&0>E{bH9!WP}VBSqvm2G?d51q^xNUv`%0RjXF5FkK+009C72oPxX0?qpclJf;d z&K)^;*aLI6CEp|PeFUw(+-`sX0RjXF5FkK+009C7_9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<#7bqz%ElWRlu<=N`xr3!Se_C? "{}" ) @no_of_books = 5 - create_list :book, @no_of_books + + FactoryBot.create_list(:book, @no_of_books) end test "index" do @@ -27,7 +28,7 @@ def setup test "show" do expected_id = 1 - get :show, {:id => expected_id} + get :show, params: { id: expected_id} assert_response :success, 'it should return successfully' assert_not_nil assigns(:book), '@book should not be nil' assert_instance_of Book, assigns(:book), 'it should be an instance of a book' @@ -38,7 +39,7 @@ def setup test "create" do expected_name = 'newly-created-book' assert_difference('Book.count') do - post :create, :book => {'name' => expected_name} + post :create, params: { book: { name: expected_name}} end end end diff --git a/test/dummy/test/factories/books.rb b/test/dummy/test/factories/books.rb index a64efcc..2d1f9e6 100644 --- a/test/dummy/test/factories/books.rb +++ b/test/dummy/test/factories/books.rb @@ -1,8 +1,8 @@ # Read about factories at https://github.com/thoughtbot/factory_girl -FactoryGirl.define do +FactoryBot.define do factory :book do - name 'some book name' - service_id 'asdf' + name { 'some book name' } + service_id { 'asdf' } end end diff --git a/test/dummy/test/integration/fastly_headers_test.rb b/test/dummy/test/integration/fastly_headers_test.rb index 61a5bac..73631e5 100644 --- a/test/dummy/test/integration/fastly_headers_test.rb +++ b/test/dummy/test/integration/fastly_headers_test.rb @@ -39,9 +39,8 @@ class FastlyHeadersTest < ActionDispatch::IntegrationTest end test 'POST /books should not have fastly headers/ fastly header values' do - assert_difference('Book.count') do - post '/books', 'book' => { 'name' => 'some new book' } + post '/books', params: { book: { name: 'some new book'}} end assert_nil request.session_options[:skip] @@ -57,7 +56,7 @@ class FastlyHeadersTest < ActionDispatch::IntegrationTest create :book, :id => 1, :name => 'some new book' - put '/books/1', 'id' => 1, 'book' => { 'name' => 'changed book' } + put '/books/1', params: { book: { id: 1, name: 'changed book'}} assert_equal 'changed book', Book.find(1).name diff --git a/test/dummy/test/lib/remove_set_cookie_header_test.rb b/test/dummy/test/lib/remove_set_cookie_header_test.rb index bf8bf19..a007b46 100644 --- a/test/dummy/test/lib/remove_set_cookie_header_test.rb +++ b/test/dummy/test/lib/remove_set_cookie_header_test.rb @@ -28,7 +28,7 @@ end it "keeps 'set-cookie' if no 'surrogate-control' or 'surrogate-key'" do - headers = { "Set-Cookie" => "yes!!" } + headers = { "Set-Cookie" => "yes=!!" } app = Rack::Builder.new do use FastlyRails::Rack::RemoveSetCookieHeader @@ -38,6 +38,6 @@ env = Rack::MockRequest.env_for('/') response = Rack::MockResponse.new(*app.call(env)) - assert_equal response.headers['Set-Cookie'], "yes!!" + assert_equal response.headers['Set-Cookie'], "yes=!!" end end diff --git a/test/dummy/test/models/book_test.rb b/test/dummy/test/models/book_test.rb index 400385c..f929913 100644 --- a/test/dummy/test/models/book_test.rb +++ b/test/dummy/test/models/book_test.rb @@ -8,10 +8,11 @@ describe Book do - let (:book) { create :book, id: 1 } + let (:book) { + FactoryBot.create(:book, id: 1) + } it "should have Fastly::SurrogateKey instance methods" do - [:record_key, :table_key, :purge, :purge_all, :soft_purge, :soft_purge_all].each do |method| assert_respond_to book, method end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3fc4ec0..d3adbb5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,17 +3,13 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rails/test_help" +require "minitest/unit" require "minitest/autorun" -require 'database_cleaner' +require 'database_cleaner/active_record' require 'ffaker' -require 'factory_girl_rails' +require 'factory_bot' require 'webmock/minitest' -begin - require 'rails-controller-testing' -rescue LoadError -end - Rails.backtrace_cleaner.remove_silencers! #include factories @@ -27,10 +23,10 @@ # ActiveSupport::TestCase.fixtures :all # end -ActiveRecord::Migrator.migrate File.expand_path('../dummy/db/migrate/', __FILE__) +ActiveRecord::MigrationContext.new("db/migrate/", ActiveRecord::SchemaMigration).migrate class Minitest::Spec - include FactoryGirl::Syntax::Methods + include FactoryBot::Syntax::Methods before :each do stub_request(:any, "https://api.fastly.com/login"). @@ -44,7 +40,7 @@ class Minitest::Spec ) WebMock.disable_net_connect! - + DatabaseCleaner.strategy = :truncation DatabaseCleaner.start end @@ -55,12 +51,12 @@ class Minitest::Spec end class ActionController::TestCase - include FactoryGirl::Syntax::Methods + include FactoryBot::Syntax::Methods end class ActionDispatch::IntegrationTest include WebMock::API - include FactoryGirl::Syntax::Methods + include FactoryBot::Syntax::Methods def setup stub_request(:any, /.*/).