From 29ce2dd476ebbb218cea1031181d41a2d0d7e97d Mon Sep 17 00:00:00 2001 From: Lachlan Sylvester Date: Tue, 8 Sep 2015 11:34:44 +1000 Subject: [PATCH 1/2] Add rails 4.0, 4.1, 4.2 to test matrix. Fix issues with changes to query api and session_class config --- .travis.yml | 21 +++++++++++++++++++ Gemfile | 2 +- gemfiles/rails31.gemfile | 2 +- gemfiles/rails32.gemfile | 1 + gemfiles/rails40.gemfile | 8 +++++++ gemfiles/rails41.gemfile | 8 +++++++ gemfiles/rails42.gemfile | 8 +++++++ lib/casclient/tickets/storage.rb | 8 +++++-- .../storage/active_record_ticket_store.rb | 8 +++++-- rubycas-client.gemspec | 4 ++-- .../shared_examples_for_ticket_stores.rb | 6 +++++- 11 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 gemfiles/rails40.gemfile create mode 100644 gemfiles/rails41.gemfile create mode 100644 gemfiles/rails42.gemfile diff --git a/.travis.yml b/.travis.yml index a7bbff96..61f59e81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,9 @@ gemfile: - gemfiles/rails30.gemfile - gemfiles/rails31.gemfile - gemfiles/rails32.gemfile + - gemfiles/rails40.gemfile + - gemfiles/rails41.gemfile + - gemfiles/rails42.gemfile rvm: - 1.8.7 - 1.9.2 @@ -25,3 +28,21 @@ matrix: gemfile: gemfiles/rails23.gemfile - rvm: rbx gemfile: gemfiles/rails23.gemfile + - rvm: 1.8.7 + gemfile: gemfiles/rails40.gemfile + - rvm: 1.8.7 + gemfile: gemfiles/rails41.gemfile + - rvm: 1.8.7 + gemfile: gemfiles/rails42.gemfile + - rvm: jruby-18mode + gemfile: gemfiles/rails40.gemfile + - rvm: jruby-18mode + gemfile: gemfiles/rails41.gemfile + - rvm: jruby-18mode + gemfile: gemfiles/rails42.gemfile + - rvm: 1.9.2 + gemfile: gemfiles/rails40.gemfile + - rvm: 1.9.2 + gemfile: gemfiles/rails41.gemfile + - rvm: 1.9.2 + gemfile: gemfiles/rails42.gemfile \ No newline at end of file diff --git a/Gemfile b/Gemfile index 8581ecd3..f908f93c 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ group :tools do gem "guard" gem "guard-rspec" gem "guard-bundler" - gem "fuubar" + gem "fuubar", "~> 1.0" gem "rb-fsevent" gem "ruby_gntp", :group => :darwin end diff --git a/gemfiles/rails31.gemfile b/gemfiles/rails31.gemfile index a9c76694..6f240a87 100644 --- a/gemfiles/rails31.gemfile +++ b/gemfiles/rails31.gemfile @@ -3,5 +3,5 @@ source "http://rubygems.org" gem "rails", "~> 3.1.8" - +gem "i18n", "< 0.7.0" gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails32.gemfile b/gemfiles/rails32.gemfile index c0365f00..7408d88b 100644 --- a/gemfiles/rails32.gemfile +++ b/gemfiles/rails32.gemfile @@ -3,5 +3,6 @@ source "http://rubygems.org" gem "rails", "~> 3.2.8" +gem "i18n", "< 0.7.0" gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails40.gemfile b/gemfiles/rails40.gemfile new file mode 100644 index 00000000..af9e61c2 --- /dev/null +++ b/gemfiles/rails40.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 4.0.0" +gem "activerecord", require: 'active_record' +gem "activerecord-session_store" +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails41.gemfile b/gemfiles/rails41.gemfile new file mode 100644 index 00000000..3632988b --- /dev/null +++ b/gemfiles/rails41.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 4.1.0" +gem "activerecord", require: 'active_record' +gem "activerecord-session_store" +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails42.gemfile b/gemfiles/rails42.gemfile new file mode 100644 index 00000000..6b079bbb --- /dev/null +++ b/gemfiles/rails42.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 4.2.0" +gem "activerecord", require: 'active_record' +gem "activerecord-session_store" +gemspec :path=>"../" \ No newline at end of file diff --git a/lib/casclient/tickets/storage.rb b/lib/casclient/tickets/storage.rb index 0ea4f656..5d2ad1fd 100644 --- a/lib/casclient/tickets/storage.rb +++ b/lib/casclient/tickets/storage.rb @@ -29,7 +29,11 @@ def get_session_for_service_ticket(st) session_id = read_service_session_lookup(st) unless session_id.nil? # This feels a bit hackish, but there isn't really a better way to go about it that I am aware of yet - session = ActiveRecord::SessionStore.session_class.find(:first, :conditions => {:session_id => session_id}) + if ActiveRecord::SessionStore.respond_to?(:session_class) + session = ActiveRecord::SessionStore.session_class.find(:first, :conditions => {:session_id => session_id}) + else + session = ActionDispatch::Session::ActiveRecordStore.session_class.find_by(:session_id => session_id) + end else log.warn("Couldn't destroy session service ticket #{st} because no corresponding session id could be found.") end @@ -106,7 +110,7 @@ def store_service_session_lookup(st, controller) # Returns the local Rails session ID corresponding to the given # ServiceTicket. This is done by reading the contents of the - # cas_sess. file created in a prior call to + # cas_sess. file created in a prior call to # #store_service_session_lookup. def read_service_session_lookup(st) raise CASException, "No service_ticket specified." if st.nil? diff --git a/lib/casclient/tickets/storage/active_record_ticket_store.rb b/lib/casclient/tickets/storage/active_record_ticket_store.rb index ec74bc6f..a30a25d7 100644 --- a/lib/casclient/tickets/storage/active_record_ticket_store.rb +++ b/lib/casclient/tickets/storage/active_record_ticket_store.rb @@ -9,7 +9,7 @@ module Storage # Proxy Granting Tickets and their IOUs are stored in the cas_pgtious table. # # This ticket store takes the following config parameters - # :pgtious_table_name - the name of the table + # :pgtious_table_name - the name of the table class ActiveRecordTicketStore < AbstractTicketStore def initialize(config={}) @@ -17,7 +17,11 @@ def initialize(config={}) if config[:pgtious_table_name] CasPgtiou.set_table_name = config[:pgtious_table_name] end - ActiveRecord::SessionStore.session_class = ServiceTicketAwareSession + if ActiveRecord::SessionStore.respond_to?(:session_class=) + ActiveRecord::SessionStore.session_class = ServiceTicketAwareSession + else + ActionDispatch::Session::ActiveRecordStore.session_class = ServiceTicketAwareSession + end end def store_service_session_lookup(st, controller) diff --git a/rubycas-client.gemspec b/rubycas-client.gemspec index aa664837..0dc07278 100644 --- a/rubycas-client.gemspec +++ b/rubycas-client.gemspec @@ -24,9 +24,9 @@ Gem::Specification.new do |gem| gem.add_dependency("activesupport") gem.add_development_dependency("rake") - gem.add_development_dependency("database_cleaner", "~> 0.9.1") + gem.add_development_dependency("database_cleaner", "~> 1.0.0") gem.add_development_dependency("json") - gem.add_development_dependency("rspec") + gem.add_development_dependency("rspec", "~> 2.0") gem.add_development_dependency("appraisal") gem.add_development_dependency("rails") gem.add_development_dependency("simplecov") diff --git a/spec/support/shared_examples_for_ticket_stores.rb b/spec/support/shared_examples_for_ticket_stores.rb index 34c45d0c..ba9e09ff 100644 --- a/spec/support/shared_examples_for_ticket_stores.rb +++ b/spec/support/shared_examples_for_ticket_stores.rb @@ -50,7 +50,11 @@ end context "the session" do it "should be destroyed" do - ActiveRecord::SessionStore.session_class.find(:first, :conditions => {:session_id => session.session_id}).should be_nil + if ActiveRecord::SessionStore.respond_to?(:session_class=) + ActiveRecord::SessionStore.session_class.find(:first, :conditions => {:session_id => session.session_id}).should be_nil + else + ActionDispatch::Session::ActiveRecordStore.session_class.find_by(:session_id => session.session_id).should be_nil + end end end it "should destroy session for the given service ticket" do From fde8fa351e5734bee95cc867dd475a63735a01c0 Mon Sep 17 00:00:00 2001 From: Lachlan Sylvester Date: Tue, 8 Sep 2015 16:13:46 +1000 Subject: [PATCH 2/2] restrict rspec version --- rubycas-client.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rubycas-client.gemspec b/rubycas-client.gemspec index 0dc07278..a141bc93 100644 --- a/rubycas-client.gemspec +++ b/rubycas-client.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency("rake") gem.add_development_dependency("database_cleaner", "~> 1.0.0") gem.add_development_dependency("json") - gem.add_development_dependency("rspec", "~> 2.0") + gem.add_development_dependency("rspec", "~> 2.14.0") gem.add_development_dependency("appraisal") gem.add_development_dependency("rails") gem.add_development_dependency("simplecov")