I have added an ActiveSupport::Concern that declares has_paper_trail with some additional options in the class method. This concern is included by the actual model, that can now have versioning enabled on it via papertrail
Now I want to test this concern only using RSpecs on a mock model (that does not currently exist in the database), and make sure that the versions table gets populated correctly.
So I have an RSpec where I am doing this :
describe PapertrailConcern do
before(:all) do
class PaperTrailModel < ActiveRecord::Base
include PapertrailConcern
has_paper_trail
end
end
it 'stores changes to model in paper trail versions' do
# check if PaperTrailModel attribute changes are tracked in versions
end
end
Since the PaperTrail Model does not exist in the database, I get this error if I do any operations on it:
PG::UndefinedTable: ERROR: relation "paper_trail_models" does not exist
LINE 5: WHERE a.attrelid = '"paper_trail_models"'::re...
^
I also considered using Rspec Mock Model, but I am not sure how to enable papertrail versioning on a mock model. Haven't found anything along those lines online
Has anyone run into this issue or would happen to know how I could declare a test model and test if papertrail versioning works correctly on it?
Aucun commentaire:
Enregistrer un commentaire