From 3c08782f3699ed1b440d49fee8eadb42aff85e74 Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Wed, 15 Aug 2018 11:01:05 -0500 Subject: [PATCH] add failing tests for `joins` bug --- spec/paper_trail/model_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/paper_trail/model_spec.rb b/spec/paper_trail/model_spec.rb index f3215dad6..1ffaa1c08 100644 --- a/spec/paper_trail/model_spec.rb +++ b/spec/paper_trail/model_spec.rb @@ -850,4 +850,20 @@ expect(widget.versions.empty?).to(eq(true)) end end + + context "joins" do + it "works" do + model = Song + model.create! + result = model.joins(:versions).select("songs.*, max(versions.event) as event").first + expect(result.event).to eq("create") + end + + it "works on an STI model" do + model = Family::CelebrityFamily + model.create! + result = model.joins(:versions).select("families.*, max(versions.event) as event").first + expect(result.event).to eq("create") + end + end end