New Upstream Release - ruby-responders

Ready changes

Summary

Merged new upstream version: 3.1.0 (was: 3.0.1).

Resulting package

Built on 2023-02-25T03:52 (took 2m42s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases ruby-responders

Lintian Result

Diff

diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml
new file mode 100644
index 0000000..9d234e5
--- /dev/null
+++ b/.github/workflows/rubocop.yml
@@ -0,0 +1,19 @@
+name: RuboCop
+
+on: [push, pull_request]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v3
+
+    - name: Set up Ruby 3.2
+      uses: ruby/setup-ruby@v1
+      with:
+        ruby-version: 3.2
+        bundler-cache: true
+
+    - name: Run RuboCop
+      run: bundle exec rubocop --parallel
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..b9da04c
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,51 @@
+name: Test
+on: [push, pull_request]
+jobs:
+  test:
+    strategy:
+      fail-fast: false
+      matrix:
+        gemfile:
+          - Gemfile
+          - gemfiles/Gemfile-rails-main
+          - gemfiles/Gemfile-rails-6-1
+          - gemfiles/Gemfile-rails-6-0
+          - gemfiles/Gemfile-rails-5-2
+        ruby:
+          - '3.2'
+          - '3.1'
+          - '3.0'
+          - '2.7'
+          - '2.6'
+          - '2.5'
+        exclude:
+          - gemfile: Gemfile
+            ruby: '2.6'
+          - gemfile: Gemfile
+            ruby: '2.5'
+          - gemfile: gemfiles/Gemfile-rails-main
+            ruby: '2.6'
+          - gemfile: gemfiles/Gemfile-rails-main
+            ruby: '2.5'
+          - gemfile: gemfiles/Gemfile-rails-6-0
+            ruby: '3.2'
+          - gemfile: gemfiles/Gemfile-rails-6-0
+            ruby: '3.1'
+          - gemfile: gemfiles/Gemfile-rails-5-2
+            ruby: '3.2'
+          - gemfile: gemfiles/Gemfile-rails-5-2
+            ruby: '3.1'
+          - gemfile: gemfiles/Gemfile-rails-5-2
+            ruby: '3.0'
+          - gemfile: gemfiles/Gemfile-rails-5-2
+            ruby: '2.7'
+    runs-on: ubuntu-latest
+    env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
+      BUNDLE_GEMFILE: ${{ matrix.gemfile }}
+    steps:
+      - uses: actions/checkout@v3
+      - uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: ${{ matrix.ruby }}
+          bundler-cache: true # runs bundle install and caches installed gems automatically
+      - run: bundle exec rake
diff --git a/.rubocop.yml b/.rubocop.yml
index 94df2ea..e7ca409 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -2,7 +2,7 @@ require:
   - rubocop-performance
 
 AllCops:
-  TargetRubyVersion: 2.4
+  TargetRubyVersion: 2.5
   # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
   # to ignore them, so only the ones explicitly set in this file are enabled.
   DisabledByDefault: true
@@ -15,12 +15,6 @@ Performance:
 Style/AndOr:
   Enabled: true
 
-# Do not use braces for hash literals when they are the last argument of a
-# method call.
-Style/BracesAroundHashParameters:
-  Enabled: true
-  EnforcedStyle: context_dependent
-
 # Align `when` with `case`.
 Layout/CaseIndentation:
   Enabled: true
@@ -64,7 +58,7 @@ Layout/EmptyLinesAroundModuleBody:
 Style/HashSyntax:
   Enabled: true
 
-Layout/IndentFirstArgument:
+Layout/FirstArgumentIndentation:
   Enabled: true
 
 Layout/IndentationConsistency:
@@ -140,11 +134,11 @@ Style/StringLiterals:
   EnforcedStyle: double_quotes
 
 # Detect hard tabs, no hard tabs.
-Layout/Tab:
+Layout/IndentationStyle:
   Enabled: true
 
 # Blank lines should not have any spaces.
-Layout/TrailingBlankLines:
+Layout/TrailingEmptyLines:
   Enabled: true
 
 # No trailing whitespace.
@@ -152,7 +146,7 @@ Layout/TrailingWhitespace:
   Enabled: true
 
 # Use quotes for string literals when they are enough.
-Style/UnneededPercentQ:
+Style/RedundantPercentQ:
   Enabled: true
 
 Lint/AmbiguousOperator:
@@ -171,7 +165,7 @@ Lint/RequireParentheses:
 Lint/ShadowingOuterLocalVariable:
   Enabled: true
 
-Lint/StringConversionInInterpolation:
+Lint/RedundantStringCoercion:
   Enabled: true
 
 Lint/UriEscapeUnescape:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 0f55914..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-sudo: false
-cache: bundler
-language: ruby
-rvm:
-  - '2.4'
-  - '2.5'
-  - '2.6'
-  - '2.7'
-  - ruby-head
-gemfile:
-  - Gemfile
-  - gemfiles/Gemfile-rails.head
-  - gemfiles/Gemfile-rails.6.0.x
-  - gemfiles/Gemfile-rails.5.2.x
-  - gemfiles/Gemfile-rails.5.1.x
-  - gemfiles/Gemfile-rails.5.0.x
-matrix:
-  exclude:
-  - rvm: '2.4'
-    gemfile: gemfiles/Gemfile-rails.6.0.x
-  - rvm: '2.4'
-    gemfile: gemfiles/Gemfile-rails.head
-  - rvm: '2.7'
-    gemfile: gemfiles/Gemfile-rails.5.0.x
-  - rvm: '2.7'
-    gemfile: gemfiles/Gemfile-rails.5.1.x
-  - rvm: '2.7'
-    gemfile: gemfiles/Gemfile-rails.5.2.x
-  allow_failures:
-    - rvm: ruby-head
-    - gemfile: gemfiles/Gemfile-rails.head
-notifications:
-  email: false
-  slack:
-    on_pull_requests: false
-    on_success: change
-    on_failure: always
-    secure: Qr9/3LRW22qAoJ/9mynVKiI1p/AVIdW4GqcaymMjC6KH46EUwtbB4DxBa3K+gfBYOcfDKDe0vt3TUL/FMCgchqHum5QaNrAfSLj6k363sZqqW+dEuEMJO2e+QsIQUexBnDDQIJNSnr5DqoQ5+npZ8YwzWeAp8nRUs5uYI/RlXXo=
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b2d972..7f9c4e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+## Unreleased
+
+
+## 3.1.0
+
+* Add config `responders.redirect_status` to allow overriding the redirect code/status used in redirects. The default is `302 Found`, which matches Rails, but it allows to change responders to redirect with `303 See Other` for example, to make it more compatible with how Hotwire/Turbo expects redirects to work.
+* Add config `responders.error_status` to allow overriding the status code used to respond to `HTML` or `JS` requests that have errors on the resource. The default is `200 OK`, but it allows to change the response to be `422 Unprocessable Entity` in such cases for example, which makes it more consistent with other statuses more commonly used in APIs (like JSON/XML), and works by default with Turbo/Hotwire which expects a 422 on form error HTML responses. Note that changing this may break your application if you're relying on the previous 2xx status to handle error cases.
+* Add support for Ruby 3.0, 3.1, and 3.2, drop support for Ruby < 2.5.
+* Add support for Rails 6.1 and 7.0, drop support for Rails < 5.2.
+* Move CI to GitHub Actions.
+
 ## 3.0.1
 
 * Add support to Ruby 2.7
@@ -13,8 +24,8 @@
 
 ## 2.4.0
 
-* `respond_with` now accepts a new kwargs called `:render` which goes straight to the `render`
-   call after an unsuccessful post request. Usefull if for example you need to render a template
+* `respond_with` now accepts a new kwarg called `:render` which goes straight to the `render`
+   call after an unsuccessful post request. Useful if for example you need to render a template
    which is outside of controller's path eg:
 
    `respond_with resource, render: { template: 'path/to/template' }`
diff --git a/Gemfile b/Gemfile
index d75d2e8..efd3734 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,7 +4,8 @@ source "https://rubygems.org"
 
 gemspec
 
-gem "activemodel"
+gem "activemodel", "~> 7.0.0"
+gem "railties", "~> 7.0.0"
 gem "mocha"
 gem "rails-controller-testing"
 gem "rubocop"
diff --git a/Gemfile.lock b/Gemfile.lock
index 4266c7d..de17fa7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,104 +1,113 @@
 PATH
   remote: .
   specs:
-    responders (3.0.1)
-      actionpack (>= 5.0)
-      railties (>= 5.0)
+    responders (3.1.0)
+      actionpack (>= 5.2)
+      railties (>= 5.2)
 
 GEM
   remote: https://rubygems.org/
   specs:
-    actionpack (6.0.3.1)
-      actionview (= 6.0.3.1)
-      activesupport (= 6.0.3.1)
-      rack (~> 2.0, >= 2.0.8)
+    actionpack (7.0.4)
+      actionview (= 7.0.4)
+      activesupport (= 7.0.4)
+      rack (~> 2.0, >= 2.2.0)
       rack-test (>= 0.6.3)
       rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.0, >= 1.2.0)
-    actionview (6.0.3.1)
-      activesupport (= 6.0.3.1)
+    actionview (7.0.4)
+      activesupport (= 7.0.4)
       builder (~> 3.1)
       erubi (~> 1.4)
       rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.1, >= 1.2.0)
-    activemodel (6.0.3.1)
-      activesupport (= 6.0.3.1)
-    activesupport (6.0.3.1)
+    activemodel (7.0.4)
+      activesupport (= 7.0.4)
+    activesupport (7.0.4)
       concurrent-ruby (~> 1.0, >= 1.0.2)
-      i18n (>= 0.7, < 2)
-      minitest (~> 5.1)
-      tzinfo (~> 1.1)
-      zeitwerk (~> 2.2, >= 2.2.2)
-    ast (2.4.0)
+      i18n (>= 1.6, < 2)
+      minitest (>= 5.1)
+      tzinfo (~> 2.0)
+    ast (2.4.2)
     builder (3.2.4)
-    concurrent-ruby (1.1.6)
+    concurrent-ruby (1.1.10)
     crass (1.0.6)
-    erubi (1.9.0)
-    i18n (1.8.2)
+    erubi (1.12.0)
+    i18n (1.12.0)
       concurrent-ruby (~> 1.0)
-    loofah (2.5.0)
+    json (2.6.3)
+    loofah (2.19.1)
       crass (~> 1.0.2)
       nokogiri (>= 1.5.9)
     method_source (1.0.0)
-    mini_portile2 (2.4.0)
-    minitest (5.14.1)
-    mocha (1.11.2)
-    nokogiri (1.10.9)
-      mini_portile2 (~> 2.4.0)
-    parallel (1.19.1)
-    parser (2.7.1.3)
-      ast (~> 2.4.0)
-    rack (2.2.2)
-    rack-test (1.1.0)
-      rack (>= 1.0, < 3)
-    rails-controller-testing (1.0.4)
-      actionpack (>= 5.0.1.x)
-      actionview (>= 5.0.1.x)
-      activesupport (>= 5.0.1.x)
+    mini_portile2 (2.8.1)
+    minitest (5.17.0)
+    mocha (2.0.2)
+      ruby2_keywords (>= 0.0.5)
+    nokogiri (1.14.0)
+      mini_portile2 (~> 2.8.0)
+      racc (~> 1.4)
+    parallel (1.22.1)
+    parser (3.2.0.0)
+      ast (~> 2.4.1)
+    racc (1.6.2)
+    rack (2.2.6)
+    rack-test (2.0.2)
+      rack (>= 1.3)
+    rails-controller-testing (1.0.5)
+      actionpack (>= 5.0.1.rc1)
+      actionview (>= 5.0.1.rc1)
+      activesupport (>= 5.0.1.rc1)
     rails-dom-testing (2.0.3)
       activesupport (>= 4.2.0)
       nokogiri (>= 1.6)
-    rails-html-sanitizer (1.3.0)
-      loofah (~> 2.3)
-    railties (6.0.3.1)
-      actionpack (= 6.0.3.1)
-      activesupport (= 6.0.3.1)
+    rails-html-sanitizer (1.4.4)
+      loofah (~> 2.19, >= 2.19.1)
+    railties (7.0.4)
+      actionpack (= 7.0.4)
+      activesupport (= 7.0.4)
       method_source
-      rake (>= 0.8.7)
-      thor (>= 0.20.3, < 2.0)
-    rainbow (3.0.0)
-    rake (13.0.1)
-    rexml (3.2.4)
-    rubocop (0.84.0)
+      rake (>= 12.2)
+      thor (~> 1.0)
+      zeitwerk (~> 2.5)
+    rainbow (3.1.1)
+    rake (13.0.6)
+    regexp_parser (2.6.1)
+    rexml (3.2.5)
+    rubocop (1.43.0)
+      json (~> 2.3)
       parallel (~> 1.10)
-      parser (>= 2.7.0.1)
+      parser (>= 3.2.0.0)
       rainbow (>= 2.2.2, < 4.0)
-      rexml
-      rubocop-ast (>= 0.0.3)
+      regexp_parser (>= 1.8, < 3.0)
+      rexml (>= 3.2.5, < 4.0)
+      rubocop-ast (>= 1.24.1, < 2.0)
       ruby-progressbar (~> 1.7)
-      unicode-display_width (>= 1.4.0, < 2.0)
-    rubocop-ast (0.0.3)
-      parser (>= 2.7.0.1)
-    rubocop-performance (1.6.0)
-      rubocop (>= 0.71.0)
-    ruby-progressbar (1.10.1)
-    thor (1.0.1)
-    thread_safe (0.3.6)
-    tzinfo (1.2.7)
-      thread_safe (~> 0.1)
-    unicode-display_width (1.7.0)
-    zeitwerk (2.3.0)
+      unicode-display_width (>= 2.4.0, < 3.0)
+    rubocop-ast (1.24.1)
+      parser (>= 3.1.1.0)
+    rubocop-performance (1.15.2)
+      rubocop (>= 1.7.0, < 2.0)
+      rubocop-ast (>= 0.4.0)
+    ruby-progressbar (1.11.0)
+    ruby2_keywords (0.0.5)
+    thor (1.2.1)
+    tzinfo (2.0.5)
+      concurrent-ruby (~> 1.0)
+    unicode-display_width (2.4.2)
+    zeitwerk (2.6.6)
 
 PLATFORMS
   ruby
 
 DEPENDENCIES
-  activemodel
+  activemodel (~> 7.0.0)
   mocha
   rails-controller-testing
+  railties (~> 7.0.0)
   responders!
   rubocop
   rubocop-performance
 
 BUNDLED WITH
-   2.1.4
+   2.4.5
diff --git a/MIT-LICENSE b/MIT-LICENSE
index 3d32773..8e3d27d 100644
--- a/MIT-LICENSE
+++ b/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2020 Rafael França, Carlos Antônio da Silva
+Copyright (c) 2020-2022 Rafael França, Carlos Antônio da Silva
 Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
 
 Permission is hereby granted, free of charge, to any person obtaining
diff --git a/README.md b/README.md
index 440927c..a7dd034 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,6 @@
 # Responders
 
 [![Gem Version](https://fury-badge.herokuapp.com/rb/responders.svg)](http://badge.fury.io/rb/responders)
-[![Build Status](https://api.travis-ci.org/plataformatec/responders.svg?branch=master)](http://travis-ci.org/heartcombo/responders)
-[![Code Climate](https://codeclimate.com/github/plataformatec/responders.svg)](https://codeclimate.com/github/heartcombo/responders)
 
 A set of responders modules to dry up your Rails app.
 
@@ -213,7 +211,8 @@ assertions on this behavior for your controllers.
 def create
   @widget = Widget.new(widget_params)
   @widget.errors.add(:base, :invalid)
-  # `respond_with` will render the `new` template again.
+  # `respond_with` will render the `new` template again,
+  # and set the status based on the configured `error_status`.
   respond_with @widget
 end
 ```
@@ -238,9 +237,37 @@ class WidgetsController < ApplicationController
     respond_with widget
   end
 end
+```
+
+## Configuring error and redirect statuses
+
+By default, `respond_with` will respond to errors on `HTML` & `JS` requests using the HTTP status code `200 OK`,
+and perform redirects using the HTTP status code `302 Found`, both for backwards compatibility reasons.
 
+You can configure this behavior by setting `config.responders.error_status` and `config.responders.redirect_status` to the desired status codes.
+
+```ruby
+config.responders.error_status = :unprocessable_entity
+config.responders.redirect_status = :see_other
 ```
 
+These can also be set in your custom `ApplicationResponder` if you have generated one: (see install instructions)
+
+```ruby
+class ApplicationResponder < ActionController::Responder
+  self.error_status = :unprocessable_entity
+  self.redirect_status = :see_other
+end
+```
+
+_Note_: the application responder generated for new apps already configures a different set of defaults: `422 Unprocessable Entity` for errors, and `303 See Other` for redirects. _Responders may change the defaults to match these in a future major release._
+
+### Hotwire/Turbo and fetch APIs
+
+Hotwire/Turbo expects successful redirects after form submissions to respond with HTTP status `303 See Other`, and error responses to be 4xx or 5xx statuses, for example `422 Unprocessable Entity` for displaying form validation errors and `500 Internal Server Error` for other server errors. [Turbo documentation: Redirecting After a Form Submission](https://turbo.hotwired.dev/handbook/drive#redirecting-after-a-form-submission).
+
+The example configuration showed above matches the statuses that better integrate with Hotwire/Turbo.
+
 ## Examples
 
 Want more examples ? Check out these blog posts:
@@ -249,10 +276,15 @@ Want more examples ? Check out these blog posts:
 * [Three reasons to love ActionController::Responder](http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder/)
 * [My five favorite things about Rails 3](http://www.engineyard.com/blog/2009/my-five-favorite-things-about-rails-3)
 
+## Supported Ruby / Rails versions
+
+We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
+
+For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
+and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
+
 ## Bugs and Feedback
 
 If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
 
-http://github.com/heartcombo/responders/issues
-
 MIT License. Copyright 2020 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
diff --git a/debian/changelog b/debian/changelog
index 3707c6e..83fb0ce 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-responders (3.1.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sat, 25 Feb 2023 03:50:04 -0000
+
 ruby-responders (3.0.1-2) unstable; urgency=medium
 
   * Team upload.
diff --git a/debian/patches/bundler.patch b/debian/patches/bundler.patch
index a2d3edc..bc337ee 100644
--- a/debian/patches/bundler.patch
+++ b/debian/patches/bundler.patch
@@ -6,13 +6,15 @@ Last-updated: 2014-11-15
 Forwarded: not-needed
 Bug: not-needed
 
---- a/test/test_helper.rb
-+++ b/test/test_helper.rb
+Index: ruby-responders.git/test/test_helper.rb
+===================================================================
+--- ruby-responders.git.orig/test/test_helper.rb
++++ ruby-responders.git/test/test_helper.rb
 @@ -1,6 +1,6 @@
  # frozen_string_literal: true
  
 -require "bundler/setup"
 +#require "bundler/setup"
  require "minitest/autorun"
- require "mocha/setup"
+ require "mocha/minitest"
  
diff --git a/gemfiles/Gemfile-rails-5-2 b/gemfiles/Gemfile-rails-5-2
new file mode 100644
index 0000000..862215e
--- /dev/null
+++ b/gemfiles/Gemfile-rails-5-2
@@ -0,0 +1,8 @@
+source "https://rubygems.org"
+
+gemspec path: ".."
+
+gem "activemodel", "~> 5.2.0"
+gem "railties", "~> 5.2.0"
+gem "mocha"
+gem "rails-controller-testing"
diff --git a/gemfiles/Gemfile-rails-6-0 b/gemfiles/Gemfile-rails-6-0
new file mode 100644
index 0000000..77019c4
--- /dev/null
+++ b/gemfiles/Gemfile-rails-6-0
@@ -0,0 +1,8 @@
+source "https://rubygems.org"
+
+gemspec path: ".."
+
+gem "activemodel", "~> 6.0.0"
+gem "railties", "~> 6.0.0"
+gem "mocha"
+gem "rails-controller-testing"
diff --git a/gemfiles/Gemfile-rails-6-1 b/gemfiles/Gemfile-rails-6-1
new file mode 100644
index 0000000..0e0832b
--- /dev/null
+++ b/gemfiles/Gemfile-rails-6-1
@@ -0,0 +1,8 @@
+source "https://rubygems.org"
+
+gemspec path: ".."
+
+gem "activemodel", "~> 6.1.0"
+gem "railties", "~> 6.1.0"
+gem "mocha"
+gem "rails-controller-testing"
diff --git a/gemfiles/Gemfile-rails-main b/gemfiles/Gemfile-rails-main
new file mode 100644
index 0000000..9f2d16f
--- /dev/null
+++ b/gemfiles/Gemfile-rails-main
@@ -0,0 +1,8 @@
+source 'https://rubygems.org'
+
+gemspec path: '..'
+
+gem 'activemodel', github: 'rails/rails', branch: 'main'
+gem 'railties', github: 'rails/rails', branch: 'main'
+gem 'mocha'
+gem 'rails-controller-testing'
diff --git a/gemfiles/Gemfile-rails.5.0.x b/gemfiles/Gemfile-rails.5.0.x
deleted file mode 100644
index c0ec6b5..0000000
--- a/gemfiles/Gemfile-rails.5.0.x
+++ /dev/null
@@ -1,8 +0,0 @@
-source 'https://rubygems.org'
-
-gemspec path: '..'
-
-gem 'activemodel', github: 'rails/rails', branch: '5-0-stable'
-gem 'railties', github: 'rails/rails', branch: '5-0-stable'
-gem 'mocha'
-gem 'rails-controller-testing'
diff --git a/gemfiles/Gemfile-rails.5.1.x b/gemfiles/Gemfile-rails.5.1.x
deleted file mode 100644
index 83c57ee..0000000
--- a/gemfiles/Gemfile-rails.5.1.x
+++ /dev/null
@@ -1,8 +0,0 @@
-source 'https://rubygems.org'
-
-gemspec path: '..'
-
-gem 'activemodel', github: 'rails/rails', branch: '5-1-stable'
-gem 'railties', github: 'rails/rails', branch: '5-1-stable'
-gem 'mocha'
-gem 'rails-controller-testing'
diff --git a/gemfiles/Gemfile-rails.5.2.x b/gemfiles/Gemfile-rails.5.2.x
deleted file mode 100644
index 10c2d4e..0000000
--- a/gemfiles/Gemfile-rails.5.2.x
+++ /dev/null
@@ -1,8 +0,0 @@
-source 'https://rubygems.org'
-
-gemspec path: '..'
-
-gem 'activemodel', github: 'rails/rails', branch: '5-2-stable'
-gem 'railties', github: 'rails/rails', branch: '5-2-stable'
-gem 'mocha'
-gem 'rails-controller-testing'
diff --git a/gemfiles/Gemfile-rails.6.0.x b/gemfiles/Gemfile-rails.6.0.x
deleted file mode 100644
index 0d0fcc6..0000000
--- a/gemfiles/Gemfile-rails.6.0.x
+++ /dev/null
@@ -1,8 +0,0 @@
-source 'https://rubygems.org'
-
-gemspec path: '..'
-
-gem 'activemodel', '~> 6.0.0'
-gem 'railties', '~> 6.0.0'
-gem 'mocha'
-gem 'rails-controller-testing'
diff --git a/gemfiles/Gemfile-rails.head b/gemfiles/Gemfile-rails.head
deleted file mode 100644
index 826d852..0000000
--- a/gemfiles/Gemfile-rails.head
+++ /dev/null
@@ -1,8 +0,0 @@
-source 'https://rubygems.org'
-
-gemspec path: '..'
-
-gem 'activemodel', github: 'rails/rails'
-gem 'railties', github: 'rails/rails'
-gem 'mocha'
-gem 'rails-controller-testing'
diff --git a/lib/action_controller/respond_with.rb b/lib/action_controller/respond_with.rb
index 7d3d01e..88ba94c 100644
--- a/lib/action_controller/respond_with.rb
+++ b/lib/action_controller/respond_with.rb
@@ -3,7 +3,7 @@
 require "active_support/core_ext/array/extract_options"
 require "action_controller/metal/mime_responds"
 
-module ActionController #:nodoc:
+module ActionController # :nodoc:
   module RespondWith
     extend ActiveSupport::Concern
 
@@ -95,7 +95,10 @@ module ActionController #:nodoc:
     #      i.e. its +show+ action.
     #   2. If there are validation errors, the response
     #      renders a default action, which is <tt>:new</tt> for a
-    #      +post+ request or <tt>:edit</tt> for +patch+ or +put+.
+    #      +post+ request or <tt>:edit</tt> for +patch+ or +put+,
+    #      and the status is set based on the configured `error_status`.
+    #      (defaults to `422 Unprocessable Entity` on new apps,
+    #       `200 OK` for compatibility reasons on old apps.)
     #   Thus an example like this -
     #
     #     respond_to :html, :xml
@@ -116,8 +119,8 @@ module ActionController #:nodoc:
     #           format.html { redirect_to(@user) }
     #           format.xml { render xml: @user }
     #         else
-    #           format.html { render action: "new" }
-    #           format.xml { render xml: @user }
+    #           format.html { render action: "new", status: :unprocessable_entity }
+    #           format.xml { render xml: @user, status: :unprocessable_entity }
     #         end
     #       end
     #     end
@@ -194,7 +197,7 @@ module ActionController #:nodoc:
     #    need to render a template which is outside of controller's path or you
     #    want to override the default http <tt>:status</tt> code, e.g.
     #
-    #    respond_with(resource, render: { template: 'path/to/template', status: 422 })
+    #    respond_with(resource, render: { template: 'path/to/template', status: 418 })
     def respond_with(*resources, &block)
       if self.class.mimes_for_respond_to.empty?
         raise "In order to use respond_with, first you need to declare the " \
@@ -239,7 +242,7 @@ module ActionController #:nodoc:
 
     # Collect mimes declared in the class method respond_to valid for the
     # current action.
-    def collect_mimes_from_class_level #:nodoc:
+    def collect_mimes_from_class_level # :nodoc:
       action = action_name.to_sym
 
       self.class.mimes_for_respond_to.keys.select do |mime|
diff --git a/lib/action_controller/responder.rb b/lib/action_controller/responder.rb
index 7d91465..5c77ba9 100644
--- a/lib/action_controller/responder.rb
+++ b/lib/action_controller/responder.rb
@@ -2,7 +2,7 @@
 
 require "active_support/json"
 
-module ActionController #:nodoc:
+module ActionController # :nodoc:
   # Responsible for exposing a resource to different mime requests,
   # usually depending on the HTTP verb. The responder is triggered when
   # <code>respond_with</code> is called. The simplest case to study is a GET request:
@@ -49,7 +49,7 @@ module ActionController #:nodoc:
   #         format.html { redirect_to(@user) }
   #         format.xml { render xml: @user, status: :created, location: @user }
   #       else
-  #         format.html { render action: "new" }
+  #         format.html { render action: "new", status: :unprocessable_entity }
   #         format.xml { render xml: @user.errors, status: :unprocessable_entity }
   #       end
   #     end
@@ -113,13 +113,16 @@ module ActionController #:nodoc:
   #       if @task.save
   #         flash[:notice] = 'Task was successfully created.'
   #       else
-  #         format.html { render "some_special_template" }
+  #         format.html { render "some_special_template", status: :unprocessable_entity }
   #       end
   #     end
   #   end
   #
   # Using <code>respond_with</code> with a block follows the same syntax as <code>respond_to</code>.
   class Responder
+    class_attribute :error_status, default: :ok, instance_writer: false, instance_predicate: false
+    class_attribute :redirect_status, default: :found, instance_writer: false, instance_predicate: false
+
     attr_reader :controller, :request, :format, :resource, :resources, :options
 
     DEFAULT_ACTIONS_FOR_VERBS = {
@@ -202,9 +205,9 @@ module ActionController #:nodoc:
       if get?
         raise error
       elsif has_errors? && default_action
-        render rendering_options
+        render error_rendering_options
       else
-        redirect_to navigation_location
+        redirect_to navigation_location, status: redirect_status
       end
     end
 
@@ -236,6 +239,8 @@ module ActionController #:nodoc:
     def default_render
       if @default_response
         @default_response.call(options)
+      elsif !get? && has_errors?
+        controller.render({ status: error_status }.merge!(options))
       else
         controller.render(options)
       end
@@ -263,6 +268,8 @@ module ActionController #:nodoc:
     end
 
     def display_errors
+      # TODO: use `error_status` once we switch the default to be `unprocessable_entity`,
+      # otherwise we'd be changing this behavior here now.
       controller.render format => resource_errors, :status => :unprocessable_entity
     end
 
@@ -300,11 +307,11 @@ module ActionController #:nodoc:
       @default_response.present?
     end
 
-    def rendering_options
+    def error_rendering_options
       if options[:render]
         options[:render]
       else
-        { action: default_action }
+        { action: default_action, status: error_status }
       end
     end
   end
diff --git a/lib/generators/responders/install_generator.rb b/lib/generators/responders/install_generator.rb
index d493591..adaff99 100644
--- a/lib/generators/responders/install_generator.rb
+++ b/lib/generators/responders/install_generator.rb
@@ -8,15 +8,19 @@ module Responders
       desc "Creates an initializer with default responder configuration and copy locale file"
 
       def create_responder_file
-        create_file "lib/application_responder.rb", <<-RUBY
-class ApplicationResponder < ActionController::Responder
-  include Responders::FlashResponder
-  include Responders::HttpCacheResponder
-
-  # Redirects resources to the collection path (index action) instead
-  # of the resource path (show action) for POST/PUT/DELETE requests.
-  # include Responders::CollectionResponder
-end
+        create_file "lib/application_responder.rb", <<~RUBY
+          class ApplicationResponder < ActionController::Responder
+            include Responders::FlashResponder
+            include Responders::HttpCacheResponder
+
+            # Redirects resources to the collection path (index action) instead
+            # of the resource path (show action) for POST/PUT/DELETE requests.
+            # include Responders::CollectionResponder
+
+            # Configure default status codes for responding to errors and redirects.
+            self.error_status = :unprocessable_entity
+            self.redirect_status = :see_other
+          end
         RUBY
       end
 
diff --git a/lib/responders.rb b/lib/responders.rb
index f3d1ec1..d28fe3e 100644
--- a/lib/responders.rb
+++ b/lib/responders.rb
@@ -12,7 +12,6 @@ module Responders
   autoload :FlashResponder,      "responders/flash_responder"
   autoload :HttpCacheResponder,  "responders/http_cache_responder"
   autoload :CollectionResponder, "responders/collection_responder"
-  autoload :LocationResponder,   "responders/location_responder"
 
   require "responders/controller_method"
 
@@ -20,6 +19,8 @@ module Responders
     config.responders = ActiveSupport::OrderedOptions.new
     config.responders.flash_keys = [:notice, :alert]
     config.responders.namespace_lookup = false
+    config.responders.error_status = :ok
+    config.responders.redirect_status = :found
 
     # Add load paths straight to I18n, so engines and application can overwrite it.
     require "active_support/i18n"
@@ -28,6 +29,8 @@ module Responders
     initializer "responders.flash_responder" do |app|
       Responders::FlashResponder.flash_keys = app.config.responders.flash_keys
       Responders::FlashResponder.namespace_lookup = app.config.responders.namespace_lookup
+      ActionController::Responder.error_status = app.config.responders.error_status
+      ActionController::Responder.redirect_status = app.config.responders.redirect_status
     end
   end
 end
diff --git a/lib/responders/collection_responder.rb b/lib/responders/collection_responder.rb
index 891ea02..45b7e02 100644
--- a/lib/responders/collection_responder.rb
+++ b/lib/responders/collection_responder.rb
@@ -20,6 +20,7 @@ module Responders
     #
     def navigation_location
       return options[:location] if options[:location]
+
       klass = resources.last.class
 
       if klass.respond_to?(:model_name)
diff --git a/lib/responders/controller_method.rb b/lib/responders/controller_method.rb
index 36835a7..9fc95e7 100644
--- a/lib/responders/controller_method.rb
+++ b/lib/responders/controller_method.rb
@@ -37,6 +37,6 @@ module Responders
   end
 end
 
-ActiveSupport.on_load(:action_controller) do
+ActiveSupport.on_load(:action_controller_base) do
   ActionController::Base.extend Responders::ControllerMethod
 end
diff --git a/lib/responders/flash_responder.rb b/lib/responders/flash_responder.rb
index 107a51c..4f6597c 100644
--- a/lib/responders/flash_responder.rb
+++ b/lib/responders/flash_responder.rb
@@ -72,7 +72,7 @@ module Responders
   #
   #     respond_with(@user, :notice => "Hooray! Welcome!", :alert => "Woot! You failed.")
   #
-  # * :flash_now - Sets the flash message using flash.now. Accepts true, :on_failure or :on_sucess.
+  # * :flash_now - Sets the flash message using flash.now. Accepts true, :on_failure or :on_success.
   #
   # == Configure status keys
   #
@@ -86,15 +86,11 @@ module Responders
   #
   module FlashResponder
     class << self
-      attr_accessor :flash_keys, :namespace_lookup, :helper
+      attr_accessor :flash_keys, :namespace_lookup
     end
 
     self.flash_keys = [ :notice, :alert ]
     self.namespace_lookup = false
-    self.helper = Object.new.extend(
-      ActionView::Helpers::TranslationHelper,
-      ActionView::Helpers::TagHelper
-    )
 
     def initialize(controller, resources, options = {})
       super
@@ -128,7 +124,7 @@ module Responders
       return if controller.flash[status].present?
 
       options = mount_i18n_options(status)
-      message = Responders::FlashResponder.helper.t options[:default].shift, **options
+      message = controller.helpers.t options[:default].shift, **options
       set_flash(status, message)
     end
 
@@ -144,11 +140,11 @@ module Responders
         (default_action && (has_errors? ? @flash_now == :on_failure : @flash_now == :on_success))
     end
 
-    def set_flash_message? #:nodoc:
+    def set_flash_message? # :nodoc:
       !get? && @flash != false
     end
 
-    def mount_i18n_options(status) #:nodoc:
+    def mount_i18n_options(status) # :nodoc:
       options = {
         default: flash_defaults_by_namespace(status),
         resource_name: resource_name,
@@ -164,12 +160,7 @@ module Responders
     end
 
     def controller_interpolation_options
-      if controller.respond_to?(:flash_interpolation_options, true)
-        controller.send(:flash_interpolation_options)
-      elsif controller.respond_to?(:interpolation_options, true)
-        ActiveSupport::Deprecation.warn("[responders] `#{controller.class}#interpolation_options` is deprecated, please rename it to `flash_interpolation_options`.")
-        controller.send(:interpolation_options)
-      end
+      controller.send(:flash_interpolation_options) if controller.respond_to?(:flash_interpolation_options, true)
     end
 
     def resource_name
@@ -180,7 +171,7 @@ module Responders
       end
     end
 
-    def flash_defaults_by_namespace(status) #:nodoc:
+    def flash_defaults_by_namespace(status) # :nodoc:
       defaults = []
       slices   = controller.controller_path.split("/")
       lookup   = Responders::FlashResponder.namespace_lookup
diff --git a/lib/responders/location_responder.rb b/lib/responders/location_responder.rb
deleted file mode 100644
index 5a654f3..0000000
--- a/lib/responders/location_responder.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-module Responders
-  module LocationResponder
-    def self.included(_base)
-      ActiveSupport::Deprecation.warn "Responders::LocationResponder is enabled by default, " \
-                                      "no need to include it", caller
-    end
-  end
-end
diff --git a/lib/responders/version.rb b/lib/responders/version.rb
index 191e4d2..f951807 100644
--- a/lib/responders/version.rb
+++ b/lib/responders/version.rb
@@ -1,5 +1,5 @@
 # frozen_string_literal: true
 
 module Responders
-  VERSION = "3.0.1"
+  VERSION = "3.1.0"
 end
diff --git a/responders.gemspec b/responders.gemspec
index eb5cbf8..84b0f7c 100644
--- a/responders.gemspec
+++ b/responders.gemspec
@@ -14,13 +14,18 @@ Gem::Specification.new do |s|
   s.description = "A set of Rails responders to dry up your application"
   s.authors     = ["José Valim"]
   s.license     = "MIT"
+  s.metadata    = {
+    "homepage_uri"    => "https://github.com/heartcombo/responders",
+    "changelog_uri"   => "https://github.com/heartcombo/responders/blob/master/CHANGELOG.md",
+    "source_code_uri" => "https://github.com/heartcombo/responders",
+    "bug_tracker_uri" => "https://github.com/heartcombo/responders/issues",
+  }
 
-
-  s.required_ruby_version = ">= 2.4.0"
+  s.required_ruby_version = ">= 2.5.0"
 
   s.files         = Dir["CHANGELOG.md", "MIT-LICENSE", "README.md", "lib/**/*"]
   s.require_paths = ["lib"]
 
-  s.add_dependency "railties", ">= 5.0"
-  s.add_dependency "actionpack", ">= 5.0"
+  s.add_dependency "railties", ">= 5.2"
+  s.add_dependency "actionpack", ">= 5.2"
 end
diff --git a/test/action_controller/respond_with_api_test.rb b/test/action_controller/respond_with_api_test.rb
index f39d068..4df0206 100644
--- a/test/action_controller/respond_with_api_test.rb
+++ b/test/action_controller/respond_with_api_test.rb
@@ -3,44 +3,42 @@
 require "test_helper"
 require "support/models"
 
-if defined?(ActionController::API)
-  class ApiRespondWithController < ActionController::API
-    respond_to :json
-
-    def index
-      respond_with [
-        Customer.new("Foo", 1),
-        Customer.new("Bar", 2),
-      ]
-    end
-
-    def create
-      respond_with Customer.new("Foo", 1), location: "http://test.host/"
-    end
+class ApiRespondWithController < ActionController::API
+  respond_to :json
+
+  def index
+    respond_with [
+      Customer.new("Foo", 1),
+      Customer.new("Bar", 2),
+    ]
   end
 
-  class RespondWithAPITest < ActionController::TestCase
-    tests ApiRespondWithController
-
-    def test_api_controller_without_view_rendering
-      @request.accept = "application/json"
-
-      get :index
-      assert_equal 200, @response.status
-      expected = [{ name: "Foo", id: 1 }, { name: "Bar", id: 2 }]
-      assert_equal expected.to_json, @response.body
-
-      post :create
-      assert_equal 201, @response.status
-      expected = { name: "Foo", id: 1 }
-      assert_equal expected.to_json, @response.body
-
-      errors = { name: ["invalid"] }
-      Customer.any_instance.stubs(:errors).returns(errors)
-      post :create
-      assert_equal 422, @response.status
-      expected = { errors: errors }
-      assert_equal expected.to_json, @response.body
-    end
+  def create
+    respond_with Customer.new("Foo", 1), location: "http://test.host/"
+  end
+end
+
+class RespondWithAPITest < ActionController::TestCase
+  tests ApiRespondWithController
+
+  def test_api_controller_without_view_rendering
+    @request.accept = "application/json"
+
+    get :index
+    assert_equal 200, @response.status
+    expected = [{ name: "Foo", id: 1 }, { name: "Bar", id: 2 }]
+    assert_equal expected.to_json, @response.body
+
+    post :create
+    assert_equal 201, @response.status
+    expected = { name: "Foo", id: 1 }
+    assert_equal expected.to_json, @response.body
+
+    errors = { name: ["invalid"] }
+    Customer.any_instance.stubs(:errors).returns(errors)
+    post :create
+    assert_equal 422, @response.status
+    expected = { errors: errors }
+    assert_equal expected.to_json, @response.body
   end
 end
diff --git a/test/action_controller/respond_with_test.rb b/test/action_controller/respond_with_test.rb
index 4711266..3fb81ca 100644
--- a/test/action_controller/respond_with_test.rb
+++ b/test/action_controller/respond_with_test.rb
@@ -10,7 +10,7 @@ class RespondWithController < ApplicationController
 
   respond_to :html, :json, :touch
   respond_to :xml, except: :using_resource_with_block
-  respond_to :js,  only: [ :using_resource_with_block, :using_resource, "using_hash_resource" ]
+  respond_to :js,  only: [ :using_resource_with_block, :using_resource, "using_hash_resource", :using_resource_with_status ]
 
   def using_resource
     respond_with(resource)
@@ -20,6 +20,10 @@ class RespondWithController < ApplicationController
     respond_with(result: resource)
   end
 
+  def using_resource_with_status
+    respond_with(resource, status: 418, template: "respond_with/using_resource")
+  end
+
   def using_resource_with_block
     respond_with(resource) do |format|
       format.csv { render body: "CSV", content_type: "text/csv" }
@@ -170,6 +174,39 @@ class RespondWithControllerTest < ActionController::TestCase
     get :using_resource
     assert_equal "text/javascript", @response.media_type
     assert_equal "alert(\"Hi\");", @response.body
+    assert_equal 200, @response.status
+  end
+
+  def test_using_resource_for_post_with_js_renders_the_template_on_failure
+    @request.accept = "text/javascript"
+    errors = { name: :invalid }
+    Customer.any_instance.stubs(:errors).returns(errors)
+    post :using_resource
+    assert_equal "text/javascript", @response.media_type
+    assert_equal "alert(\"Hi\");", @response.body
+    assert_equal 200, @response.status
+  end
+
+  def test_using_resource_for_post_with_js_renders_the_template_and_yields_configured_error_status_on_failure
+    @request.accept = "text/javascript"
+    errors = { name: :invalid }
+    Customer.any_instance.stubs(:errors).returns(errors)
+    with_error_status(:unprocessable_entity) do
+      post :using_resource
+    end
+    assert_equal "text/javascript", @response.media_type
+    assert_equal "alert(\"Hi\");", @response.body
+    assert_equal 422, @response.status
+  end
+
+  def test_using_resource_for_post_with_js_renders_the_template_and_yields_given_status_on_failure
+    @request.accept = "text/javascript"
+    errors = { name: :invalid }
+    Customer.any_instance.stubs(:errors).returns(errors)
+    post :using_resource_with_status
+    assert_equal "text/javascript", @response.media_type
+    assert_equal "alert(\"Hi\");", @response.body
+    assert_equal 418, @response.status
   end
 
   def test_using_hash_resource_with_js_raises_an_error_if_template_cant_be_found
@@ -188,9 +225,9 @@ class RespondWithControllerTest < ActionController::TestCase
     @request.accept = "application/json"
     get :using_hash_resource
     assert_equal "application/json", @response.media_type
-    assert @response.body.include?("result")
-    assert @response.body.include?('"name":"david"')
-    assert @response.body.include?('"id":13')
+    assert_includes @response.body, "result"
+    assert_includes @response.body, '"name":"david"'
+    assert_includes @response.body, '"id":13'
   end
 
   def test_using_hash_resource_with_post
@@ -257,6 +294,20 @@ class RespondWithControllerTest < ActionController::TestCase
     end
   end
 
+  def test_using_resource_for_post_with_html_rerender_and_yields_configured_error_status_on_failure
+    with_test_route_set do
+      errors = { name: :invalid }
+      Customer.any_instance.stubs(:errors).returns(errors)
+      with_error_status(:unprocessable_entity) do
+        post :using_resource
+      end
+      assert_equal "text/html", @response.media_type
+      assert_equal 422, @response.status
+      assert_equal "New world!\n", @response.body
+      assert_nil @response.location
+    end
+  end
+
   def test_using_resource_for_post_with_xml_yields_created_on_success
     with_test_route_set do
       @request.accept = "application/xml"
@@ -317,6 +368,20 @@ class RespondWithControllerTest < ActionController::TestCase
     end
   end
 
+  def test_using_resource_for_patch_with_html_rerender_and_yields_configured_error_status_on_failure
+    with_test_route_set do
+      errors = { name: :invalid }
+      Customer.any_instance.stubs(:errors).returns(errors)
+      with_error_status(:unprocessable_entity) do
+        patch :using_resource
+      end
+      assert_equal "text/html", @response.media_type
+      assert_equal 422, @response.status
+      assert_equal "Edit world!\n", @response.body
+      assert_nil @response.location
+    end
+  end
+
   def test_using_resource_for_patch_with_html_rerender_on_failure_even_on_method_override
     with_test_route_set do
       errors = { name: :invalid }
@@ -330,6 +395,21 @@ class RespondWithControllerTest < ActionController::TestCase
     end
   end
 
+  def test_using_resource_for_patch_with_html_rerender_and_yields_configured_error_status_on_failure_even_on_method_override
+    with_test_route_set do
+      errors = { name: :invalid }
+      Customer.any_instance.stubs(:errors).returns(errors)
+      @request.env["rack.methodoverride.original_method"] = "POST"
+      with_error_status(:unprocessable_entity) do
+        patch :using_resource
+      end
+      assert_equal "text/html", @response.media_type
+      assert_equal 422, @response.status
+      assert_equal "Edit world!\n", @response.body
+      assert_nil @response.location
+    end
+  end
+
   def test_using_resource_for_put_with_html_redirects_on_success
     with_test_route_set do
       put :using_resource
@@ -345,7 +425,6 @@ class RespondWithControllerTest < ActionController::TestCase
       errors = { name: :invalid }
       Customer.any_instance.stubs(:errors).returns(errors)
       put :using_resource
-
       assert_equal "text/html", @response.media_type
       assert_equal 200, @response.status
       assert_equal "Edit world!\n", @response.body
@@ -353,6 +432,20 @@ class RespondWithControllerTest < ActionController::TestCase
     end
   end
 
+  def test_using_resource_for_put_with_html_rerender_and_yields_configured_error_status_on_failure
+    with_test_route_set do
+      errors = { name: :invalid }
+      Customer.any_instance.stubs(:errors).returns(errors)
+      with_error_status(:unprocessable_entity) do
+        put :using_resource
+      end
+      assert_equal "text/html", @response.media_type
+      assert_equal 422, @response.status
+      assert_equal "Edit world!\n", @response.body
+      assert_nil @response.location
+    end
+  end
+
   def test_using_resource_for_put_with_html_rerender_on_failure_even_on_method_override
     with_test_route_set do
       errors = { name: :invalid }
@@ -366,6 +459,21 @@ class RespondWithControllerTest < ActionController::TestCase
     end
   end
 
+  def test_using_resource_for_put_with_html_rerender_and_yields_configured_error_status_on_failure_even_on_method_override
+    with_test_route_set do
+      errors = { name: :invalid }
+      Customer.any_instance.stubs(:errors).returns(errors)
+      @request.env["rack.methodoverride.original_method"] = "POST"
+      with_error_status(:unprocessable_entity) do
+        put :using_resource
+      end
+      assert_equal "text/html", @response.media_type
+      assert_equal 422, @response.status
+      assert_equal "Edit world!\n", @response.body
+      assert_nil @response.location
+    end
+  end
+
   def test_using_resource_for_put_with_xml_yields_no_content_on_success
     @request.accept = "application/xml"
     put :using_resource
@@ -628,6 +736,24 @@ class RespondWithControllerTest < ActionController::TestCase
     end
   end
 
+  def test_redirect_status_configured_as_see_other
+    with_test_route_set do
+      with_redirect_status(:see_other) do
+        post :using_resource
+        assert_equal 303, @response.status
+      end
+    end
+  end
+
+  def test_redirect_status_configured_as_moved_permanently
+    with_test_route_set do
+      with_redirect_status(:moved_permanently) do
+        patch :using_resource
+        assert_equal 301, @response.status
+      end
+    end
+  end
+
   private
 
   def with_test_route_set
@@ -644,16 +770,27 @@ class RespondWithControllerTest < ActionController::TestCase
       yield
     end
   end
+
+  def with_error_status(status)
+    old_status = ActionController::Responder.error_status
+    ActionController::Responder.error_status = status
+    yield
+  ensure
+    ActionController::Responder.error_status = old_status
+  end
+
+  def with_redirect_status(status)
+    old_status = ActionController::Responder.redirect_status
+    ActionController::Responder.redirect_status = status
+    yield
+  ensure
+    ActionController::Responder.redirect_status = old_status
+  end
 end
 
 class LocationsController < ApplicationController
   respond_to :html
-  # TODO: Remove this when we drop support for Rails 4.2.
-  if respond_to?(:before_action)
-    before_action :set_resource
-  else
-    before_filter :set_resource
-  end
+  before_action :set_resource
 
   def create
     respond_with @resource, location: -> { "given_location" }
@@ -665,7 +802,7 @@ class LocationsController < ApplicationController
 
   def set_resource
     @resource = Address.new
-    @resource.errors[:fail] << "FAIL" if params[:fail]
+    @resource.errors.add(:fail, "FAIL") if params[:fail]
   end
 end
 
@@ -679,7 +816,7 @@ class LocationResponderTest < ActionController::TestCase
 
   def test_renders_page_on_fail
     post :create, params: { fail: true }
-    assert @response.body.include?("new.html.erb")
+    assert_includes @response.body, "new.html.erb"
   end
 
   def test_redirects_to_plain_string
diff --git a/test/responders/flash_responder_test.rb b/test/responders/flash_responder_test.rb
index c6681aa..670c116 100644
--- a/test/responders/flash_responder_test.rb
+++ b/test/responders/flash_responder_test.rb
@@ -7,11 +7,7 @@ class FlashResponder < ActionController::Responder
 end
 
 class AddressesController < ApplicationController
-  if respond_to?(:before_action)
-    before_action :set_resource
-  else
-    before_filter :set_resource
-  end
+  before_action :set_resource
   self.responder = FlashResponder
 
   respond_to :js, only: :create
@@ -70,7 +66,7 @@ class AddressesController < ApplicationController
 
   def set_resource
     @resource = Address.new
-    @resource.errors[:fail] << "FAIL" if params[:fail]
+    @resource.errors.add(:fail, "FAIL") if params[:fail]
   end
 end
 
@@ -214,17 +210,13 @@ class FlashResponderTest < ActionController::TestCase
     assert_not_flash_now :failure
   end
 
-  # If we have flash.now, it's always marked as used. Rails 4.1 has string keys,
-  # whereas 3.2 and 4.0 has symbols, so we need to test both.
   def assert_flash_now(k)
-    assert flash.used_keys.include?(k.to_sym) || flash.used_keys.include?(k.to_s),
-     "Expected #{k} to be in flash.now, but it's not."
+    assert_includes flash.used_keys, k.to_s, "Expected #{k} to be in flash.now, but it's not."
   end
 
   def assert_not_flash_now(k)
     assert flash[k], "Expected #{k} to be set"
-    assert !flash.used_keys.include?(k.to_sym),
-     "Expected #{k} to not be in flash.now, but it is."
+    assert_not_includes flash.used_keys, k, "Expected #{k} to not be in flash.now, but it is."
   end
 end
 
diff --git a/test/support/models.rb b/test/support/models.rb
index 4b10568..a93a5e5 100644
--- a/test/support/models.rb
+++ b/test/support/models.rb
@@ -4,6 +4,10 @@ class Customer < Struct.new(:name, :id)
   extend ActiveModel::Naming
   include ActiveModel::Conversion
 
+  def to_json(*)
+    to_h.to_json
+  end
+
   def to_xml(options = {})
     if options[:builder]
       options[:builder].name name
@@ -26,16 +30,6 @@ class Customer < Struct.new(:name, :id)
   end
 end
 
-class ValidatedCustomer < Customer
-  def errors
-    if name =~ /Sikachu/i
-      []
-    else
-      [{ name: "is invalid" }]
-    end
-  end
-end
-
 module Quiz
   class Question < Struct.new(:name, :id)
     extend ActiveModel::Naming
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8d063d6..d33b88c 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -2,7 +2,7 @@
 
 require "bundler/setup"
 require "minitest/autorun"
-require "mocha/setup"
+require "mocha/minitest"
 
 # Configure Rails
 ENV["RAILS_ENV"] = "test"

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/action_controller/respond_with.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/action_controller/responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/generators/rails/USAGE
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/generators/rails/responders_controller_generator.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/generators/rails/templates/api_controller.rb.tt
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/generators/rails/templates/controller.rb.tt
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/generators/responders/install_generator.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders/collection_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders/controller_method.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders/flash_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders/http_cache_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders/locales/en.yml
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.1.0/lib/responders/version.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/responders-3.1.0.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/action_controller/respond_with.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/action_controller/responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/generators/rails/USAGE
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/generators/rails/responders_controller_generator.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/generators/rails/templates/api_controller.rb.tt
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/generators/rails/templates/controller.rb.tt
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/generators/responders/install_generator.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/collection_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/controller_method.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/flash_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/http_cache_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/locales/en.yml
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/location_responder.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/responders-3.0.1/lib/responders/version.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/responders-3.0.1.gemspec

Control files: lines which differ (wdiff format)

  • Ruby-Versions: all

More details

Full run details