Skip to content

Instantly share code, notes, and snippets.

@dblock
Created June 2, 2014 14:01
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 dblock/6d745fbdacddebb9ba65 to your computer and use it in GitHub Desktop.
Save dblock/6d745fbdacddebb9ba65 to your computer and use it in GitHub Desktop.
require 'mongoid'
require 'mongoid/support/query_counter'
require 'minitest/autorun'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
Mongoid.configure.connect_to("mongoid_test")
class Address
include Mongoid::Document
embedded_in :person
end
class Person
include Mongoid::Document
embeds_many :addresses
end
class BugTest < Minitest::Test
def test_pluck
person = Person.create!
person.addresses.create!
assert_equal [person.id], Person.all.pluck(:id)
assert_equal [person.addresses.first.id], person.addresses.pluck(:id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment