Permalink
Browse files

The console --sandbox transaction should not be joinable

Thanks @neerajdotname for noticing this bug.
  • Loading branch information...
1 parent 8f9c81b commit e5fc096bea4e56a9eb17a80f12775b92c8a8f1ee @jonleighton jonleighton committed Mar 8, 2013
@@ -1,4 +1,5 @@
-ActiveRecord::Base.connection.begin_transaction
+ActiveRecord::Base.connection.begin_transaction(joinable: false)
+
at_exit do
ActiveRecord::Base.connection.rollback_transaction
end
@@ -119,9 +119,11 @@ def assert_output(expected, timeout = 0.2)
assert output.include?(expected), "#{expected.inspect} expected, but got:\n\n#{output}"
end
- def write_prompt(command)
+ def write_prompt(command, expected_output = nil)
@master.puts command
assert_output command
+ assert_output expected_output if expected_output
+ assert_output "> "
end
def kill(pid)
@@ -143,21 +145,17 @@ def spawn_console
def test_sandbox
pid = spawn_console
- write_prompt "Post.count"
- assert_output "=> 0"
-
+ write_prompt "Post.count", "=> 0"
write_prompt "Post.create"
- assert_output "=> "
-
- write_prompt "Post.count"
- assert_output "=> 1"
+ write_prompt "Post.count", "=> 1"
kill pid
pid = spawn_console
- write_prompt "Post.count"
- assert_output "=> 0"
+ write_prompt "Post.count", "=> 0"
+ write_prompt "Post.transaction { Post.create; raise }"
+ write_prompt "Post.count", "=> 0"
ensure
kill pid
end

0 comments on commit e5fc096

Please sign in to comment.