Skip to content

Instantly share code, notes, and snippets.

@mfazekas
Created March 23, 2018 19:17
Show Gist options
  • Save mfazekas/1a8778dfea45961ec1333506ca12d837 to your computer and use it in GitHub Desktop.
Save mfazekas/1a8778dfea45961ec1333506ca12d837 to your computer and use it in GitHub Desktop.
Paranoia issue with rails 5.2.0.rc2
# 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 "paranoia", "2.4.0"
gem "activerecord", "5.2.0.rc2"
gem "sqlite3"
gem "byebug"
end
require "active_record"
require "minitest/autorun"
require "logger"
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# 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 :posts, force: true do |t|
t.datetime :deleted_at
end
create_table :comments, force: true do |t|
t.integer :post_id
t.datetime :deleted_at
end
end
class Post < ActiveRecord::Base
acts_as_paranoid without_default_scope: true
has_one :comment, dependent: :destroy
end
class Comment < ActiveRecord::Base
acts_as_paranoid without_default_scope: true
belongs_to :post
end
class BugTest < Minitest::Test
def test_association_stuff
post = Post.create!
post.create_comment!
post.destroy!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment