Commit Graph

13 Commits

Author SHA1 Message Date
Jared Beck 4d877a7558 Remove touch_with_version, was deprecated in 9.0.0 2018-08-01 22:20:33 -04:00
Jared Beck 812c306892 Uninstall timecop
I'm hoping we don't actually need it because we explicitly enable
fractional seconds precision in our `dummy_app` migration by
specifying `limit(6)`.

Works on my machine, but I use mariadb. We'll see how well it works
on TravisCI, which runs mysql 5.6.33.

MySQL added support for `limit(6)` in 5.6.4, so I'm hopeful.
2018-05-14 22:31:12 -04:00
Jared Beck 97a776e255 Add save_with_version
Replaces deprecated touch_with_version
2018-04-22 23:34:28 -04:00
Weston Ganger 02b6de2dac Integrate versioning into AR touch method (#1063)
* integrate versioning into AR touch method

* add touch to list of :on events, deprecate touch_with_version

* integrate versioning into AR touch method
2018-03-16 18:21:45 -04:00
Jared Beck cfbf7a647c Lint: Style/FrozenStringLiteralComment 2017-12-10 23:05:39 -05:00
Jared Beck 38fa23873c Merge rails_helper into spec_helper
The reason some projects have both is so that some spec files can be
run in isolation, without the rails stuff. In practice, I don't find
myself ever doing this. So, the complexity of two files is unnecessary.
2017-05-30 00:59:55 -04:00
Jared Beck c4148de9d0 Configure RSpec
Enable various standard configuration.
2017-05-21 02:04:28 -04:00
Jared Beck af10cd4f00 Lint: Fix RSpec/ExampleWording 2017-04-01 01:50:13 -04:00
Jared Beck ad3806fcbb An idea to combat model pollution
Problem
-------

`has_paper_trail` adds too many methods to the ActiveRecord model.

> If I'm counting correctly, installing the paper_trail gem adds 36 instance
> methods and 10 class methods to all of your active record models. Of those
> 46, 13 have a prefix, either "pt_" or "paper_trail_". I don't know what the
> best way to deal with this is. Ideally, we'd add far fewer methods to
> people's models. If we were able to add fewer methods to models, then I
> wouldn't mind prefixing all of them.
> https://github.com/airblade/paper_trail/issues/703

Solution
--------

Add only two methods to the AR model.

1. An instance method `#paper_trail`
2. A class method `.paper_trail`

The instance method would return a `RecordTrail` and the class method would
return a `ClassTrail`. Those names are totally up for debate.

Advantages
----------

- Plain ruby, easy to understand
- Adding new methods to e.g. the `RecordTrail` does not add any methods to
  the AR model.
- Methods privacy is more strongly enforced.
- Enables isolated testing of e.g. `RecordTrail`; it can be constructed with a
  mock AR instance.

Disadvantages
-------------

- Two new classes, though they are simple.
2016-06-06 01:18:31 -04:00
Jared Beck 8980f08d0e Fix Style/StringLiterals: Use double quotes 2016-03-05 17:07:32 -05:00
Jared Beck 10941c8459 Fix Style/HashSyntax 2016-02-15 22:32:40 -05:00
Owen Rodda b9d9fb2e7c Update PaperTrail and test suite for ActiveRecord 5 compatibility 2016-01-24 19:57:10 -05:00
Jared Beck 0fd007cff9 Fixes `touch_with_version` re: the `:on` option
Fixes a bug where e.g. `on: [:create, :destroy]` (not :update)
failed to create a version.
2015-07-08 23:52:49 -04:00