From d1f1b73506e1178da59840f866f15147e3ccd15f Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 09:18:37 -0400 Subject: [PATCH 01/18] Allow for rails 5.1 and 5.2 in dependencies --- verification.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/verification.gemspec b/verification.gemspec index 151f1a0..b27c14b 100644 --- a/verification.gemspec +++ b/verification.gemspec @@ -15,8 +15,8 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_dependency('activesupport', '>= 3.0.0', '< 5.1') - s.add_dependency('actionpack', '>= 3.0.0', '< 5.1') + s.add_dependency('activesupport', '>= 3.0.0', '< 6') + s.add_dependency('actionpack', '>= 3.0.0', '< 6') s.add_development_dependency('rake') s.add_development_dependency('appraisal') From 6d35c4f3ffbe76fce9597470bd9a4ab7cf5971d8 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 09:18:45 -0400 Subject: [PATCH 02/18] Add rails 5.1 and 5.2 to appraisals --- Appraisals | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Appraisals b/Appraisals index 7072d81..599f37a 100644 --- a/Appraisals +++ b/Appraisals @@ -32,3 +32,13 @@ appraise 'rails_5_0' do gem 'activesupport', '~> 5.0.0' gem 'actionpack', '~> 5.0.0' end + +appraise 'rails_5_1' do + gem 'activesupport', '~> 5.1.0' + gem 'actionpack', '~> 5.1.0' +end + +appraise 'rails_5_2' do + gem 'activesupport', '~> 5.2.0' + gem 'actionpack', '~> 5.2.0' +end From 3af50199c9a8f883f28c7ac9aef1732b2f2497fc Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 09:18:55 -0400 Subject: [PATCH 03/18] New appraisal gemfiles --- gemfiles/rails_3_0.gemfile | 2 +- gemfiles/rails_3_1.gemfile | 2 +- gemfiles/rails_3_2.gemfile | 2 +- gemfiles/rails_4_0.gemfile | 2 +- gemfiles/rails_4_1.gemfile | 2 +- gemfiles/rails_4_2.gemfile | 2 +- gemfiles/rails_5_1.gemfile | 8 ++++++++ gemfiles/rails_5_2.gemfile | 8 ++++++++ 8 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 gemfiles/rails_5_1.gemfile create mode 100644 gemfiles/rails_5_2.gemfile diff --git a/gemfiles/rails_3_0.gemfile b/gemfiles/rails_3_0.gemfile index 857439f..e685072 100644 --- a/gemfiles/rails_3_0.gemfile +++ b/gemfiles/rails_3_0.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "activesupport", "~> 3.0.0" gem "actionpack", "~> 3.0.0" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_3_1.gemfile b/gemfiles/rails_3_1.gemfile index d1ec134..8126b01 100644 --- a/gemfiles/rails_3_1.gemfile +++ b/gemfiles/rails_3_1.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "activesupport", "~> 3.1.0" gem "actionpack", "~> 3.1.0" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_3_2.gemfile b/gemfiles/rails_3_2.gemfile index a79d34e..fd6ec16 100644 --- a/gemfiles/rails_3_2.gemfile +++ b/gemfiles/rails_3_2.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "activesupport", "~> 3.2.0" gem "actionpack", "~> 3.2.0" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_4_0.gemfile b/gemfiles/rails_4_0.gemfile index 3e6650c..fb950fd 100644 --- a/gemfiles/rails_4_0.gemfile +++ b/gemfiles/rails_4_0.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "activesupport", "~> 4.0.0" gem "actionpack", "~> 4.0.0" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_4_1.gemfile b/gemfiles/rails_4_1.gemfile index a64a9dd..9819a49 100644 --- a/gemfiles/rails_4_1.gemfile +++ b/gemfiles/rails_4_1.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "activesupport", "~> 4.1.0" gem "actionpack", "~> 4.1.0" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile index 5adda11..7a03e76 100644 --- a/gemfiles/rails_4_2.gemfile +++ b/gemfiles/rails_4_2.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "activesupport", "~> 4.2.0" gem "actionpack", "~> 4.2.0" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile new file mode 100644 index 0000000..98a6051 --- /dev/null +++ b/gemfiles/rails_5_1.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activesupport", "~> 5.1.0" +gem "actionpack", "~> 5.1.0" + +gemspec path: "../" diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile new file mode 100644 index 0000000..41b8b1b --- /dev/null +++ b/gemfiles/rails_5_2.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activesupport", "~> 5.2.0" +gem "actionpack", "~> 5.2.0" + +gemspec path: "../" From 5e133875d3f81da924ae082b60aa1701888b7583 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 09:27:24 -0400 Subject: [PATCH 04/18] Update travis for ruby/rails combos --- .travis.yml | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c2ae2d..b1d4001 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,14 +19,50 @@ gemfile: - gemfiles/rails_4_1.gemfile - gemfiles/rails_4_2.gemfile - gemfiles/rails_5_0.gemfile + - gemfiles/rails_5_1.gemfile + - gemfiles/rails_5_2.gemfile jobs: exclude: + - rvm: 2.6.1 + gemfile: gemfiles/rails_3_0.gemfile + - rvm: 2.3.3 + gemfile: gemfiles/rails_3_0.gemfile + - rvm: 2.6.1 + gemfile: gemfiles/rails_3_1.gemfile + - rvm: 2.3.3 + gemfile: gemfiles/rails_3_1.gemfile + - rvm: 2.6.1 + gemfile: gemfiles/rails_3_2.gemfile + - rvm: 2.3.3 + gemfile: gemfiles/rails_3_2.gemfile + - rvm: 2.6.1 + gemfile: gemfiles/rails_4_0.gemfile + - rvm: 2.3.3 + gemfile: gemfiles/rails_4_0.gemfile + - rvm: 2.6.1 + gemfile: gemfiles/rails_4_1.gemfile + - rvm: 2.3.3 + gemfile: gemfiles/rails_4_1.gemfile + - rvm: 2.6.1 + gemfile: gemfiles/rails_4_2.gemfile + - rvm: 2.3.3 + gemfile: gemfiles/rails_4_2.gemfile - rvm: 1.9.3-p551 gemfile: gemfiles/rails_5_0.gemfile - rvm: 2.0.0-p648 gemfile: gemfiles/rails_5_0.gemfile - rvm: 2.1.10 gemfile: gemfiles/rails_5_0.gemfile - - rvm: 2.6.1 - gemfile: gemfiles/rails_3_0.gemfile + - rvm: 1.9.3-p551 + gemfile: gemfiles/rails_5_1.gemfile + - rvm: 2.0.0-p648 + gemfile: gemfiles/rails_5_1.gemfile + - rvm: 2.1.10 + gemfile: gemfiles/rails_5_1.gemfile + - rvm: 1.9.3-p551 + gemfile: gemfiles/rails_5_2.gemfile + - rvm: 2.0.0-p648 + gemfile: gemfiles/rails_5_2.gemfile + - rvm: 2.1.10 + gemfile: gemfiles/rails_5_2.gemfile From b1c7757fab7ac3876c60c81fd1ef7bbc481426c8 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 09:27:33 -0400 Subject: [PATCH 05/18] Bump version --- verification.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verification.gemspec b/verification.gemspec index b27c14b..90d6cb2 100644 --- a/verification.gemspec +++ b/verification.gemspec @@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = "verification" - s.version = "1.0.4" + s.version = "1.0.5" s.platform = Gem::Platform::RUBY s.authors = ["David Heinemeier Hansson"] s.email = ["david@loudthinking.com"] From 9b984d721c042910fc0c6f28bf038bee8a23955f Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 09:27:48 -0400 Subject: [PATCH 06/18] Use rails 5 syntax --- test/verification_test.rb | 213 ++++++++++++++++++++++++++++++-------- 1 file changed, 167 insertions(+), 46 deletions(-) diff --git a/test/verification_test.rb b/test/verification_test.rb index 8fc5f27..c96fc99 100644 --- a/test/verification_test.rb +++ b/test/verification_test.rb @@ -1,108 +1,206 @@ require 'test_helper' class VerificationTestController < ActionController::Base - verify :only => :guarded_one, :params => "one", + verify :only => :guarded_one, params: "one", + # verify only: :guarded_one, params: { "one" }, :add_flash => { :error => 'unguarded' }, + # flash: { error: 'unguarded' }, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => :guarded_two, :params => %w( one two ), + # verify only: :guarded_two, params: { %w( one two ) }, + verify only: :guarded_two, params: "%w( one two )", :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => :guarded_with_flash, :params => "one", + verify only: :guarded_with_flash, :params => "one", + # verify only: :guarded_with_flash, params: { "one": "ONE" }, + # flash: { notice: "prereqs failed" }, :add_flash => { :notice => "prereqs failed" }, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => :guarded_in_session, :session => "one", + verify only: :guarded_in_session, :session => "one", + # verify only: :guarded_in_session, session: { "one" }, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => [:multi_one, :multi_two], :session => %w( one two ), + verify only: [:multi_one, :multi_two], :session => %w( one two ), + # verify only: [:multi_one, :multi_two], session: { %w( one two ) }, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => :guarded_by_method, :method => :post, + verify only: :guarded_by_method, method: :post, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => :guarded_by_xhr, :xhr => true, + verify only: :guarded_by_xhr, :xhr => true, + # verify only: :guarded_by_xhr, xhr: true, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - verify :only => :guarded_by_not_xhr, :xhr => false, + verify only: :guarded_by_not_xhr, :xhr => false, + # verify only: :guarded_by_not_xhr, xhr: false, :redirect_to => { :action => "unguarded" } + # redirect_to({ action: :unguarded }) - before_filter :unconditional_redirect, :only => :two_redirects - verify :only => :two_redirects, :method => :post, - :redirect_to => { :action => "unguarded" } - - verify :only => :must_be_post, :method => :post, :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } - - verify :only => :must_be_put, :method => :put, :render => { :status => 405, :text => "Must be put" }, :add_headers => { "Allow" => "PUT" } + if respond_to?(:before_action) + before_action :unconditional_redirect, only: :two_redirects + else + before_filter :unconditional_redirect, only: :two_redirects + end - verify :only => :guarded_one_for_named_route_test, :params => "one", + verify only: :two_redirects, method: :post, + :redirect_to => { :action => "unguarded" } + # redirect_to:({ :action => "unguarded" }) + # begin + verify only: :must_be_post, method: :post, :render => { :status => 405, plain: "Must be post" }, :add_headers => { "Allow" => "POST" } + # rescue ActionView::MissingTemplate + # verify only: :must_be_post, method: :post, :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } + # verify only: :must_be_post, method: :post, render: { :status => 405, :text => "Must be post" }, add_headers: { "Allow" => "POST" } + # end + + # begin + verify only: :must_be_put, method: :put, :render => { :status => 405, plain: "Must be put" }, :add_headers => { "Allow" => "PUT" } + # rescue ActionView::MissingTemplate + # verify only: :must_be_put, method: :put, :render => { :status => 405, :text => "Must be put" }, :add_headers => { "Allow" => "PUT" } + # verify only: :must_be_put, method: :put, render: { :status => 405, :text => "Must be put" }, add_headers: { "Allow" => "PUT" } + # end + + verify only: :guarded_one_for_named_route_test, :params => "one", :redirect_to => :foo_url + # redirect_to:(:foo_url) - verify :only => :no_default_action, :params => "santa" + verify only: :no_default_action, :params => "santa" - verify :only => :guarded_with_back, :method => :post, - :redirect_to => :back + # verify only: :guarded_with_back, method: :post, redirect_to: :back + verify only: :guarded_with_back, method: :post, :redirect_to => :back, fallback_location: '/' + # :redirect_to => :back + # begin + # :redirect_to => :back + # rescue NoMethodError + # redirect_back + # end + # redirect_to:(:back) def guarded_one - render :text => "#{params[:one]}" + begin + render plain: "#{params[:one]}" + rescue ActionView::MissingTemplate + render text: "#{params[:one]}" + end end def guarded_one_for_named_route_test - render :text => "#{params[:one]}" + begin + render plain: "#{params[:one]}" + rescue ActionView::MissingTemplate + render text: "#{params[:one]}" + end end def guarded_with_flash - render :text => "#{params[:one]}" + begin + render plain: "#{params[:one]}" + rescue ActionView::MissingTemplate + render text: "#{params[:one]}" + end end def guarded_two - render :text => "#{params[:one]}:#{params[:two]}" + begin + render plain: "#{params[:one]}:#{params[:two]}" + rescue ActionView::MissingTemplate + render text: "#{params[:one]}:#{params[:two]}" + end end def guarded_in_session - render :text => "#{session["one"]}" + begin + render plain: "#{session["one"]}" + rescue ActionView::MissingTemplate + render text: "#{session["one"]}" + end end def multi_one - render :text => "#{session["one"]}:#{session["two"]}" + begin + render plain: "#{session["one"]}:#{session["two"]}" + rescue ActionView::MissingTemplate + render text: "#{session["one"]}:#{session["two"]}" + end end def multi_two - render :text => "#{session["two"]}:#{session["one"]}" + begin + render plain: "#{session["two"]}:#{session["one"]}" + rescue ActionView::MissingTemplate + render text: "#{session["two"]}:#{session["one"]}" + end end def guarded_by_method - render :text => "#{request.method}" + begin + render plain: "#{request.method}" + rescue ActionView::MissingTemplate + render text: "#{request.method}" + end end def guarded_by_xhr - render :text => "#{!!request.xhr?}" + begin + render plain: "#{!!request.xhr?}" + rescue ActionView::MissingTemplate + render text: "#{!!request.xhr?}" + end end def guarded_by_not_xhr - render :text => "#{!!request.xhr?}" + begin + render plain: "#{!!request.xhr?}" + rescue ActionView::MissingTemplate + render text: "#{!!request.xhr?}" + end end def unguarded - render :text => "#{params[:one]}" + begin + render plain: "#{params[:one]}" + rescue ActionView::MissingTemplate + render text: "#{params[:one]}" + end end def two_redirects - render :nothing => true + head :ok + # render :nothing => true end def must_be_post - render :text => "Was a post!" + begin + render plain: "Was a post!" + rescue ActionView::MissingTemplate + render text: "Was a post!" + end end def must_be_put - render :text => "Was a put!" + begin + render plain: "Was a put!" + rescue ActionView::MissingTemplate + render text: "Was a put!" + end end def guarded_with_back - render :text => "#{params[:one]}" + begin + render plain: "#{params[:one]}" + rescue ActionView::MissingTemplate + render text: "#{params[:one]}" + end end + def no_default_action # Will never run end @@ -111,6 +209,7 @@ def no_default_action def unconditional_redirect redirect_to :action => "unguarded" + # redirect_to({action: :unguarded}) end end @@ -118,7 +217,7 @@ class VerificationTest < ActionController::TestCase tests ::VerificationTestController def test_using_symbol_back_with_no_referrer - assert_raise(ActionController::RedirectBackError) { get :guarded_with_back } + assert_raise { get :guarded_with_back } end def test_using_symbol_back_redirects_to_referrer @@ -128,18 +227,21 @@ def test_using_symbol_back_redirects_to_referrer end def test_guarded_one_with_prereqs - get :guarded_one, :one => "here" + # get :guarded_one, :one => "here" + get :guarded_one, params: {:one => "here"} assert_equal "here", @response.body end def test_guarded_one_without_prereqs get :guarded_one assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) assert_equal 'unguarded', flash[:error] end def test_guarded_with_flash_with_prereqs - get :guarded_with_flash, :one => "here" + # get :guarded_with_flash, :one => "here" + get :guarded_with_flash, params: {:one => "here"} assert_equal "here", @response.body assert flash.empty? end @@ -147,31 +249,39 @@ def test_guarded_with_flash_with_prereqs def test_guarded_with_flash_without_prereqs get :guarded_with_flash assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) assert_equal "prereqs failed", flash[:notice] end def test_guarded_two_with_prereqs - get :guarded_two, :one => "here", :two => "there" + # get :guarded_two, :one => "here", :two => "there" + get :guarded_two, params: {:one => "here", :two => "there"} assert_equal "here:there", @response.body end def test_guarded_two_without_prereqs_one - get :guarded_two, :two => "there" + # get :guarded_two, :two => "there" + get :guarded_two, params: {:two => "there"} assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_guarded_two_without_prereqs_two - get :guarded_two, :one => "here" + # get :guarded_two, :one => "here" + get :guarded_two, params: {:one => "here"} assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_guarded_two_without_prereqs_both get :guarded_two assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_unguarded_with_params - get :unguarded, :one => "here" + # get :unguarded, :one => "here" + get :unguarded, params: {:one => "here"} assert_equal "here", @response.body end @@ -181,17 +291,20 @@ def test_unguarded_without_params end def test_guarded_in_session_with_prereqs - get :guarded_in_session, {}, "one" => "here" + # get :guarded_in_session, {}, "one" => "here" + get :guarded_in_session, params: {"one" => "here"} assert_equal "here", @response.body end def test_guarded_in_session_without_prereqs get :guarded_in_session assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_multi_one_with_prereqs - get :multi_one, {}, "one" => "here", "two" => "there" + # get :multi_one, {}, "one" => "here", "two" => "there" + get :multi_one, params: {"one" => "here", "two" => "there"} assert_equal "here:there", @response.body end @@ -201,13 +314,14 @@ def test_multi_one_without_prereqs end def test_multi_two_with_prereqs - get :multi_two, {}, "one" => "here", "two" => "there" + get :multi_two, params: {"one" => "here", "two" => "there"} assert_equal "there:here", @response.body end def test_multi_two_without_prereqs get :multi_two assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_guarded_by_method_with_prereqs @@ -218,16 +332,22 @@ def test_guarded_by_method_with_prereqs def test_guarded_by_method_without_prereqs get :guarded_by_method assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_guarded_by_xhr_with_prereqs - xhr :post, :guarded_by_xhr - assert_equal "true", @response.body + if respond_to?(:xhr) + xhr :post, :guarded_by_xhr + assert_equal "true", @response.body + else + return + end end def test_guarded_by_xhr_without_prereqs get :guarded_by_xhr assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_guarded_by_not_xhr_with_prereqs @@ -238,6 +358,7 @@ def test_guarded_by_not_xhr_with_prereqs def test_guarded_by_not_xhr_without_prereqs xhr :post, :guarded_by_not_xhr assert_redirected_to :action => "unguarded" + # assert_redirected_to(action: :unguarded) end def test_guarded_post_and_calls_render_succeeds From 797209be3ed759c6a7b69cf7f981529a6fc49962 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 18 Aug 2022 21:41:19 -0400 Subject: [PATCH 07/18] Remove appraisals for Rails 3.x and 4.x --- Appraisals | 33 +++------------------------------ gemfiles/rails_3_0.gemfile | 8 -------- gemfiles/rails_3_1.gemfile | 8 -------- gemfiles/rails_3_2.gemfile | 8 -------- gemfiles/rails_4_0.gemfile | 8 -------- gemfiles/rails_4_1.gemfile | 8 -------- gemfiles/rails_4_2.gemfile | 8 -------- 7 files changed, 3 insertions(+), 78 deletions(-) delete mode 100644 gemfiles/rails_3_0.gemfile delete mode 100644 gemfiles/rails_3_1.gemfile delete mode 100644 gemfiles/rails_3_2.gemfile delete mode 100644 gemfiles/rails_4_0.gemfile delete mode 100644 gemfiles/rails_4_1.gemfile delete mode 100644 gemfiles/rails_4_2.gemfile diff --git a/Appraisals b/Appraisals index 599f37a..69be857 100644 --- a/Appraisals +++ b/Appraisals @@ -1,44 +1,17 @@ -appraise 'rails_3_0' do - gem 'activesupport', '~> 3.0.0' - gem 'actionpack', '~> 3.0.0' -end - -appraise 'rails_3_1' do - gem 'activesupport', '~> 3.1.0' - gem 'actionpack', '~> 3.1.0' -end - -appraise 'rails_3_2' do - gem 'activesupport', '~> 3.2.0' - gem 'actionpack', '~> 3.2.0' -end - -appraise 'rails_4_0' do - gem 'activesupport', '~> 4.0.0' - gem 'actionpack', '~> 4.0.0' -end - -appraise 'rails_4_1' do - gem 'activesupport', '~> 4.1.0' - gem 'actionpack', '~> 4.1.0' -end - -appraise 'rails_4_2' do - gem 'activesupport', '~> 4.2.0' - gem 'actionpack', '~> 4.2.0' -end - appraise 'rails_5_0' do gem 'activesupport', '~> 5.0.0' gem 'actionpack', '~> 5.0.0' + gem 'byebug' end appraise 'rails_5_1' do gem 'activesupport', '~> 5.1.0' gem 'actionpack', '~> 5.1.0' + gem 'byebug' end appraise 'rails_5_2' do gem 'activesupport', '~> 5.2.0' gem 'actionpack', '~> 5.2.0' + gem 'byebug' end diff --git a/gemfiles/rails_3_0.gemfile b/gemfiles/rails_3_0.gemfile deleted file mode 100644 index e685072..0000000 --- a/gemfiles/rails_3_0.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activesupport", "~> 3.0.0" -gem "actionpack", "~> 3.0.0" - -gemspec path: "../" diff --git a/gemfiles/rails_3_1.gemfile b/gemfiles/rails_3_1.gemfile deleted file mode 100644 index 8126b01..0000000 --- a/gemfiles/rails_3_1.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activesupport", "~> 3.1.0" -gem "actionpack", "~> 3.1.0" - -gemspec path: "../" diff --git a/gemfiles/rails_3_2.gemfile b/gemfiles/rails_3_2.gemfile deleted file mode 100644 index fd6ec16..0000000 --- a/gemfiles/rails_3_2.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activesupport", "~> 3.2.0" -gem "actionpack", "~> 3.2.0" - -gemspec path: "../" diff --git a/gemfiles/rails_4_0.gemfile b/gemfiles/rails_4_0.gemfile deleted file mode 100644 index fb950fd..0000000 --- a/gemfiles/rails_4_0.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activesupport", "~> 4.0.0" -gem "actionpack", "~> 4.0.0" - -gemspec path: "../" diff --git a/gemfiles/rails_4_1.gemfile b/gemfiles/rails_4_1.gemfile deleted file mode 100644 index 9819a49..0000000 --- a/gemfiles/rails_4_1.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activesupport", "~> 4.1.0" -gem "actionpack", "~> 4.1.0" - -gemspec path: "../" diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile deleted file mode 100644 index 7a03e76..0000000 --- a/gemfiles/rails_4_2.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activesupport", "~> 4.2.0" -gem "actionpack", "~> 4.2.0" - -gemspec path: "../" From cce8074813f362f788f7f43669793ad02e73f4e1 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 08:41:48 -0400 Subject: [PATCH 08/18] Refactor tests for Rails 5 --- .gitignore | 1 + Gemfile | 1 + gemfiles/rails_5_1.gemfile | 1 + test/test_helper.rb | 1 + test/verification_test.rb | 326 +++++++++++++------------------------ 5 files changed, 120 insertions(+), 210 deletions(-) diff --git a/.gitignore b/.gitignore index e6b8c78..77de0c9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ pkg/* *.gem .bundle gemfiles/*.lock +.byebug_history diff --git a/Gemfile b/Gemfile index b4e2a20..9578583 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ source "https://rubygems.org" gemspec +gem 'byebug' diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index 98a6051..2a51a9c 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -4,5 +4,6 @@ source "https://rubygems.org" gem "activesupport", "~> 5.1.0" gem "actionpack", "~> 5.1.0" +gem "byebug" gemspec path: "../" diff --git a/test/test_helper.rb b/test/test_helper.rb index c09b729..6f9a534 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,6 +3,7 @@ require 'mocha/setup' require 'active_support' require 'action_controller' +require 'byebug' if ActiveSupport::VERSION::MAJOR > 3 require 'active_support/testing/autorun' diff --git a/test/verification_test.rb b/test/verification_test.rb index c96fc99..e2d6942 100644 --- a/test/verification_test.rb +++ b/test/verification_test.rb @@ -1,203 +1,105 @@ require 'test_helper' class VerificationTestController < ActionController::Base - verify :only => :guarded_one, params: "one", - # verify only: :guarded_one, params: { "one" }, - :add_flash => { :error => 'unguarded' }, - # flash: { error: 'unguarded' }, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) - - # verify only: :guarded_two, params: { %w( one two ) }, + before_action :unconditional_redirect, only: :two_redirects + + verify only: :guarded_one, params: "one", + add_flash: { error: 'unguarded' }, + redirect_to: { action: "unguarded" } + verify only: :guarded_two, params: "%w( one two )", - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) + redirect_to: { action: "unguarded" } verify only: :guarded_with_flash, :params => "one", - # verify only: :guarded_with_flash, params: { "one": "ONE" }, - # flash: { notice: "prereqs failed" }, - :add_flash => { :notice => "prereqs failed" }, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) - - verify only: :guarded_in_session, :session => "one", - # verify only: :guarded_in_session, session: { "one" }, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) - - verify only: [:multi_one, :multi_two], :session => %w( one two ), - # verify only: [:multi_one, :multi_two], session: { %w( one two ) }, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) + add_flash: { :notice => "prereqs failed" }, + redirect_to: { action: "unguarded" } - verify only: :guarded_by_method, method: :post, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) + verify only: :guarded_in_session, session: "one", + redirect_to: { action: "unguarded" } - verify only: :guarded_by_xhr, :xhr => true, - # verify only: :guarded_by_xhr, xhr: true, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) + verify only: [:multi_one, :multi_two], session: %w( one two ), + redirect_to: { action: "unguarded" } - verify only: :guarded_by_not_xhr, :xhr => false, - # verify only: :guarded_by_not_xhr, xhr: false, - :redirect_to => { :action => "unguarded" } - # redirect_to({ action: :unguarded }) + verify only: :guarded_by_method, method: :post, + redirect_to: { action: "unguarded" } - if respond_to?(:before_action) - before_action :unconditional_redirect, only: :two_redirects - else - before_filter :unconditional_redirect, only: :two_redirects - end + verify only: :guarded_by_xhr, xhr: true, + redirect_to: { action: "unguarded" } + + verify only: :guarded_by_not_xhr, xhr: false, + redirect_to: { action: "unguarded" } verify only: :two_redirects, method: :post, - :redirect_to => { :action => "unguarded" } - # redirect_to:({ :action => "unguarded" }) - # begin - verify only: :must_be_post, method: :post, :render => { :status => 405, plain: "Must be post" }, :add_headers => { "Allow" => "POST" } - # rescue ActionView::MissingTemplate - # verify only: :must_be_post, method: :post, :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } - # verify only: :must_be_post, method: :post, render: { :status => 405, :text => "Must be post" }, add_headers: { "Allow" => "POST" } - # end - - # begin - verify only: :must_be_put, method: :put, :render => { :status => 405, plain: "Must be put" }, :add_headers => { "Allow" => "PUT" } - # rescue ActionView::MissingTemplate - # verify only: :must_be_put, method: :put, :render => { :status => 405, :text => "Must be put" }, :add_headers => { "Allow" => "PUT" } - # verify only: :must_be_put, method: :put, render: { :status => 405, :text => "Must be put" }, add_headers: { "Allow" => "PUT" } - # end - - verify only: :guarded_one_for_named_route_test, :params => "one", - :redirect_to => :foo_url - # redirect_to:(:foo_url) - - verify only: :no_default_action, :params => "santa" - - # verify only: :guarded_with_back, method: :post, redirect_to: :back - verify only: :guarded_with_back, method: :post, :redirect_to => :back, fallback_location: '/' - # :redirect_to => :back - # begin - # :redirect_to => :back - # rescue NoMethodError - # redirect_back - # end - # redirect_to:(:back) + redirect_to: { action: :unguarded } + + verify only: :must_be_post, method: :post, render: { status: 405, plain: "Must be post" }, add_headers: { "Allow" => "POST" } + + verify only: :must_be_put, method: :put, render: { status: 405, plain: "Must be put" }, add_headers: { "Allow" => "PUT" } + + verify only: :guarded_one_for_named_route_test, params: "one", redirect_to: :foo_url + + verify only: :no_default_action, params: "santa" + + verify only: :guarded_with_back, method: :post, redirect_to: :back def guarded_one - begin - render plain: "#{params[:one]}" - rescue ActionView::MissingTemplate - render text: "#{params[:one]}" - end + render plain: "#{params[:one]}" end def guarded_one_for_named_route_test - begin - render plain: "#{params[:one]}" - rescue ActionView::MissingTemplate - render text: "#{params[:one]}" - end + render plain: "#{params[:one]}" end def guarded_with_flash - begin - render plain: "#{params[:one]}" - rescue ActionView::MissingTemplate - render text: "#{params[:one]}" - end + render plain: "#{params[:one]}" end def guarded_two - begin - render plain: "#{params[:one]}:#{params[:two]}" - rescue ActionView::MissingTemplate - render text: "#{params[:one]}:#{params[:two]}" - end + render plain: "#{params[:one]}:#{params[:two]}" end def guarded_in_session - begin - render plain: "#{session["one"]}" - rescue ActionView::MissingTemplate - render text: "#{session["one"]}" - end + render plain: "#{session["one"]}" end def multi_one - begin - render plain: "#{session["one"]}:#{session["two"]}" - rescue ActionView::MissingTemplate - render text: "#{session["one"]}:#{session["two"]}" - end + render plain: "#{session["one"]}:#{session["two"]}" end def multi_two - begin - render plain: "#{session["two"]}:#{session["one"]}" - rescue ActionView::MissingTemplate - render text: "#{session["two"]}:#{session["one"]}" - end + render plain: "#{session["two"]}:#{session["one"]}" end def guarded_by_method - begin - render plain: "#{request.method}" - rescue ActionView::MissingTemplate - render text: "#{request.method}" - end + render plain: "#{request.method}" end def guarded_by_xhr - begin - render plain: "#{!!request.xhr?}" - rescue ActionView::MissingTemplate - render text: "#{!!request.xhr?}" - end + render plain: "#{!!request.xhr?}" end def guarded_by_not_xhr - begin - render plain: "#{!!request.xhr?}" - rescue ActionView::MissingTemplate - render text: "#{!!request.xhr?}" - end + render plain: "#{!!request.xhr?}" end def unguarded - begin - render plain: "#{params[:one]}" - rescue ActionView::MissingTemplate - render text: "#{params[:one]}" - end + render plain: "#{params[:one]}" end def two_redirects head :ok - # render :nothing => true end def must_be_post - begin - render plain: "Was a post!" - rescue ActionView::MissingTemplate - render text: "Was a post!" - end + render plain: "Was a post!" end def must_be_put - begin - render plain: "Was a put!" - rescue ActionView::MissingTemplate - render text: "Was a put!" - end + render plain: "Was a put!" end def guarded_with_back - begin - render plain: "#{params[:one]}" - rescue ActionView::MissingTemplate - render text: "#{params[:one]}" - end + render plain: "#{params[:one]}" end @@ -208,8 +110,7 @@ def no_default_action protected def unconditional_redirect - redirect_to :action => "unguarded" - # redirect_to({action: :unguarded}) + redirect_to(action: "unguarded") end end @@ -217,170 +118,175 @@ class VerificationTest < ActionController::TestCase tests ::VerificationTestController def test_using_symbol_back_with_no_referrer - assert_raise { get :guarded_with_back } + assert_raise(ActionController::ActionControllerError) { get :guarded_with_back } end def test_using_symbol_back_redirects_to_referrer @request.env["HTTP_REFERER"] = "/foo" get :guarded_with_back - assert_redirected_to '/foo' + + assert_redirected_to('/foo') end def test_guarded_one_with_prereqs - # get :guarded_one, :one => "here" - get :guarded_one, params: {:one => "here"} - assert_equal "here", @response.body + get :guarded_one, params: { one: "here" } + + assert_equal("here", @response.body) end def test_guarded_one_without_prereqs get :guarded_one - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) - assert_equal 'unguarded', flash[:error] + + assert_redirected_to(action: "unguarded") + assert_equal('unguarded', flash[:error]) end def test_guarded_with_flash_with_prereqs - # get :guarded_with_flash, :one => "here" - get :guarded_with_flash, params: {:one => "here"} - assert_equal "here", @response.body - assert flash.empty? + get :guarded_with_flash, params: { one: "here" } + + assert_equal("here", @response.body) + assert(flash.empty?) end def test_guarded_with_flash_without_prereqs get :guarded_with_flash - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) - assert_equal "prereqs failed", flash[:notice] + + assert_redirected_to(action: "unguarded") + assert_equal("prereqs failed", flash[:notice]) end def test_guarded_two_with_prereqs - # get :guarded_two, :one => "here", :two => "there" - get :guarded_two, params: {:one => "here", :two => "there"} - assert_equal "here:there", @response.body + get :guarded_two, params: { one: "here", two: "there" } + + assert_equal("here:there", @response.body) end def test_guarded_two_without_prereqs_one - # get :guarded_two, :two => "there" - get :guarded_two, params: {:two => "there"} - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + get :guarded_two, params: { two: "there" } + + assert_redirected_to(action: "unguarded") end def test_guarded_two_without_prereqs_two - # get :guarded_two, :one => "here" - get :guarded_two, params: {:one => "here"} - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + get :guarded_two, params: { one: "here" } + + assert_redirected_to(action: "unguarded") end def test_guarded_two_without_prereqs_both get :guarded_two - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + + assert_redirected_to(action: "unguarded") end def test_unguarded_with_params - # get :unguarded, :one => "here" - get :unguarded, params: {:one => "here"} - assert_equal "here", @response.body + get :unguarded, params: {one: "here"} + + assert_equal("here", @response.body) end def test_unguarded_without_params get :unguarded - assert @response.body.blank? + + assert(@response.body.blank?) end def test_guarded_in_session_with_prereqs - # get :guarded_in_session, {}, "one" => "here" - get :guarded_in_session, params: {"one" => "here"} - assert_equal "here", @response.body + get :guarded_in_session, params: { "one" => "here" } + + assert_equal("here", @response.body) end def test_guarded_in_session_without_prereqs get :guarded_in_session - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + + assert_redirected_to(action: "unguarded") end def test_multi_one_with_prereqs - # get :multi_one, {}, "one" => "here", "two" => "there" - get :multi_one, params: {"one" => "here", "two" => "there"} - assert_equal "here:there", @response.body + get :multi_one, params: { "one" => "here", "two" => "there" } + + assert_equal("here:there", @response.body) end def test_multi_one_without_prereqs get :multi_one - assert_redirected_to :action => "unguarded" + + assert_redirected_to(action: "unguarded") end def test_multi_two_with_prereqs get :multi_two, params: {"one" => "here", "two" => "there"} - assert_equal "there:here", @response.body + + assert_equal("there:here", @response.body) end def test_multi_two_without_prereqs get :multi_two - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + + assert_redirected_to(action: "unguarded") end def test_guarded_by_method_with_prereqs post :guarded_by_method - assert_equal "POST", @response.body + + assert_equal("POST", @response.body) end def test_guarded_by_method_without_prereqs get :guarded_by_method - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + + assert_redirected_to(action: "unguarded") end def test_guarded_by_xhr_with_prereqs - if respond_to?(:xhr) - xhr :post, :guarded_by_xhr - assert_equal "true", @response.body - else - return - end + post :guarded_by_xhr, xhr: true + + assert_equal("true", @response.body) end def test_guarded_by_xhr_without_prereqs get :guarded_by_xhr - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + + assert_redirected_to(action: "unguarded") end def test_guarded_by_not_xhr_with_prereqs get :guarded_by_not_xhr - assert_equal "false", @response.body + + assert_equal("false", @response.body) end def test_guarded_by_not_xhr_without_prereqs - xhr :post, :guarded_by_not_xhr - assert_redirected_to :action => "unguarded" - # assert_redirected_to(action: :unguarded) + post :guarded_by_not_xhr, xhr: true + + assert_redirected_to(action: "unguarded") end def test_guarded_post_and_calls_render_succeeds post :must_be_post - assert_equal "Was a post!", @response.body + + assert_equal("Was a post!", @response.body) end def test_guarded_put_and_calls_render_succeeds put :must_be_put - assert_equal "Was a put!", @response.body + + assert_equal("Was a put!", @response.body) end def test_default_failure_should_be_a_bad_request post :no_default_action - assert_response :bad_request + + assert_response(:bad_request) end def test_guarded_post_and_calls_render_fails_and_sets_allow_header get :must_be_post - assert_response 405 - assert_equal "Must be post", @response.body - assert_equal "POST", @response.headers["Allow"] + + assert_response(405) + assert_equal("Must be post", @response.body) + assert_equal("POST", @response.headers["Allow"]) end def test_second_redirect From d157589a42cc50622d6ac268e69837690a60f44f Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 08:42:16 -0400 Subject: [PATCH 09/18] Handle new redirect_back syntax rais 5 --- lib/action_controller/verification.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/action_controller/verification.rb b/lib/action_controller/verification.rb index 149cbaa..f6ed787 100644 --- a/lib/action_controller/verification.rb +++ b/lib/action_controller/verification.rb @@ -79,20 +79,15 @@ module ClassMethods # do not apply this verification to the actions specified in the associated # array (may also be a single value). def verify(options={}) - before_filter_or_before_action_for_options :only => options[:only], :except => options[:except] do - verify_action options + before_action_for_options(:only => options[:only], :except => options[:except]) do + verify_action(options) end end private - # fix DEPRECATION WARNING: - # before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead - def before_filter_or_before_action_for_options(options, &block) - if respond_to? :before_action - before_action options, &block - else - before_filter options, &block - end + + def before_action_for_options(options, &block) + before_action(options, &block) end end @@ -123,10 +118,14 @@ def verify_method(options) # :nodoc: end def verify_request_xhr_status(options) # :nodoc: + byebug !!request.xhr? != options[:xhr] unless options[:xhr].nil? end def apply_redirect_to(redirect_to_option) # :nodoc: + if redirect_to_option == :back + return request.env["HTTP_REFERER"] + end (redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.__send__(redirect_to_option) : redirect_to_option end From 3cc1f8e678dcc6b29236a44c7b69d287796ea457 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 08:47:41 -0400 Subject: [PATCH 10/18] Fix travis config --- .travis.yml | 54 ----------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1d4001..51f0757 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,65 +4,11 @@ before_install: gem install bundler -v 1.17.3 script: bundle exec rake test rvm: - - 1.9.3-p551 - - 2.0.0-p648 - - 2.1.10 - 2.2.6 - 2.3.3 - 2.6.1 gemfile: - - gemfiles/rails_3_0.gemfile - - gemfiles/rails_3_1.gemfile - - gemfiles/rails_3_2.gemfile - - gemfiles/rails_4_0.gemfile - - gemfiles/rails_4_1.gemfile - - gemfiles/rails_4_2.gemfile - gemfiles/rails_5_0.gemfile - gemfiles/rails_5_1.gemfile - gemfiles/rails_5_2.gemfile - -jobs: - exclude: - - rvm: 2.6.1 - gemfile: gemfiles/rails_3_0.gemfile - - rvm: 2.3.3 - gemfile: gemfiles/rails_3_0.gemfile - - rvm: 2.6.1 - gemfile: gemfiles/rails_3_1.gemfile - - rvm: 2.3.3 - gemfile: gemfiles/rails_3_1.gemfile - - rvm: 2.6.1 - gemfile: gemfiles/rails_3_2.gemfile - - rvm: 2.3.3 - gemfile: gemfiles/rails_3_2.gemfile - - rvm: 2.6.1 - gemfile: gemfiles/rails_4_0.gemfile - - rvm: 2.3.3 - gemfile: gemfiles/rails_4_0.gemfile - - rvm: 2.6.1 - gemfile: gemfiles/rails_4_1.gemfile - - rvm: 2.3.3 - gemfile: gemfiles/rails_4_1.gemfile - - rvm: 2.6.1 - gemfile: gemfiles/rails_4_2.gemfile - - rvm: 2.3.3 - gemfile: gemfiles/rails_4_2.gemfile - - rvm: 1.9.3-p551 - gemfile: gemfiles/rails_5_0.gemfile - - rvm: 2.0.0-p648 - gemfile: gemfiles/rails_5_0.gemfile - - rvm: 2.1.10 - gemfile: gemfiles/rails_5_0.gemfile - - rvm: 1.9.3-p551 - gemfile: gemfiles/rails_5_1.gemfile - - rvm: 2.0.0-p648 - gemfile: gemfiles/rails_5_1.gemfile - - rvm: 2.1.10 - gemfile: gemfiles/rails_5_1.gemfile - - rvm: 1.9.3-p551 - gemfile: gemfiles/rails_5_2.gemfile - - rvm: 2.0.0-p648 - gemfile: gemfiles/rails_5_2.gemfile - - rvm: 2.1.10 - gemfile: gemfiles/rails_5_2.gemfile From 7a91a7fce10da0a8bf19979f0d89e8abe740196f Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 08:49:01 -0400 Subject: [PATCH 11/18] byebug --- lib/action_controller/verification.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/action_controller/verification.rb b/lib/action_controller/verification.rb index f6ed787..261c28d 100644 --- a/lib/action_controller/verification.rb +++ b/lib/action_controller/verification.rb @@ -118,7 +118,6 @@ def verify_method(options) # :nodoc: end def verify_request_xhr_status(options) # :nodoc: - byebug !!request.xhr? != options[:xhr] unless options[:xhr].nil? end From ec7da81b8d1869ecd5039f48223dccf47a0181a0 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 09:24:33 -0400 Subject: [PATCH 12/18] Byebug travis errors --- gemfiles/rails_5_0.gemfile | 1 + gemfiles/rails_5_2.gemfile | 1 + 2 files changed, 2 insertions(+) diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index c03a540..bcf5bd0 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -4,5 +4,6 @@ source "https://rubygems.org" gem "activesupport", "~> 5.0.0" gem "actionpack", "~> 5.0.0" +gem "byebug" gemspec path: "../" diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile index 41b8b1b..11e34b4 100644 --- a/gemfiles/rails_5_2.gemfile +++ b/gemfiles/rails_5_2.gemfile @@ -4,5 +4,6 @@ source "https://rubygems.org" gem "activesupport", "~> 5.2.0" gem "actionpack", "~> 5.2.0" +gem "byebug" gemspec path: "../" From cc5f31c52fc5a7b7e3f38147626e8963c0ee6aa0 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 09:38:03 -0400 Subject: [PATCH 13/18] Switch params to sessions --- test/verification_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/verification_test.rb b/test/verification_test.rb index e2d6942..b108642 100644 --- a/test/verification_test.rb +++ b/test/verification_test.rb @@ -156,7 +156,7 @@ def test_guarded_with_flash_without_prereqs end def test_guarded_two_with_prereqs - get :guarded_two, params: { one: "here", two: "there" } + get :guarded_two, sesssion: { one: "here", two: "there" } assert_equal("here:there", @response.body) end @@ -192,7 +192,7 @@ def test_unguarded_without_params end def test_guarded_in_session_with_prereqs - get :guarded_in_session, params: { "one" => "here" } + get :guarded_in_session, session: { "one" => "here" } assert_equal("here", @response.body) end @@ -204,7 +204,7 @@ def test_guarded_in_session_without_prereqs end def test_multi_one_with_prereqs - get :multi_one, params: { "one" => "here", "two" => "there" } + get :multi_one, session: { "one" => "here", "two" => "there" } assert_equal("here:there", @response.body) end @@ -216,7 +216,7 @@ def test_multi_one_without_prereqs end def test_multi_two_with_prereqs - get :multi_two, params: {"one" => "here", "two" => "there"} + get :multi_two, session: {"one" => "here", "two" => "there"} assert_equal("there:here", @response.body) end From a4e055a1facd95b4df76a2775d0b03dff6a80140 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 09:38:40 -0400 Subject: [PATCH 14/18] Typo for session --- test/verification_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/verification_test.rb b/test/verification_test.rb index b108642..38de585 100644 --- a/test/verification_test.rb +++ b/test/verification_test.rb @@ -156,7 +156,7 @@ def test_guarded_with_flash_without_prereqs end def test_guarded_two_with_prereqs - get :guarded_two, sesssion: { one: "here", two: "there" } + get :guarded_two, session: { one: "here", two: "there" } assert_equal("here:there", @response.body) end From 1bab657c91f27de0527512a95b1d07eff8a7f20e Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 09:42:43 -0400 Subject: [PATCH 15/18] Stringify param keys for guarded_two --- test/verification_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/verification_test.rb b/test/verification_test.rb index 38de585..914626a 100644 --- a/test/verification_test.rb +++ b/test/verification_test.rb @@ -156,7 +156,7 @@ def test_guarded_with_flash_without_prereqs end def test_guarded_two_with_prereqs - get :guarded_two, session: { one: "here", two: "there" } + get :guarded_two, params: { "one" => "here", "two" => "there" } assert_equal("here:there", @response.body) end From 022857095acccae90012b3998eca4bec63ce1a89 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 09:44:59 -0400 Subject: [PATCH 16/18] Remove quotes --- test/verification_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/verification_test.rb b/test/verification_test.rb index 914626a..9453a21 100644 --- a/test/verification_test.rb +++ b/test/verification_test.rb @@ -7,7 +7,7 @@ class VerificationTestController < ActionController::Base add_flash: { error: 'unguarded' }, redirect_to: { action: "unguarded" } - verify only: :guarded_two, params: "%w( one two )", + verify only: :guarded_two, params: %w( one two ), redirect_to: { action: "unguarded" } verify only: :guarded_with_flash, :params => "one", From 1ecedc6d19b1cb4f406756a050d4b465a1a0bd43 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 13:24:15 -0400 Subject: [PATCH 17/18] Remove gem byebug from gem --- .gitignore | 1 - Appraisals | 3 --- Gemfile | 1 - gemfiles/rails_5_0.gemfile | 1 - gemfiles/rails_5_1.gemfile | 1 - gemfiles/rails_5_2.gemfile | 1 - test/test_helper.rb | 1 - 7 files changed, 9 deletions(-) diff --git a/.gitignore b/.gitignore index 77de0c9..e6b8c78 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ pkg/* *.gem .bundle gemfiles/*.lock -.byebug_history diff --git a/Appraisals b/Appraisals index 69be857..069101c 100644 --- a/Appraisals +++ b/Appraisals @@ -1,17 +1,14 @@ appraise 'rails_5_0' do gem 'activesupport', '~> 5.0.0' gem 'actionpack', '~> 5.0.0' - gem 'byebug' end appraise 'rails_5_1' do gem 'activesupport', '~> 5.1.0' gem 'actionpack', '~> 5.1.0' - gem 'byebug' end appraise 'rails_5_2' do gem 'activesupport', '~> 5.2.0' gem 'actionpack', '~> 5.2.0' - gem 'byebug' end diff --git a/Gemfile b/Gemfile index 9578583..b4e2a20 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source "https://rubygems.org" gemspec -gem 'byebug' diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index bcf5bd0..c03a540 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -4,6 +4,5 @@ source "https://rubygems.org" gem "activesupport", "~> 5.0.0" gem "actionpack", "~> 5.0.0" -gem "byebug" gemspec path: "../" diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index 2a51a9c..98a6051 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -4,6 +4,5 @@ source "https://rubygems.org" gem "activesupport", "~> 5.1.0" gem "actionpack", "~> 5.1.0" -gem "byebug" gemspec path: "../" diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile index 11e34b4..41b8b1b 100644 --- a/gemfiles/rails_5_2.gemfile +++ b/gemfiles/rails_5_2.gemfile @@ -4,6 +4,5 @@ source "https://rubygems.org" gem "activesupport", "~> 5.2.0" gem "actionpack", "~> 5.2.0" -gem "byebug" gemspec path: "../" diff --git a/test/test_helper.rb b/test/test_helper.rb index 6f9a534..c09b729 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,7 +3,6 @@ require 'mocha/setup' require 'active_support' require 'action_controller' -require 'byebug' if ActiveSupport::VERSION::MAJOR > 3 require 'active_support/testing/autorun' From 94808b83357bf2593766eabc3c855330d86b57b0 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Fri, 19 Aug 2022 13:24:42 -0400 Subject: [PATCH 18/18] Bump version and update gemspec dependencies --- README.rdoc | 4 +++- verification.gemspec | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index 1260a72..24cdc98 100644 --- a/README.rdoc +++ b/README.rdoc @@ -33,4 +33,6 @@ Usage: Note that these prerequisites are not business rules. They do not examine the content of the session or the parameters. That level of validation should -be encapsulated by your domain model or helper methods in the controller. \ No newline at end of file +be encapsulated by your domain model or helper methods in the controller. + +** Version 2.0.0 introduces breaking changes that remove support for Rails < 5.0 ** diff --git a/verification.gemspec b/verification.gemspec index 90d6cb2..d7c846e 100644 --- a/verification.gemspec +++ b/verification.gemspec @@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = "verification" - s.version = "1.0.5" + s.version = "2.0.0" s.platform = Gem::Platform::RUBY s.authors = ["David Heinemeier Hansson"] s.email = ["david@loudthinking.com"] @@ -15,8 +15,8 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_dependency('activesupport', '>= 3.0.0', '< 6') - s.add_dependency('actionpack', '>= 3.0.0', '< 6') + s.add_dependency('activesupport', '>= 5.0.0', '< 6') + s.add_dependency('actionpack', '>= 5.0.0', '< 6') s.add_development_dependency('rake') s.add_development_dependency('appraisal')