Created
June 27, 2013 07:07
-
-
Save pftg/5874525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '3.2.13' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :gynecologic_examination_uterine_boundaries do |t| | |
t.string :value | |
t.timestamps | |
end | |
create_table :gynecologic_examinations do |t| | |
t.date :date | |
t.integer :uterine_boundary_id | |
t.timestamps | |
end | |
end | |
class GynecologicExamination < ActiveRecord::Base | |
belongs_to :uterine_boundary | |
attr_accessible :date, :uterine_boundary_id, :uterine_boundary | |
end | |
class GynecologicExamination::UterineBoundary < ActiveRecord::Base | |
has_many :gynecologic_examination | |
attr_accessible :value | |
end | |
class BugTest < MiniTest::Unit::TestCase | |
def test_association_stuff | |
boundary = GynecologicExamination::UterineBoundary.create value: 'test' | |
exam = GynecologicExamination.create(:date => Date.today, uterine_boundary_id: boundary.id) | |
assert exam.uterine_boundary, 'should be associated' | |
exam = GynecologicExamination.create(:date => Date.today, uterine_boundary: boundary) | |
assert exam.uterine_boundary, 'should be associated' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment