Permalink
Browse files

hack hack hack hack hack. tests work now

  • Loading branch information...
1 parent 840b8c7 commit 58aefb8bc47911c8ebadf52c1660d1e567e5b43d @raggi committed May 24, 2011
@@ -1,3 +1,5 @@
+require 'active_record'
+
class OpenidAbstract < ActiveRecord::Base
self.abstract_class = true
end
@@ -17,7 +17,7 @@ def store_association(server_url, association)
oa.target = targetize(server_url)
oa.handle = association.handle
oa.secret = association.secret
- oa.issued_at = association.issued_at
+ oa.issued_at = association.issued
oa.lifetime = association.lifetime
oa.assoc_type = association.assoc_type
oa.save
@@ -1,25 +0,0 @@
-class CreateOpenidAssociations < ActiveRecord::Migration
-
- def self.up
- create_table :openid_associations do |t|
-
- # association fields
- t.datetime :issued_at
- t.integer :lifetime
- t.string :assoc_type
- t.text :handle
- t.text :secret
-
- # extra fields
- t.string :target, :size => 32 # store url as md5 for faster retrival
- t.text :server_url # store url
-
- t.timestamps
- end
- end
-
- def self.down
- drop_table :openid_associations
- end
-
-end
@@ -0,0 +1,22 @@
+class CreateOpenidAssociations < ActiveRecord::Migration
+
+ def self.up
+ create_table :openid_associations do |t|
+ t.datetime :issued_at
+ t.integer :lifetime
+ t.string :assoc_type
+ t.text :handle
+ t.binary :secret
+
+ t.string :target, :size => 32
+ t.text :server_url
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :openid_associations
+ end
+
+end
@@ -2,10 +2,10 @@ class CreateOpenidNonces < ActiveRecord::Migration
def self.up
create_table :openid_nonces do |t|
- t.integer :timestamp
- t.string :salt
- t.string :target, :size => 32 # store url as md5 for faster retrival
- t.text :server_url
+ t.integer :timestamp
+ t.string :salt
+ t.string :target, :size => 32
+ t.text :server_url
t.timestamps
end
end
@@ -54,9 +54,13 @@ def _check_retrieve(url, handle=nil, expected=nil)
if expected.nil?
assert_nil(ret_assoc)
else
- assert_equal(expected, ret_assoc)
- assert_equal(expected.handle, ret_assoc.handle)
- assert_equal(expected.secret, ret_assoc.secret)
+ %w[assoc_type handle issued lifetime secret].each do |prop|
+ ex, actual = expected.send(prop), ret_assoc.send(prop)
+ if ex.kind_of?(Time)
+ ex, actual = ex.to_i, actual.to_i
+ end
+ assert_equal ex, actual, "#{prop} doesn't match"
+ end
end
end
View
@@ -1,4 +1,23 @@
require 'test/unit'
require 'openid/store/active_record'
-require 'active_support'
-require 'active_support/test_case'
+require 'active_record'
+
+db = {
+ :adapter => :mysql2,
+ :database => 'openid_active_record_store'
+}
+
+system "echo 'drop database #{db[:database]};' | mysql5 -uroot" rescue nil
+system "echo 'create database #{db[:database]};' | mysql5 -uroot"
+
+ActiveRecord::Base.establish_connection db
+
+# TODO removeme once the railtie bootstrap is used
+Dir['app/models/*.rb'].each do |model|
+ require File.expand_path(model)
+end
+
+Dir['migrations/*.rb'].each do |migration|
+ require migration
+ Object.const_get(File.basename(migration, '.rb').camelize).up
+end

0 comments on commit 58aefb8

Please sign in to comment.