Skip to content

Instantly share code, notes, and snippets.

@swapnilchincholkar
Created October 16, 2015 06:56
Show Gist options
  • Save swapnilchincholkar/968096944c6c00193017 to your computer and use it in GitHub Desktop.
Save swapnilchincholkar/968096944c6c00193017 to your computer and use it in GitHub Desktop.
require 'mongoid'
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 Band
include Mongoid::Document
belongs_to :studio
end
class Studio
include Mongoid::Document
has_one :band
field :name
end
class BugTest < Minitest::Test
def test_query_count
Band.destroy_all
Studio.destroy_all
b = Band.new
b.create_studio(name:'LA')
assert_equal b.studio, Studio.first
assert_equal Studio.first.band, b
#expect( band.studio ).to eq Studio.first
#expect( Studio.first.band ).to eq band
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment