From 4d9fc6aaabee2c599af4214f25dca9e6f84c8d34 Mon Sep 17 00:00:00 2001 From: Jared Beck Date: Thu, 8 Sep 2016 19:33:14 -0400 Subject: [PATCH] Clarify interaction between serializer_test and model_test This business with changing Fluxor on the fly is pretty confusing. It would probably be better to have different models, rather than changing Fluxor's PT config on the fly. --- spec/models/fluxor_spec.rb | 17 ----------------- test/dummy/app/models/fluxor.rb | 4 ++++ test/unit/serializer_test.rb | 20 ++++++++------------ 3 files changed, 12 insertions(+), 29 deletions(-) delete mode 100644 spec/models/fluxor_spec.rb diff --git a/spec/models/fluxor_spec.rb b/spec/models/fluxor_spec.rb deleted file mode 100644 index 7dc0e3f8..00000000 --- a/spec/models/fluxor_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "rails_helper" - -describe Fluxor, type: :model do - describe "`be_versioned` matcher" do - it { is_expected.to_not be_versioned } - end - - describe "Methods" do - describe "Class" do - describe ".paper_trail.enabled?" do - it "returns false" do - expect(Fluxor.paper_trail.enabled?).to eq(false) - end - end - end - end -end diff --git a/test/dummy/app/models/fluxor.rb b/test/dummy/app/models/fluxor.rb index 68d72306..ae500b52 100644 --- a/test/dummy/app/models/fluxor.rb +++ b/test/dummy/app/models/fluxor.rb @@ -1,3 +1,7 @@ class Fluxor < ActiveRecord::Base belongs_to :widget + + # In test/unit/model_test.rb and test/unit/serializer_test.rb, this is + # changed on the fly, which is quite confusing. + has_paper_trail end diff --git a/test/unit/serializer_test.rb b/test/unit/serializer_test.rb index 49e767d2..fd3fec9c 100644 --- a/test/unit/serializer_test.rb +++ b/test/unit/serializer_test.rb @@ -2,12 +2,16 @@ require "test_helper" require "custom_json_serializer" class SerializerTest < ActiveSupport::TestCase + setup do + # Clean up after test/unit/model_test.rb + Fluxor.reset_callbacks :create + Fluxor.reset_callbacks :update + Fluxor.reset_callbacks :destroy + Fluxor.instance_eval "has_paper_trail" + end + context "YAML Serializer" do setup do - Fluxor.instance_eval <<-END - has_paper_trail - END - @fluxor = Fluxor.create name: "Some text." # this is exactly what PaperTrail serializes @@ -34,10 +38,6 @@ class SerializerTest < ActiveSupport::TestCase config.serializer = PaperTrail::Serializers::JSON end - Fluxor.instance_eval <<-END - has_paper_trail - END - @fluxor = Fluxor.create name: "Some text." # this is exactly what PaperTrail serializes @@ -77,10 +77,6 @@ class SerializerTest < ActiveSupport::TestCase config.serializer = CustomJsonSerializer end - Fluxor.instance_eval <<-END - has_paper_trail - END - @fluxor = Fluxor.create # this is exactly what PaperTrail serializes