active_record_tweaks 0.2.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CODEOWNERS +13 -0
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +20 -0
- data/.github/workflows/coverage.yml +66 -0
- data/.github/workflows/tests.yaml +55 -0
- data/Appraisals +8 -8
- data/CHANGELOG.md +34 -6
- data/README.md +7 -3
- data/Rakefile +0 -3
- data/active_record_tweaks.gemspec +5 -5
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5_2.gemfile +10 -0
- data/gemfiles/rails_6_0.gemfile +10 -0
- data/gemfiles/rails_6_1.gemfile +10 -0
- data/gemfiles/rails_7_0.gemfile +10 -0
- data/lib/active_record_tweaks/integration.rb +25 -7
- data/lib/active_record_tweaks/version.rb +3 -1
- data/spec/active_record_tweaks_spec.rb +39 -14
- data/spec/spec_helper.rb +18 -3
- metadata +40 -32
- data/.rubocop.yml +0 -803
- data/.travis.yml +0 -25
- data/gemfiles/rails_4_0.gemfile +0 -10
- data/gemfiles/rails_4_1.gemfile +0 -10
- data/gemfiles/rails_4_2.gemfile +0 -10
- data/gemfiles/rails_5_0.gemfile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 148a7169a1a8ecdaa48749b04a6b6d3fbca5148717cd397271de51e59cd29a1f
|
4
|
+
data.tar.gz: 992fd1f3433839433bef7e645ca8d2cb10d3d1a28d3da6fce327f90c258220ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fbf083180ee5c4a27a81d9715ff7f51b96ef9ee04bcc67b471658ff831c21a21a6234b9acb4eea9c83d2b5aafb0b9ba85f5690ced0a93123d4c7b9e1ce30239
|
7
|
+
data.tar.gz: d999cf0151e108094a4494f755e6f4ba8d7cd71d02292364bb4a759b2a7ac1fd37da38639e3457aece5d55ad9d5be566e8a5610fe6b35610ed2eef5494e46b03
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Lines starting with '#' are comments.
|
2
|
+
# Each line is a file pattern followed by one or more owners.
|
3
|
+
|
4
|
+
# These owners will be the default owners for everything in the repo.
|
5
|
+
* @PikachuEXE
|
6
|
+
|
7
|
+
# Order is important. The last matching pattern has the most precedence.
|
8
|
+
# So if a pull request only touches javascript files, only these owners
|
9
|
+
# will be requested to review.
|
10
|
+
# *.rb @PikachuEXE
|
11
|
+
|
12
|
+
# You can also use email addresses if you prefer.
|
13
|
+
# docs/* docs@example.com
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: monthly
|
7
|
+
time: "06:00"
|
8
|
+
timezone: Asia/Hong_Kong
|
9
|
+
open-pull-requests-limit: 10
|
10
|
+
labels:
|
11
|
+
- "dependencies"
|
12
|
+
- package-ecosystem: github-actions
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: monthly
|
16
|
+
time: "06:00"
|
17
|
+
timezone: Asia/Hong_Kong
|
18
|
+
open-pull-requests-limit: 10
|
19
|
+
labels:
|
20
|
+
- "dependencies"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
name: Coverage
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
paths-ignore:
|
8
|
+
- 'README.md'
|
9
|
+
push:
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
paths-ignore:
|
13
|
+
- 'README.md'
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
coverage:
|
17
|
+
name: Coverage
|
18
|
+
# Homemade support for [ci skip] no longer needed
|
19
|
+
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
|
20
|
+
# if: "contains(github.event.commits[0].message, '[ci skip]') == false"
|
21
|
+
strategy:
|
22
|
+
fail-fast: false
|
23
|
+
matrix:
|
24
|
+
os:
|
25
|
+
- ubuntu
|
26
|
+
ruby:
|
27
|
+
- "2.7"
|
28
|
+
gemfile:
|
29
|
+
- gemfiles/rails_5_2.gemfile
|
30
|
+
- gemfiles/rails_6_0.gemfile
|
31
|
+
- gemfiles/rails_6_1.gemfile
|
32
|
+
- gemfiles/rails_7_0.gemfile
|
33
|
+
env:
|
34
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
35
|
+
COVERALLS: true
|
36
|
+
runs-on: ${{ matrix.os }}-latest
|
37
|
+
steps:
|
38
|
+
- name: Checkout
|
39
|
+
uses: actions/checkout@v3
|
40
|
+
|
41
|
+
- name: Setup Ruby
|
42
|
+
uses: ruby/setup-ruby@v1
|
43
|
+
with:
|
44
|
+
ruby-version: ${{ matrix.ruby }}
|
45
|
+
bundler-cache: true
|
46
|
+
|
47
|
+
- name: Collect coverage info
|
48
|
+
run: bundle exec rake spec
|
49
|
+
|
50
|
+
- name: Coveralls Parallel
|
51
|
+
uses: coverallsapp/github-action@master
|
52
|
+
continue-on-error: true
|
53
|
+
with:
|
54
|
+
github-token: ${{ secrets.github_token }}
|
55
|
+
flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile }}
|
56
|
+
parallel: true
|
57
|
+
|
58
|
+
finish:
|
59
|
+
needs: coverage
|
60
|
+
runs-on: ubuntu-latest
|
61
|
+
steps:
|
62
|
+
- name: Send to Coveralls
|
63
|
+
uses: coverallsapp/github-action@master
|
64
|
+
with:
|
65
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
66
|
+
parallel-finished: true
|
@@ -0,0 +1,55 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
paths-ignore:
|
8
|
+
- 'README.md'
|
9
|
+
push:
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
paths-ignore:
|
13
|
+
- 'README.md'
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
unit_tests:
|
17
|
+
name: Unit Tests
|
18
|
+
# Homemade support for [ci skip] no longer needed
|
19
|
+
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
|
20
|
+
# if: "contains(github.event.commits[0].message, '[ci skip]') == false"
|
21
|
+
strategy:
|
22
|
+
fail-fast: false
|
23
|
+
matrix:
|
24
|
+
os:
|
25
|
+
- ubuntu
|
26
|
+
ruby:
|
27
|
+
- "2.7"
|
28
|
+
- "3.0"
|
29
|
+
- "3.1"
|
30
|
+
gemfile:
|
31
|
+
- gemfiles/rails_6_0.gemfile
|
32
|
+
- gemfiles/rails_6_1.gemfile
|
33
|
+
- gemfiles/rails_7_0.gemfile
|
34
|
+
allow_failures:
|
35
|
+
- false
|
36
|
+
include:
|
37
|
+
- os: ubuntu
|
38
|
+
ruby: ruby-head
|
39
|
+
gemfile: gemfiles/rails_7_0.gemfile
|
40
|
+
allow_failures: true
|
41
|
+
env:
|
42
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
43
|
+
ALLOW_FAILURES: "${{ matrix.allow_failures }}"
|
44
|
+
runs-on: ${{ matrix.os }}-latest
|
45
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
46
|
+
steps:
|
47
|
+
- name: Checkout
|
48
|
+
uses: actions/checkout@v3
|
49
|
+
- name: Setup Ruby
|
50
|
+
uses: ruby/setup-ruby@v1
|
51
|
+
with:
|
52
|
+
ruby-version: ${{ matrix.ruby }}
|
53
|
+
bundler-cache: true
|
54
|
+
- name: Test
|
55
|
+
run: bundle exec rake spec || $ALLOW_FAILURES
|
data/Appraisals
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
|
2
|
-
appraise "
|
3
|
-
version = "~>
|
2
|
+
appraise "rails_5_2" do
|
3
|
+
version = "~> 5.2.0"
|
4
4
|
gem "activesupport", version
|
5
5
|
gem "actionpack", version
|
6
6
|
gem "activerecord", version
|
7
7
|
gem "railties", version
|
8
8
|
end
|
9
9
|
|
10
|
-
appraise "
|
11
|
-
version = "~>
|
10
|
+
appraise "rails_6_0" do
|
11
|
+
version = "~> 6.0.0"
|
12
12
|
gem "activesupport", version
|
13
13
|
gem "actionpack", version
|
14
14
|
gem "activerecord", version
|
15
15
|
gem "railties", version
|
16
16
|
end
|
17
17
|
|
18
|
-
appraise "
|
19
|
-
version = "~>
|
18
|
+
appraise "rails_6_1" do
|
19
|
+
version = "~> 6.1.0"
|
20
20
|
gem "activesupport", version
|
21
21
|
gem "actionpack", version
|
22
22
|
gem "activerecord", version
|
23
23
|
gem "railties", version
|
24
24
|
end
|
25
25
|
|
26
|
-
appraise "
|
27
|
-
version = "~>
|
26
|
+
appraise "rails_7_0" do
|
27
|
+
version = "~> 7.0.0"
|
28
28
|
gem "activesupport", version
|
29
29
|
gem "actionpack", version
|
30
30
|
gem "activerecord", version
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,31 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
18
18
|
- Nothing
|
19
19
|
|
20
20
|
|
21
|
+
## [0.2.5] - 2022-04-12
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Add support for AR 7.x
|
26
|
+
- Drop support for Ruby < 2.7
|
27
|
+
|
28
|
+
|
29
|
+
## [0.2.4] - 2019-08-26
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- Add support for AR 6.x
|
34
|
+
- Drop support for Ruby < 2.4
|
35
|
+
|
36
|
+
|
37
|
+
## [0.2.3] - 2017-05-11
|
38
|
+
|
39
|
+
### Changed
|
40
|
+
|
41
|
+
- Add support for AR 5.1.x
|
42
|
+
- Drop support for AR 4.0.x
|
43
|
+
- Drop support for Ruby < 2.2
|
44
|
+
|
45
|
+
|
21
46
|
## [0.2.2] - 2016-12-23
|
22
47
|
|
23
48
|
### Changed
|
@@ -49,10 +74,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
49
74
|
### Added
|
50
75
|
|
51
76
|
- Initial Release
|
52
|
-
|
53
|
-
|
54
|
-
[Unreleased]: https://github.com/
|
55
|
-
[0.2.
|
56
|
-
[0.2.
|
57
|
-
[0.2.
|
77
|
+
|
78
|
+
|
79
|
+
[Unreleased]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.2.5...HEAD
|
80
|
+
[0.2.5]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.2.4...v0.2.5
|
81
|
+
[0.2.4]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.2.3...v0.2.4
|
82
|
+
[0.2.3]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.2.2...v0.2.3
|
83
|
+
[0.2.2]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.2.1...v0.2.2
|
84
|
+
[0.2.1]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.2.0...v0.2.1
|
85
|
+
[0.2.0]: https://github.com/PikachuEXE/active_record_tweaks/compare/v0.1...v0.2.0
|
58
86
|
|
data/README.md
CHANGED
@@ -5,11 +5,15 @@ Active Record is great, but could be better. Here are some tweaks for it.
|
|
5
5
|
|
6
6
|
## Status
|
7
7
|
|
8
|
-
[![Build Status](
|
8
|
+
[![GitHub Build Status](https://img.shields.io/github/workflow/status/PikachuEXE/active_record_tweaks/Tests?style=flat-square)](https://github.com/PikachuEXE/active_record_tweaks/actions?query=workflow%3ATests)
|
9
|
+
|
9
10
|
[![Gem Version](http://img.shields.io/gem/v/active_record_tweaks.svg?style=flat-square)](http://badge.fury.io/rb/active_record_tweaks)
|
10
|
-
[![
|
11
|
+
[![License](https://img.shields.io/github/license/PikachuEXE/active_record_tweaks.svg?style=flat-square)](http://badge.fury.io/rb/active_record_tweaks)
|
12
|
+
|
11
13
|
[![Coverage Status](http://img.shields.io/coveralls/PikachuEXE/active_record_tweaks.svg?style=flat-square)](https://coveralls.io/r/PikachuEXE/active_record_tweaks)
|
12
|
-
[![Code Climate](
|
14
|
+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/PikachuEXE/active_record_tweaks.svg?style=flat-square)](https://codeclimate.com/github/PikachuEXE/active_record_tweaks)
|
15
|
+
|
16
|
+
> The above badges are generated by https://shields.io/
|
13
17
|
|
14
18
|
|
15
19
|
## Installation
|
data/Rakefile
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
require "appraisal"
|
2
2
|
require "bundler"
|
3
3
|
require "rspec/core/rake_task"
|
4
|
-
require "rubocop/rake_task"
|
5
4
|
|
6
5
|
Bundler::GemHelper.install_tasks
|
7
6
|
|
8
7
|
RSpec::Core::RakeTask.new(:spec)
|
9
8
|
|
10
|
-
RuboCop::RakeTask.new(:rubocop)
|
11
|
-
|
12
9
|
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
13
10
|
task :default do
|
14
11
|
sh "appraisal install && rake appraisal spec"
|
@@ -27,21 +27,21 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
28
28
|
s.require_paths = ["lib"]
|
29
29
|
|
30
|
-
s.add_dependency "activerecord", ">=
|
30
|
+
s.add_dependency "activerecord", ">= 5.2.0", "< 8.0.0"
|
31
31
|
|
32
32
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
33
|
-
s.add_development_dependency "rake", "
|
33
|
+
s.add_development_dependency "rake", ">= 10.0", "<= 14.0"
|
34
34
|
s.add_development_dependency "appraisal", "~> 2.0"
|
35
35
|
s.add_development_dependency "rspec", "~> 3.0"
|
36
36
|
s.add_development_dependency "rspec-its", "~> 1.0"
|
37
37
|
s.add_development_dependency "sqlite3", ">= 1.3"
|
38
38
|
s.add_development_dependency "database_cleaner", ">= 1.0"
|
39
|
-
s.add_development_dependency "
|
39
|
+
s.add_development_dependency "simplecov", ">= 0.21"
|
40
|
+
s.add_development_dependency "simplecov-lcov", ">= 0.8"
|
40
41
|
s.add_development_dependency "gem-release", ">= 0.7"
|
41
42
|
s.add_development_dependency "timecop", ">= 0.7.1"
|
42
|
-
s.add_development_dependency "rubocop", "~> 0.30"
|
43
43
|
|
44
|
-
s.required_ruby_version = ">= 2.
|
44
|
+
s.required_ruby_version = ">= 2.7.0"
|
45
45
|
|
46
46
|
s.required_rubygems_version = ">= 1.4.0"
|
47
47
|
end
|
@@ -40,8 +40,14 @@ module ActiveRecordTweaks
|
|
40
40
|
|
41
41
|
timestamp = max_updated_attribute_timestamp_for_cache_key(attribute_names)
|
42
42
|
if timestamp
|
43
|
-
|
44
|
-
|
43
|
+
timestamp_str = timestamp.utc.yield_self do |utc_time|
|
44
|
+
if utc_time.respond_to?(:to_fs)
|
45
|
+
utc_time.to_fs(cache_timestamp_format)
|
46
|
+
else
|
47
|
+
utc_time.to_s(cache_timestamp_format)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
"#{self.class.model_name.cache_key}/#{id}-#{timestamp_str}"
|
45
51
|
else
|
46
52
|
"#{self.class.model_name.cache_key}/#{id}"
|
47
53
|
end
|
@@ -61,9 +67,15 @@ module ActiveRecordTweaks
|
|
61
67
|
end
|
62
68
|
|
63
69
|
module ClassMethods
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
def self.extended(_base)
|
71
|
+
# rubocop:disable all
|
72
|
+
warn ([
|
73
|
+
"[DEPRECATION]",
|
74
|
+
"`ActiveRecordTweaks::Integration::ClassMethods` is deprecated without replacement.",
|
75
|
+
"Please read README in project for details."
|
76
|
+
].join(" "))
|
77
|
+
# rubocop:enable all
|
78
|
+
end
|
67
79
|
|
68
80
|
# Returns a cache key for the ActiveRecord class based
|
69
81
|
# based on count and maximum value of update timestamp columns
|
@@ -81,8 +93,14 @@ module ActiveRecordTweaks
|
|
81
93
|
timestamp_columns = args.empty? ? [:updated_at] : args
|
82
94
|
|
83
95
|
if (timestamp = max_updated_column_timestamp_for_cache_key(timestamp_columns))
|
84
|
-
|
85
|
-
|
96
|
+
timestamp_str = timestamp.utc.yield_self do |utc_time|
|
97
|
+
if utc_time.respond_to?(:to_fs)
|
98
|
+
utc_time.to_fs(cache_timestamp_format)
|
99
|
+
else
|
100
|
+
utc_time.to_s(cache_timestamp_format)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
"#{model_name.cache_key}/all/#{count}-#{timestamp_str}"
|
86
104
|
else
|
87
105
|
cache_key_without_timestamp
|
88
106
|
end
|
@@ -23,7 +23,7 @@ describe Parent do
|
|
23
23
|
let(:record) { Parent.create! }
|
24
24
|
|
25
25
|
context "and update_at is nil" do
|
26
|
-
before { record.
|
26
|
+
before { record.update!(updated_at: nil) }
|
27
27
|
|
28
28
|
it "works like #cache_key" do
|
29
29
|
should eq "#{record.class.model_name.cache_key}/#{record.id}"
|
@@ -58,9 +58,26 @@ describe Parent do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
let(:virtual_update_at_1) { record.virtual_update_at_1 }
|
61
|
-
let(:virtual_update_at_1_in_cache_key)
|
61
|
+
let(:virtual_update_at_1_in_cache_key) do
|
62
|
+
|
63
|
+
virtual_update_at_1.utc.yield_self do |utc_time|
|
64
|
+
if utc_time.respond_to?(:to_fs)
|
65
|
+
utc_time.to_fs(:nsec)
|
66
|
+
else
|
67
|
+
utc_time.to_s(:nsec)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
62
71
|
let(:virtual_update_at_2) { record.virtual_update_at_2 }
|
63
|
-
let(:virtual_update_at_2_in_cache_key)
|
72
|
+
let(:virtual_update_at_2_in_cache_key) do
|
73
|
+
virtual_update_at_2.utc.yield_self do |utc_time|
|
74
|
+
if utc_time.respond_to?(:to_fs)
|
75
|
+
utc_time.to_fs(:nsec)
|
76
|
+
else
|
77
|
+
utc_time.to_s(:nsec)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
64
81
|
|
65
82
|
subject { record.cache_key_from_attribute(*arguments) }
|
66
83
|
|
@@ -211,8 +228,16 @@ describe Parent do
|
|
211
228
|
let!(:parent) { klass.create! }
|
212
229
|
|
213
230
|
it do
|
231
|
+
expected_time_str = klass.maximum(:updated_at).utc.yield_self do |utc_time|
|
232
|
+
if utc_time.respond_to?(:to_fs)
|
233
|
+
utc_time.to_fs(:nsec)
|
234
|
+
else
|
235
|
+
utc_time.to_s(:nsec)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
214
239
|
should eq "parents/all/"\
|
215
|
-
"#{klass.count}-#{
|
240
|
+
"#{klass.count}-#{expected_time_str}"
|
216
241
|
end
|
217
242
|
|
218
243
|
context "when record all has nil updated timestamps" do
|
@@ -258,13 +283,13 @@ describe Parent do
|
|
258
283
|
let!(:person) { klass.create! }
|
259
284
|
|
260
285
|
context "and it has updated_at value only" do
|
261
|
-
before { person.
|
286
|
+
before { person.update!(updated_at: Time.now, updated_on: nil) }
|
262
287
|
|
263
288
|
it { should eq "people/all/#{klass.count}" }
|
264
289
|
end
|
265
290
|
|
266
291
|
context "and it has updated_on value only" do
|
267
|
-
before { person.
|
292
|
+
before { person.update!(updated_at: nil, updated_on: Time.now) }
|
268
293
|
|
269
294
|
it do
|
270
295
|
should eq "people/all/"\
|
@@ -287,7 +312,7 @@ describe Parent do
|
|
287
312
|
|
288
313
|
context "and it has updated_on value only" do
|
289
314
|
before do
|
290
|
-
person.
|
315
|
+
person.update!(
|
291
316
|
updated_at: nil,
|
292
317
|
updated_on: Time.now,
|
293
318
|
)
|
@@ -301,7 +326,7 @@ describe Parent do
|
|
301
326
|
|
302
327
|
context "and it has newer updated_at" do
|
303
328
|
before do
|
304
|
-
person.
|
329
|
+
person.update!(
|
305
330
|
updated_at: Time.now + 3600,
|
306
331
|
updated_on: Time.now,
|
307
332
|
)
|
@@ -315,7 +340,7 @@ describe Parent do
|
|
315
340
|
|
316
341
|
context "and it has newer updated_on" do
|
317
342
|
before do
|
318
|
-
person.
|
343
|
+
person.update!(
|
319
344
|
updated_at: Time.now,
|
320
345
|
updated_on: Time.now + 3600,
|
321
346
|
)
|
@@ -342,7 +367,7 @@ describe Parent do
|
|
342
367
|
|
343
368
|
context "and it has updated_on value only" do
|
344
369
|
before do
|
345
|
-
person.
|
370
|
+
person.update!(
|
346
371
|
updated_at: nil,
|
347
372
|
updated_on: Time.now,
|
348
373
|
)
|
@@ -353,7 +378,7 @@ describe Parent do
|
|
353
378
|
|
354
379
|
context "and it has newer updated_at" do
|
355
380
|
before do
|
356
|
-
person.
|
381
|
+
person.update!(
|
357
382
|
updated_at: Time.now + 3600,
|
358
383
|
updated_on: Time.now,
|
359
384
|
)
|
@@ -364,7 +389,7 @@ describe Parent do
|
|
364
389
|
|
365
390
|
context "and it has newer updated_on" do
|
366
391
|
before do
|
367
|
-
person.
|
392
|
+
person.update!(
|
368
393
|
updated_at: Time.now,
|
369
394
|
updated_on: Time.now + 3600,
|
370
395
|
)
|
@@ -439,13 +464,13 @@ describe Parent do
|
|
439
464
|
let!(:person) { klass.create! }
|
440
465
|
|
441
466
|
context "and it has updated_at value only" do
|
442
|
-
before { person.
|
467
|
+
before { person.update!(updated_at: Time.now, updated_on: nil) }
|
443
468
|
|
444
469
|
it { should eq "people/all/#{klass.count}" }
|
445
470
|
end
|
446
471
|
|
447
472
|
context "and it has updated_on value only" do
|
448
|
-
before { person.
|
473
|
+
before { person.update!(updated_at: nil, updated_on: Time.now) }
|
449
474
|
|
450
475
|
it { should eq "people/all/#{klass.count}" }
|
451
476
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if ENV["COVERALLS"]
|
4
|
+
require "simplecov"
|
5
|
+
require "simplecov-lcov"
|
6
|
+
|
7
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
8
|
+
c.report_with_single_file = true
|
9
|
+
c.single_report_path = "coverage/lcov.info"
|
10
|
+
end
|
11
|
+
|
12
|
+
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
|
13
|
+
[SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::LcovFormatter]
|
14
|
+
)
|
15
|
+
|
16
|
+
SimpleCov.start do
|
17
|
+
add_filter "spec/"
|
18
|
+
end
|
4
19
|
end
|
5
20
|
|
6
21
|
require "active_record"
|