diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6f4c316 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + push: + branches: [master, main] + pull_request: + branches: [master, main] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + ruby: ["3.3", "3.4"] + devise: ["4", "5"] + + name: Ruby ${{ matrix.ruby }} / Devise ${{ matrix.devise }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + env: + DEVISE_VERSION: ${{ matrix.devise }} + + - name: Set up database + run: | + cd spec/dummy && bundle exec rake db:schema:load + env: + RAILS_ENV: test + DEVISE_VERSION: ${{ matrix.devise }} + + - name: Run RSpec + run: bundle exec rspec + env: + RAILS_ENV: test + DEVISE_VERSION: ${{ matrix.devise }} + + - name: Run Cucumber + run: bundle exec cucumber + env: + RAILS_ENV: test + DEVISE_VERSION: ${{ matrix.devise }} diff --git a/Gemfile b/Gemfile index f95428c..3e75a70 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,12 @@ source 'https://rubygems.org' # Specify your gem's dependencies in devise_masquerade.gemspec gemspec +if ENV["DEVISE_VERSION"] == "5" + gem "devise", "~> 5.0" +elsif ENV["DEVISE_VERSION"] == "4" + gem "devise", "~> 4.9" +end + group :test do gem 'activerecord', '>= 8.0.3' diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index 768d8f0..2854047 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -7,15 +7,12 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 509cd32..b8dfce0 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_10_22_100000) do +ActiveRecord::Schema[7.2].define(version: 2019_10_22_100000) do create_table "admin_users", force: :cascade do |t| t.string "email", default: "", null: false diff --git a/spec/support/authentication.rb b/spec/support/authentication.rb index ae90b90..0462c6a 100644 --- a/spec/support/authentication.rb +++ b/spec/support/authentication.rb @@ -10,7 +10,7 @@ def current_user def admin_logged_in @admin_user ||= create(:admin_user) - sign_in(:admin, @admin_user) + sign_in(@admin_user, scope: :admin) end def current_admin_user