1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
Commit graph

26 commits

Author SHA1 Message Date
Jared Beck
31862462ce Tests: Remove defunct config: time_zone_aware_types
We started setting this config in rails 5, to preserve the behavior
in rails 4, ie. `time` columns being "zone-unaware".

If we rewrite our `time` column tests to focus on the time only
(and not the date) then we don't need to set time_zone_aware_types.
2020-12-14 17:11:00 -05:00
Jared Beck
91feabfc55 Lint: Fix RSpec/InstanceVariable
Again, not an easy diff to review. I've kept the structure
as close as possible. To do so, I've had to use `let`, which
isn't my favorite, but it's better than instance variables.
2020-08-18 02:59:48 -04:00
Jared Beck
292050288f Lint: Fix RSpec/NestedGroups
Test are easier to understand when you can see the whole test on one
page, without scrolling around through half a dozen nesting levels.

This will be a difficult diff to review. Basically, I've converted
tests like:

```
context 'create' do
  context 'update' do
    context 'delete' do
```

to:

```
context 'create'
context 'create, then update'
context 'create, then update, then delete'
```
2020-08-18 02:21:41 -04:00
Jared Beck
4c4f1ec086 Lint: RSpec/ContextMethod 2019-10-21 13:06:23 -04:00
Jared Beck
24f3fbcd8f PT-AT is now responsible for testing itself
See historical overview in README
2019-08-06 02:45:06 -04:00
Jared Beck
43dca0bc24 Follow-up to PR #1188 2019-03-14 14:49:34 -04:00
Sergey Tokarenko
cf17bc47a6 Lower the memory allocations
It prevents the repeating hashes creation during the calculation of `object` and `object_changes`.

The real-life case, discovered with a help of `memory_profiler` gem:
1. It saves `~35Mb` per bulk of 100 typical objects like `User`;
2. It saves `~875Mb` per Sidekiq process full of bulk jobs like P1,
   under default concurrency 25.
2019-03-14 14:27:18 -04:00
Edouard Chin
2b479a7f08 Support rails 6.0.0 (#1172)
* Change update_attributes to update

In Rails 6.0 update_attributes/update_attributes! is considered deprecated. Method update/update! is the replacement.

* CI: Don't use Bundler 1.16.1

- Bundler 1.16.1 has bug where dependencies can't be resolved properly
  when a gem is a release candidate or an alpha version.
  The underlying bundler issue can be found here https://github.com/bundler/bundler/issues/6449

* Disable eager_load in test env:

- In Rails 6.0, rails/rails@3b95478 made a change to eagerly define
  attribute methods of a Model when `eager_load` is enabled.
  This breaks our test suite because of the way we run migration.

  The TL;DR is that doing `People.attribute_names` will return an
  empty array instead of `[:id, time_zone, ...]`.
  You can find a failing build here https://travis-ci.org/paper-trail-gem/paper_trail/jobs/463369634

  Basically what happens is:

  1) The dummy app boot, attribute methods of each model are defined
     but since migration didn't run yet, the tables aren't even
     created resulting in a empty attribute set.
  2) Migration runs, but it's already too late.

  In this commit I disabled eager_loading in test, AFAIT there isn't
  much benefit in eager_loading the dummy app anyway.
  Also renaming the `user.rb` file to `postgres_user.rb` in order for
  rails autoloading to work correctly.
2018-12-04 16:10:35 -05:00
Sean Linsley
0cac983026 allow object_changes_adapter to use the default behavior 2018-08-29 12:21:58 -05:00
Jared Beck
f279ca28af Lint: RSpec/InstanceVariable in model_spec, ctn'd 2018-08-18 18:48:14 -04:00
Jared Beck
265b3d972c Remove methods deprecated in PT 9 2018-08-14 01:06:35 -04:00
Sean Linsley
c145cc46c2 Track changes on destroy (#1123)
this involved refactoring the internal serialization code so it'd be possible to run it on non-Rails-provided changes
2018-08-13 21:11:24 -04:00
Jared Beck
dadba10f18 Avoid changing schema during test run
Sean's approach to dropping/re-adding the column during the test run
worked, but it had a few disadvantages:

1. it required a `before(:all)` callback, which is frowned upon by rubocop-rspec
2. more importantly, it could have prevented us from using test parallelization
  in the future
3. least importantly, it produced annoying output in the middle of the test run
2018-08-13 15:51:02 -04:00
Sean Linsley
68ecf779da make the object column optional 2018-07-24 10:45:22 -05:00
Jared Beck
97e75d7df2 Lint: working on RSpec/InstanceVariable in model_spec.rb 2018-06-07 14:43:56 -04:00
Ashwin Hegde
776189de57 Introduce config.object_changes_adapter
Allows users to write third-party adapters giving them complete
control over the contents of the `object_changes` column.
2018-06-04 13:06:10 -04:00
Jared Beck
8730d7e5fc Deprecate RecordTrail#without_versioning 2018-03-23 22:30:36 -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
c659b1faf0 A new API for request variables 2018-02-27 00:14:33 -05:00
Jared Beck
cfbf7a647c Lint: Style/FrozenStringLiteralComment 2017-12-10 23:05:39 -05:00
Jared Beck
ce5e8cd7c1 rubocop 0.51.0 2017-10-27 11:36:37 -04:00
Jared Beck
431feb97d4 Reduce spec context nesting level in model_spec.rb 2017-10-04 23:26:53 -04:00
Jared Beck
df4f3bba4f Lint: Fix various offenses, mostly rspec
- Fix Lint/RescueWithoutErrorClass
  - And I use the term "fix" loosely
- Fix RSpec/PredicateMatcher
  - The failure message should actually be better this way too.
- RSpec/LetBeforeExamples
- RSpec/HookArgument
- Fix RSpec/ExpectInHook in widget_spec.rb
- Fix RSpec/MessageSpies
  - I like spies. I've never linted them before, but I like how they
    separate test setup from assertions.
2017-09-19 01:25:53 -04:00
Jared Beck
7295f65a3c Organizing model tests
model_spec is far too long, let's break it up into specs for individual
models in the dummy app.

Extract spec/models/legacy_widget_spec.rb

Extract spec/models/on/empty_array_spec.rb

Extract spec/models/on/create_spec.rb

Extract spec/models/on/update_spec.rb

Extract spec/models/on/destroy_spec.rb

Move an example to config_spec.rb

Extract spec/models/translation_spec.rb

Extract spec/models/article_spec.rb

Move examples to document_spec.rb
2017-07-05 00:15:15 -04: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
f099b61540 Convert test/unit/model_test.rb to rspec
- Test against ruby 2.3.4 (was 2.3.1)
- Troubleshooting time comparison in test
- Test should not care about array order
2017-05-28 20:43:35 -04:00