Skip to content

Instantly share code, notes, and snippets.

@miloops
Created December 27, 2009 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miloops/264397 to your computer and use it in GitHub Desktop.
Save miloops/264397 to your computer and use it in GitHub Desktop.
require 'spec_helper'
module Arel
describe Lock do
before do
@relation = Table.new(:users)
end
describe '#to_sql' do
it "manufactures a simple select query lock" do
sql = @relation.lock.to_sql
adapter_is :mysql do
sql.should be_like(%Q{
SELECT `users`.`id`, `users`.`name`
FROM `users` FOR UPDATE
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
SELECT "users"."id", "users"."name"
FROM "users" FOR UPDATE
})
end
end
it "manufactures a select query locking with a given lock" do
sql = @relation.lock("LOCK IN SHARE MODE").to_sql
adapter_is :mysql do
sql.should be_like(%Q{
SELECT `users`.`id`, `users`.`name`
FROM `users` LOCK IN SHARE MODE
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
SELECT "users"."id", "users"."name"
FROM "users" LOCK IN SHARE MODE
})
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment