active_record-updated_at 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11b3013f3d9c32bc668986d89b880ea877a10bd3
4
+ data.tar.gz: 085d518fa7940abd8e894604bf60103d00ce3cb2
5
+ SHA512:
6
+ metadata.gz: 32d49111d8517931ae445b3a36eee57fbc290323377aa357bcc2baba6bf6fb464262a8468f5a125d9b43fd77012efef5d2d7b73cd63ced9079cc2ea9ba2b9c02
7
+ data.tar.gz: e1004fd0bf6cc3b0794042eadceca4db61ae8f544b2f4d19c8145f2ede0d993c18da5377a23c886f2d80ac2ab1ca7bd9675d40e9e3c40172d4736c3a8cc1b658
@@ -0,0 +1,9 @@
1
+ steps:
2
+ - name: ":rubocop:"
3
+ command: bin/rubocop
4
+ timeout_in_minutes: 30
5
+
6
+ - name: ":rspec:"
7
+ command: bin/test
8
+ timeout_in_minutes: 30
9
+ artifact_paths: cache.tar.lz4
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ coverage
2
+ pkg
3
+ rdoc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/Dockerfile ADDED
@@ -0,0 +1,2 @@
1
+ FROM lendinghome/rails
2
+ MAINTAINER github@lendinghome.com
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://www.rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "codeclimate-test-reporter"
6
+ gem "combustion"
7
+ gem "pg"
8
+ gem "rspec-rails"
9
+ gem "timecop"
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_record-updated_at (0.0.0)
5
+ activerecord
6
+
7
+ GEM
8
+ remote: https://www.rubygems.org/
9
+ specs:
10
+ actionpack (5.0.0.1)
11
+ actionview (= 5.0.0.1)
12
+ activesupport (= 5.0.0.1)
13
+ rack (~> 2.0)
14
+ rack-test (~> 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.0.0.1)
18
+ activesupport (= 5.0.0.1)
19
+ builder (~> 3.1)
20
+ erubis (~> 2.7.0)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ activemodel (5.0.0.1)
24
+ activesupport (= 5.0.0.1)
25
+ activerecord (5.0.0.1)
26
+ activemodel (= 5.0.0.1)
27
+ activesupport (= 5.0.0.1)
28
+ arel (~> 7.0)
29
+ activesupport (5.0.0.1)
30
+ concurrent-ruby (~> 1.0, >= 1.0.2)
31
+ i18n (~> 0.7)
32
+ minitest (~> 5.1)
33
+ tzinfo (~> 1.1)
34
+ arel (7.1.4)
35
+ builder (3.2.2)
36
+ codeclimate-test-reporter (0.6.0)
37
+ simplecov (>= 0.7.1, < 1.0.0)
38
+ combustion (0.5.5)
39
+ activesupport (>= 3.0.0)
40
+ railties (>= 3.0.0)
41
+ thor (>= 0.14.6)
42
+ concurrent-ruby (1.0.2)
43
+ diff-lcs (1.2.5)
44
+ docile (1.1.5)
45
+ erubis (2.7.0)
46
+ i18n (0.7.0)
47
+ json (2.0.2)
48
+ loofah (2.0.3)
49
+ nokogiri (>= 1.5.9)
50
+ method_source (0.8.2)
51
+ mini_portile2 (2.1.0)
52
+ minitest (5.9.1)
53
+ nokogiri (1.6.8.1)
54
+ mini_portile2 (~> 2.1.0)
55
+ pg (0.19.0)
56
+ rack (2.0.1)
57
+ rack-test (0.6.3)
58
+ rack (>= 1.0)
59
+ rails-dom-testing (2.0.1)
60
+ activesupport (>= 4.2.0, < 6.0)
61
+ nokogiri (~> 1.6.0)
62
+ rails-html-sanitizer (1.0.3)
63
+ loofah (~> 2.0)
64
+ railties (5.0.0.1)
65
+ actionpack (= 5.0.0.1)
66
+ activesupport (= 5.0.0.1)
67
+ method_source
68
+ rake (>= 0.8.7)
69
+ thor (>= 0.18.1, < 2.0)
70
+ rake (11.3.0)
71
+ rspec-core (3.5.4)
72
+ rspec-support (~> 3.5.0)
73
+ rspec-expectations (3.5.0)
74
+ diff-lcs (>= 1.2.0, < 2.0)
75
+ rspec-support (~> 3.5.0)
76
+ rspec-mocks (3.5.0)
77
+ diff-lcs (>= 1.2.0, < 2.0)
78
+ rspec-support (~> 3.5.0)
79
+ rspec-rails (3.5.2)
80
+ actionpack (>= 3.0)
81
+ activesupport (>= 3.0)
82
+ railties (>= 3.0)
83
+ rspec-core (~> 3.5.0)
84
+ rspec-expectations (~> 3.5.0)
85
+ rspec-mocks (~> 3.5.0)
86
+ rspec-support (~> 3.5.0)
87
+ rspec-support (3.5.0)
88
+ simplecov (0.12.0)
89
+ docile (~> 1.1.0)
90
+ json (>= 1.8, < 3)
91
+ simplecov-html (~> 0.10.0)
92
+ simplecov-html (0.10.0)
93
+ thor (0.19.1)
94
+ thread_safe (0.3.5)
95
+ timecop (0.8.1)
96
+ tzinfo (1.2.2)
97
+ thread_safe (~> 0.1)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ active_record-updated_at!
104
+ codeclimate-test-reporter
105
+ combustion
106
+ pg
107
+ rspec-rails
108
+ timecop
109
+
110
+ BUNDLED WITH
111
+ 1.13.6
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 LendingHome - github@lendinghome.com
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # ![LendingHome](https://cloud.githubusercontent.com/assets/2419/19467866/7efa93a8-94c8-11e6-93e7-4375dbb8a7bc.png) active_record-updated_at
2
+ [![Code Climate](https://codeclimate.com/github/LendingHome/active_record-updated_at/badges/gpa.svg)](https://codeclimate.com/github/LendingHome/active_record-updated_at) [![Coverage](https://codeclimate.com/github/LendingHome/active_record-updated_at/badges/coverage.svg)](https://codeclimate.com/github/LendingHome/active_record-updated_at) [![Gem Version](https://badge.fury.io/rb/active_record-updated_at.svg)](http://badge.fury.io/rb/active_record-updated_at)
3
+
4
+ > Touch `updated_at` by default with calls to `update_column(s)` and `update_all`
5
+
6
+ ## Installation
7
+
8
+ Add this gem to the project `Gemfile`.
9
+
10
+ ```ruby
11
+ gem "active_record-updated_at"
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ The default `ActiveRecord` behavior does not touch `updated_at` when the following are called:
17
+
18
+ * `ActiveRecord::Base#update_column`
19
+ * `ActiveRecord::Base#update_columns`
20
+ * `ActiveRecord::Relation#update_all`
21
+
22
+ We **rarely ever have a case to modify data WITHOUT touching `updated_at`** so this gem enables the touching behavior by default. For those rare occassions that we don't want the touching we can call these alternative methods to explicitly disable it:
23
+
24
+ * `ActiveRecord::Base#update_column_without_updated_at`
25
+ * `ActiveRecord::Base#update_columns_without_updated_at`
26
+ * `ActiveRecord::Relation#update_all_without_updated_at`
27
+
28
+ **If `updated_at` is explicitly specified then the UPDATE query is not modified**.
29
+
30
+ ```ruby
31
+ # This touches `updated_at` with `Time.current`
32
+ User.update_all(role: "member")
33
+
34
+ # This sets `updated_at` to `1.day.ago`
35
+ User.update_all(role: "member", updated_at: 1.day.ago)
36
+
37
+ # This sets `updated_at` to `NULL`
38
+ User.update_all(role: "member", updated_at: nil)
39
+
40
+ # This doesn't touch `updated_at`
41
+ User.update_all_without_updated_at(role: "member")
42
+ ```
43
+
44
+ ## Testing
45
+
46
+ ```bash
47
+ bundle exec rspec
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ * Fork the project.
53
+ * Make your feature addition or bug fix.
54
+ * Add tests for it. This is important so we don't break it in a future version unintentionally.
55
+ * Commit, do not mess with the version or history.
56
+ * Open a pull request. Bonus points for topic branches.
57
+
58
+ ## Authors
59
+
60
+ * [Sean Huber](https://github.com/shuber)
61
+
62
+ ## License
63
+
64
+ [MIT](https://github.com/lendinghome/active_record-updated_at/blob/master/LICENSE) - Copyright © 2016 LendingHome
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.author = "LendingHome"
3
+ s.email = "github@lendinghome.com"
4
+ s.extra_rdoc_files = %w(LICENSE)
5
+ s.files = `git ls-files`.split("\n")
6
+ s.homepage = "https://github.com/lendinghome/active_record-updated_at"
7
+ s.license = "MIT"
8
+ s.name = "active_record-updated_at"
9
+ s.rdoc_options = %w(--charset=UTF-8 --inline-source --line-numbers --main README.md)
10
+ s.require_paths = %w(lib)
11
+ s.required_ruby_version = ">= 2.0.0"
12
+ s.summary = "Touch `updated_at` by default with calls to `update_column(s)` and `update_all`"
13
+ s.test_files = `git ls-files -- spec/*`.split("\n")
14
+ s.version = "0.0.0"
15
+
16
+ s.add_dependency "activerecord"
17
+ end
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ set -eo pipefail
4
+
5
+ echo -e "--- \033[33mWhat does this command do?\033[0m"
6
+ echo
7
+ echo " This script runs our LendingHome platform wide rubocop Docker image"
8
+ echo " for the gem or service mounted at /app. It uses a configuration file"
9
+ echo " that has been added directly into the rubocop Docker image itself. This"
10
+ echo " configuration lives in the lendinghome-dockerfiles repository."
11
+ echo
12
+ echo " Check out the documentation on rubocop for more information!"
13
+ echo
14
+ echo " * https://github.com/bbatsov/rubocop"
15
+ echo " * https://github.com/bbatsov/ruby-style-guide"
16
+ echo
17
+
18
+ if [ -v REBUILD_CACHE ]; then
19
+ echo "--- :docker: Pulling latest docker image"
20
+ docker-compose pull rubocop
21
+
22
+ echo "--- :recycle: Updating build cache"
23
+ echo "The build was triggered with REBUILD_CACHE"
24
+ echo "Skipping the remaining build steps"
25
+ else
26
+ echo "--- :docker: Starting docker"
27
+ docker-compose pull rubocop
28
+ docker-compose run rubocop $@
29
+ fi
data/bin/test ADDED
@@ -0,0 +1,68 @@
1
+ #!/bin/bash
2
+
3
+ set -eo pipefail
4
+
5
+ if [[ -z "$DOCKER" ]]; then
6
+ echo "--- :buildkite: Building active_record-updated_at"
7
+ buildkite-agent --version
8
+
9
+ echo "branch: $BUILDKITE_BRANCH"
10
+ echo "commit: $BUILDKITE_COMMIT"
11
+ echo "image: $DOCKER_IMAGE"
12
+
13
+ if [ -v REBUILD_CACHE ]; then
14
+ echo "--- :minidisc: Pulling images"
15
+ docker-compose pull --ignore-pull-failures
16
+ fi
17
+
18
+ echo "--- :docker: Starting docker"
19
+ docker --version
20
+ docker-compose --version
21
+
22
+ echo "Building $DOCKER_IMAGE"
23
+ docker-compose run app /app/bin/test $@
24
+
25
+ if [ -v REBUILD_CACHE ]; then
26
+ echo "--- :recycle: Updating build cache"
27
+ echo "The build was triggered with REBUILD_CACHE"
28
+
29
+ echo "Generating cache.tar.lz4"
30
+ tar -c --use-compress-program=lz4 -f cache.tar.lz4 "$BUILD_CACHE" \
31
+ || echo "Ignoring permission denied failures"
32
+
33
+ [ -v BUILDKITE ] && buildkite-agent meta-data set "rebuild-cache" "1"
34
+ fi
35
+
36
+ exit 0
37
+ fi
38
+
39
+ echo "--- :terminal: Loading environment"
40
+ echo "bash: `bash --version | head -1`"
41
+ echo "git: `git --version`"
42
+ echo "imagemagick: `identify --version | head -1`"
43
+ echo "java: `java -version 2>&1 | head -1`"
44
+ echo "os: `cat /etc/issue | head -1`"
45
+ echo "phantomjs: `phantomjs --version`"
46
+
47
+ echo "--- :ruby: Installing ruby"
48
+ rbenv install --skip-existing
49
+ ruby --version
50
+ rbenv --version
51
+
52
+ echo "--- :rubygems: Installing ruby gems"
53
+ echo "gem $(gem --version)"
54
+ bundler --version
55
+ cpus=$(nproc 2>/dev/null || echo 1)
56
+ [[ $cpus -eq 1 ]] && jobs=1 || jobs=$((cpus - 1))
57
+ options="--path vendor/bundle --jobs $jobs --retry 3 --frozen --no-cache --no-prune"
58
+ bundle check || bundle install $options
59
+
60
+ echo "--- :postgres: Creating database"
61
+ sleep 3 # give postgres container time to boot
62
+ createdb -h postgres -U postgres -w active_record-updated_at || true
63
+
64
+ if [[ -z "$REBUILD_CACHE" ]]; then
65
+ echo "+++ :rspec: Running rspec tests"
66
+ echo "rspec $(bundle exec rspec --version)"
67
+ bundle exec rspec $@
68
+ fi
@@ -0,0 +1,36 @@
1
+ version: "2"
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: "."
7
+ depends_on:
8
+ - postgres
9
+ environment:
10
+ - CI
11
+ - CODECLIMATE_REPO_TOKEN=8102620cfe1d55b13fb97eb60f07bcc4e665dbfdb681bc9c98d6ae0539b29456
12
+ - DATABASE_URL=postgres://postgres@postgres/active_record-updated_at
13
+ - DOCKER=true
14
+ - PGTZ=UTC
15
+ - RACK_ENV=test
16
+ - RAILS_ENV=test
17
+ - REBUILD_CACHE
18
+ - TZ=UTC
19
+ links:
20
+ - postgres
21
+ volumes:
22
+ - .:/app
23
+ - $BUILD_CACHE/bundler:/app/vendor/bundle
24
+ - $BUILD_CACHE/tmp:/app/tmp/cache
25
+
26
+ postgres:
27
+ image: lendinghome/postgres:9.4.8
28
+ environment:
29
+ - TZ=UTC
30
+
31
+ rubocop:
32
+ image: lendinghome/rubocop
33
+ environment:
34
+ - RUBOCOP_VERSION=2.3
35
+ volumes:
36
+ - .:/app
@@ -0,0 +1,9 @@
1
+ require "active_record"
2
+ require_relative "active_record/updated_at/model"
3
+ require_relative "active_record/updated_at/relation"
4
+
5
+ module ActiveRecord
6
+ Base.send(:include, UpdatedAt::Model)
7
+ Relation.send(:include, UpdatedAt::Relation)
8
+ Querying.delegate(:update_all_with_updated_at, :update_all_without_updated_at, to: :all)
9
+ end
@@ -0,0 +1,27 @@
1
+ module ActiveRecord
2
+ module UpdatedAt
3
+ module Model
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method :update_columns_without_updated_at, :update_columns
8
+ alias_method :update_columns, :update_columns_with_updated_at
9
+ end
10
+
11
+ def update_column_without_updated_at(attribute, value)
12
+ update_columns_without_updated_at(attribute => value)
13
+ end
14
+
15
+ def update_columns_with_updated_at(attributes)
16
+ attribute_exists = has_attribute?(:updated_at)
17
+ already_specified = attributes.with_indifferent_access.key?(:updated_at)
18
+
19
+ if attribute_exists && !already_specified
20
+ attributes[:updated_at] = Time.current
21
+ end
22
+
23
+ update_columns_without_updated_at(attributes)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ module ActiveRecord
2
+ module UpdatedAt
3
+ module Relation
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method :update_all_without_updated_at, :update_all
8
+ alias_method :update_all, :update_all_with_updated_at
9
+ end
10
+
11
+ def update_all_with_updated_at(query, *args, &block)
12
+ attribute_exists = column_names.include?("updated_at")
13
+ already_specified = Array(query).flatten.grep(/\bupdated_at\b/).any?
14
+ updated_at = Time.current
15
+
16
+ if attribute_exists && !already_specified
17
+ case query
18
+ when Array
19
+ query.first << ", updated_at = ?"
20
+ query << updated_at
21
+ when Hash
22
+ query[:updated_at] = updated_at
23
+ when String
24
+ query = ["#{query}, updated_at = ?", updated_at]
25
+ end
26
+ end
27
+
28
+ update_all_without_updated_at(query, *args, &block)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,108 @@
1
+ RSpec.describe ActiveRecord::UpdatedAt do
2
+ let(:reloaded) { User.find(user.id) }
3
+
4
+ let!(:user) { User.create!(name: "test") }
5
+ let!(:timestamp) { 1.day.ago }
6
+
7
+ describe "#update_all" do
8
+ context "with an array" do
9
+ it "touches updated_at" do
10
+ Timecop.freeze(timestamp) { User.update_all(["name = ?", "changed"]) }
11
+ expect(reloaded.name).to eq("changed")
12
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
13
+ end
14
+
15
+ it "does not touch updated_at if already specified" do
16
+ User.update_all(["name = ?, updated_at = ?", "changed", timestamp])
17
+ expect(reloaded.name).to eq("changed")
18
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
19
+ end
20
+
21
+ it "does not touch updated_at with workaround method" do
22
+ User.update_all_without_updated_at(["name = ?", "changed"])
23
+ expect(reloaded.name).to eq("changed")
24
+ expect(reloaded.updated_at).to eq(user.updated_at)
25
+ end
26
+ end
27
+
28
+ context "with a hash" do
29
+ it "touches updated_at" do
30
+ Timecop.freeze(timestamp) { User.update_all(name: "changed") }
31
+ expect(reloaded.name).to eq("changed")
32
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
33
+ end
34
+
35
+ it "does not touch updated_at if already specified" do
36
+ User.update_all(name: "changed", updated_at: timestamp)
37
+ expect(reloaded.name).to eq("changed")
38
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
39
+ end
40
+
41
+ it "does not touch updated_at with workaround method" do
42
+ User.update_all_without_updated_at(name: "changed")
43
+ expect(reloaded.name).to eq("changed")
44
+ expect(reloaded.updated_at).to eq(user.updated_at)
45
+ end
46
+ end
47
+
48
+ context "with a string" do
49
+ it "touches updated_at" do
50
+ Timecop.freeze(timestamp) { User.update_all("name = 'changed'") }
51
+ expect(reloaded.name).to eq("changed")
52
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
53
+ end
54
+
55
+ it "does not touch updated_at if already specified" do
56
+ formatted_timestamp = timestamp.iso8601(6)
57
+ User.update_all("name = 'changed', updated_at = '#{formatted_timestamp}'")
58
+ expect(reloaded.name).to eq("changed")
59
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
60
+ end
61
+
62
+ it "does not touch updated_at with workaround method" do
63
+ User.update_all_without_updated_at("name = 'changed'")
64
+ expect(reloaded.name).to eq("changed")
65
+ expect(reloaded.updated_at).to eq(user.updated_at)
66
+ end
67
+ end
68
+ end
69
+
70
+ describe "#update_column" do
71
+ it "touches updated_at" do
72
+ Timecop.freeze(timestamp) { user.update_column(:name, "changed") }
73
+ expect(reloaded.name).to eq("changed")
74
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
75
+ end
76
+
77
+ it "does not touch updated_at if already specified" do
78
+ user.update_column(:updated_at, timestamp)
79
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
80
+ end
81
+
82
+ it "does not touch updated_at with workaround method" do
83
+ user.update_column_without_updated_at(:name, "changed")
84
+ expect(reloaded.name).to eq("changed")
85
+ expect(reloaded.updated_at).to eq(user.updated_at)
86
+ end
87
+ end
88
+
89
+ describe "#update_columns" do
90
+ it "touches updated_at" do
91
+ Timecop.freeze(timestamp) { user.update_columns(name: "changed") }
92
+ expect(reloaded.name).to eq("changed")
93
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
94
+ end
95
+
96
+ it "does not touch updated_at if already specified" do
97
+ user.update_columns(name: "changed", updated_at: timestamp)
98
+ expect(reloaded.name).to eq("changed")
99
+ expect(reloaded.updated_at.to_s).to eq(timestamp.to_s)
100
+ end
101
+
102
+ it "does not touch updated_at with workaround method" do
103
+ user.update_columns_without_updated_at(name: "changed")
104
+ expect(reloaded.name).to eq("changed")
105
+ expect(reloaded.updated_at).to eq(user.updated_at)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -0,0 +1,10 @@
1
+ test:
2
+ adapter: postgresql
3
+ <% if ENV["DATABASE_URL"] %>
4
+ url: <%= ENV["DATABASE_URL"] %>
5
+ <% else %>
6
+ database: active_record-updated_at
7
+ encoding: unicode
8
+ pool: 5
9
+ username: <%= ENV.fetch("USER") %>
10
+ <% end %>
@@ -0,0 +1,6 @@
1
+ ActiveRecord::Schema.define(version: 20161012223251) do
2
+ create_table "users", force: :cascade do |t|
3
+ t.string "name", index: true, null: false
4
+ t.timestamps null: false, limit: 6
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ *.log
@@ -0,0 +1,25 @@
1
+ if ENV["CODECLIMATE_REPO_TOKEN"]
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ else
5
+ require "simplecov"
6
+ SimpleCov.start { add_filter("/vendor/bundle/") }
7
+ end
8
+
9
+ require File.expand_path("../../lib/active_record-updated_at", __FILE__)
10
+ ActiveRecord::Migration.verbose = false
11
+
12
+ require "combustion"
13
+ Combustion.initialize!(:active_record)
14
+
15
+ require "rspec/rails"
16
+ RSpec::Expectations.configuration.on_potential_false_positives = :nothing
17
+
18
+ require "timecop"
19
+
20
+ RSpec.configure do |config|
21
+ config.filter_run :focus
22
+ config.raise_errors_for_deprecations!
23
+ config.run_all_when_everything_filtered = true
24
+ config.use_transactional_fixtures = true
25
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_record-updated_at
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - LendingHome
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email: github@lendinghome.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ files:
34
+ - ".buildkite/pipeline.yml"
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".ruby-version"
38
+ - Dockerfile
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE
42
+ - README.md
43
+ - active_record-updated_at.gemspec
44
+ - bin/rubocop
45
+ - bin/test
46
+ - docker-compose.yml
47
+ - lib/active_record-updated_at.rb
48
+ - lib/active_record/updated_at/model.rb
49
+ - lib/active_record/updated_at/relation.rb
50
+ - spec/active_record-updated_at_spec.rb
51
+ - spec/internal/app/models/user.rb
52
+ - spec/internal/config/database.yml
53
+ - spec/internal/db/schema.rb
54
+ - spec/internal/log/.gitignore
55
+ - spec/spec_helper.rb
56
+ homepage: https://github.com/lendinghome/active_record-updated_at
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options:
62
+ - "--charset=UTF-8"
63
+ - "--inline-source"
64
+ - "--line-numbers"
65
+ - "--main"
66
+ - README.md
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.0.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.5.1
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Touch `updated_at` by default with calls to `update_column(s)` and `update_all`
85
+ test_files:
86
+ - spec/active_record-updated_at_spec.rb
87
+ - spec/internal/app/models/user.rb
88
+ - spec/internal/config/database.yml
89
+ - spec/internal/db/schema.rb
90
+ - spec/internal/log/.gitignore
91
+ - spec/spec_helper.rb