Skip to content

Commit

Permalink
testing sqlbypass destroy. caching connection during destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jul 23, 2010
1 parent 9b48a94 commit 5ebc1d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 7 additions & 6 deletions activerecord/lib/active_record/session_store.rb
Expand Up @@ -273,12 +273,13 @@ def save
end

def destroy
unless @new_record
@@connection.delete <<-end_sql, 'Destroy session'
DELETE FROM #{@@table_name}
WHERE #{@@connection.quote_column_name(@@session_id_column)}=#{@@connection.quote(session_id)}
end_sql
end
return if @new_record

connect = connection
connect.delete <<-end_sql, 'Destroy session'
DELETE FROM #{table_name}
WHERE #{connect.quote_column_name(session_id_column)}=#{connect.quote(session_id)}
end_sql
end
end

Expand Down
9 changes: 9 additions & 0 deletions activerecord/test/cases/session_store/sql_bypass.rb
Expand Up @@ -42,6 +42,15 @@ def test_save
assert_equal s.session_id, t.session_id
assert_equal s.data, t.data
end

def test_destroy
SqlBypass.create_table! unless Session.table_exists?
session_id = 20
s = SqlBypass.new :data => 'hello', :session_id => session_id
s.save
s.destroy
assert_nil SqlBypass.find_by_session_id session_id
end
end
end
end

0 comments on commit 5ebc1d8

Please sign in to comment.