Skip to content

Commit

Permalink
Test against rails 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Nov 13, 2023
1 parent 8d663ad commit 2cf5a8a
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "6.0"
- "6.1"
- "7.0"
- "7.1"
ruby:
- "2.7.6"
- "3.0.4"
Expand Down
10 changes: 7 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
appraise "rails_6.0" do
gem "railties", "~> 6.0"
gem "railties", "~> 6.0.0"
gem "net-smtp", require: false # not bundled in ruby 3.1
gem "psych", "< 4" # psych 4 switched from unsafe load to safe load
end

appraise "rails_6.1" do
gem "railties", "~> 6.1"
gem "railties", "~> 6.1.0"
gem "net-smtp", require: false # not bundled in ruby 3.1
end

appraise "rails_7.0" do
gem "railties", "~> 7.0"
gem "railties", "~> 7.0.0"
end

appraise "rails_7.1" do
gem "railties", "~> 7.1.0"
end
2 changes: 1 addition & 1 deletion gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3"
gem "timecop"
gem "railties", "~> 6.0"
gem "railties", "~> 6.0.0"
gem "net-smtp", require: false
gem "psych", "< 4"

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3"
gem "timecop"
gem "railties", "~> 6.1"
gem "railties", "~> 6.1.0"
gem "net-smtp", require: false

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3"
gem "timecop"
gem "railties", "~> 7.0"
gem "railties", "~> 7.0.0"

gemspec path: "../"
21 changes: 21 additions & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "addressable"
gem "ammeter"
gem "appraisal"
gem "capybara"
gem "database_cleaner"
gem "erb_lint", require: false
gem "factory_bot_rails"
gem "nokogiri"
gem "pry", require: false
gem "rails-controller-testing"
gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3"
gem "timecop"
gem "railties", "~> 7.1.0"

gemspec path: "../"
8 changes: 7 additions & 1 deletion lib/clearance/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ def sign_in(user, &block)
clearance_session.sign_in(user, &block)

if signed_in? && Clearance.configuration.rotate_csrf_on_sign_in?
session.delete(:_csrf_token)
if request.respond_to?(:controller_instance) && \
request.controller_instance.respond_to?(:reset_csrf_token)
# Rails 7.1+
request.controller_instance.reset_csrf_token(request)
else
request.session.try(:delete, :_csrf_token)
end
form_authenticity_token
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/clearance/testing/deny_access_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def redirects_to_url?
@failure_message_when_negated <<
"Didn't expect to redirect to #{@url}."
true
rescue MiniTest::Assertion, ::Test::Unit::AssertionFailedError
rescue ::Minitest::Assertion, ::Test::Unit::AssertionFailedError
@failure_message << "Expected to redirect to #{@url} but did not."
false
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Application < Rails::Application

if Rails.version.match?(/^6.0/)
config.active_record.sqlite3.represent_boolean_as_integer = true
else
elsif Rails.version.match?(/^7.0/)
config.active_record.legacy_connection_handling = false
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/cookie_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
it { should_have_one_remember_token }

it "should have the httponly flag set" do
expect(remember_token_cookies.last).to match(/HttpOnly/)
expect(remember_token_cookies.last).to match(/HttpOnly/i)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/request_with_remember_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def request_without_remember_token
end

def remember_token_cookies
cookie_lines = headers["Set-Cookie"].lines.map(&:chomp)
cookie_lines = Array(headers["Set-Cookie"]).join("\n").lines.map(&:chomp)
cookie_lines.select { |name| name =~ /^remember_token/ }
end
end
Expand Down

0 comments on commit 2cf5a8a

Please sign in to comment.