Skip to content
Browse files

Added support for Sessions in Sequel 3, making specs pass.

  • Loading branch information...
1 parent 5fbd1f3 commit a8239dc2cdadb3634609f77f8a22a81461fcd883 @pk committed May 4, 2009
Showing with 24 additions and 5 deletions.
  1. +15 −2 lib/merb/session/sequel_session.rb
  2. BIN spec/log/merb_test.log
  3. +1 −1 spec/sequel_ext_spec.rb
  4. +8 −2 spec/spec_helper.rb
View
17 lib/merb/session/sequel_session.rb
@@ -1,4 +1,6 @@
require 'sequel'
+# Load extensions if we use new versions of Sequel
+require 'sequel/extensions/migration' if /^(2.12|3)/ =~ Sequel.version
require 'merb-core/dispatch/session'
require 'base64'
@@ -96,11 +98,22 @@ def loaded?
!!@data
end
- before_save do
+ private
+
+ def prepare_data_to_save
@values[:data] = Marshal.dump(self.data)
if @values[:data].size > self.class.data_column_size_limit
raise Merb::SessionMixin::SessionOverflow
- end
+ end
+ end
+
+ if /^(2.12|3)/ =~ Sequel.version
+ def before_save
+ super
+ prepare_data_to_save
+ end
+ else
+ before_save :prepare_data_to_save
end
end
View
BIN spec/log/merb_test.log
Binary file not shown.
View
2 spec/sequel_ext_spec.rb
@@ -4,7 +4,7 @@
it_should_behave_like "it has a SpecModel"
it "is defined" do
- SpecModel.instance_methods.should include 'new_record?'
+ SpecModel.instance_methods.map {|m| m.to_sym }.should include(:new_record?)
end
it "Returns true or new model" do
View
10 spec/spec_helper.rb
@@ -9,7 +9,13 @@
require File.join( File.dirname(__FILE__), "..", "lib", 'merb_sequel')
-Merb.start :environment => 'test', :adapter => 'runner', :session_store => 'sequel', :merb_root => File.dirname(__FILE__)
+Merb.start :environment => 'test',
+ :adapter => 'runner',
+ :session_store => 'sequel',
+ :merb_root => File.dirname(__FILE__)
+
+# Load extensions if we use new versions of Sequel
+require 'sequel/extensions/migration' if /^(2.12|3)/ =~ Sequel.version
Spec::Runner.configure do |config|
config.include Merb::Test::RequestHelper
@@ -20,4 +26,4 @@
end
require File.join( File.dirname(__FILE__), 'spec_model')
-require File.join( File.dirname(__FILE__), 'spec_controller')
+require File.join( File.dirname(__FILE__), 'spec_controller')

0 comments on commit a8239dc

Please sign in to comment.
Something went wrong with that request. Please try again.