Last active
April 12, 2021 12:59
-
-
Save intrip/25665e7b9e759cb021c951ea4d25f28b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# frozen_string_literal: true | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
# Activate the gem you are reporting the issue against. | |
gem "activerecord", "~> 6.1" | |
gem "sqlite3" | |
end | |
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 :countries, force: true do |t| | |
end | |
create_table :cities, force: true do |t| | |
t.references :country | |
t.string :language | |
end | |
end | |
class Country < ActiveRecord::Base | |
has_many :cities, dependent: :destroy | |
accepts_nested_attributes_for :cities | |
end | |
class City < ActiveRecord::Base | |
belongs_to :country | |
validates :language , uniqueness: true | |
end | |
class T < Minitest::Test | |
def test_case | |
country = Country.new(cities:[City.new(language: 'en-US'), City.new(language: 'en-US')]) | |
assert_equal false, country.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment