first_after_created_at 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class HasTimestampTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -1,7 +1,40 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class FirstAfterCreatedAtTest < ActiveSupport::TestCase
4
- test "truth" do
5
- assert_kind_of Module, FirstAfterCreatedAt
4
+ test 'returns nil if no object exists' do
5
+ assert_nil HasTimestamp.first_after_created_at(Time.now)
6
+ end
7
+
8
+ test 'returns nil if no object meets criteria' do
9
+ HasTimestamp.create
10
+ assert_nil HasTimestamp.first_after_created_at(1.hour.from_now)
11
+ end
12
+
13
+ test 'can return the first object' do
14
+ obj = HasTimestamp.create
15
+ HasTimestamp.create
16
+ assert_equal obj, HasTimestamp.first_after_created_at(1.hour.ago)
17
+ end
18
+
19
+ test "will ignore first object if it's out of scope" do
20
+ HasTimestamp.create
21
+ obj = HasTimestamp.create(created_at: 2.hours.from_now)
22
+
23
+ assert_equal obj, HasTimestamp.first_after_created_at(1.hour.from_now)
24
+ end
25
+
26
+ test 'given two objects with same created at, returns one with min id' do
27
+ obj = HasTimestamp.create
28
+ HasTimestamp.create(created_at: obj.created_at)
29
+
30
+ assert_equal obj, HasTimestamp.first_after_created_at(1.hour.ago)
31
+ end
32
+
33
+ test 'can return the middle object' do
34
+ objs = Array.new(3) do |n|
35
+ HasTimestamp.create(created_at: n.hours.from_now)
36
+ end
37
+ middle = objs[1]
38
+ assert_equal middle, HasTimestamp.first_after_created_at(middle.created_at)
6
39
  end
7
40
  end
data/test/test_helper.rb CHANGED
@@ -3,6 +3,9 @@ ENV["RAILS_ENV"] = "test"
3
3
 
4
4
  require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
5
  ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
6
+ ActiveRecord::Migrator.up File.expand_path("../../test/dummy/db/migrate", __FILE__)
7
+ ActiveRecord::Migration.maintain_test_schema!
8
+
6
9
  require "rails/test_help"
7
10
 
8
11
  # Filter out Minitest backtrace while allowing backtrace from other libraries
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: first_after_created_at
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Glass
8
+ - quelledanielle
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-07-22 00:00:00.000000000 Z
12
+ date: 2017-08-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activerecord
@@ -38,6 +39,20 @@ dependencies:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rails
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 4.2.9
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 4.2.9
41
56
  description: adds a first_by_created_at class method to active record models that
42
57
  search by binary search through auto-ascending primary key ids
43
58
  email:
@@ -47,16 +62,17 @@ extensions: []
47
62
  extra_rdoc_files: []
48
63
  files:
49
64
  - MIT-LICENSE
50
- - README.rdoc
51
65
  - Rakefile
52
66
  - lib/first_after_created_at.rb
53
67
  - lib/first_after_created_at/version.rb
68
+ - lib/tasks/first_after_created_at_tasks.rake
54
69
  - test/dummy/README.rdoc
55
70
  - test/dummy/Rakefile
56
71
  - test/dummy/app/assets/javascripts/application.js
57
72
  - test/dummy/app/assets/stylesheets/application.css
58
73
  - test/dummy/app/controllers/application_controller.rb
59
74
  - test/dummy/app/helpers/application_helper.rb
75
+ - test/dummy/app/models/has_timestamp.rb
60
76
  - test/dummy/app/views/layouts/application.html.erb
61
77
  - test/dummy/bin/bundle
62
78
  - test/dummy/bin/rails
@@ -82,10 +98,17 @@ files:
82
98
  - test/dummy/config/locales/en.yml
83
99
  - test/dummy/config/routes.rb
84
100
  - test/dummy/config/secrets.yml
101
+ - test/dummy/db/migrate/20170802143942_create_has_timestamps.rb
102
+ - test/dummy/db/schema.rb
103
+ - test/dummy/db/test.sqlite3
104
+ - test/dummy/log/development.log
105
+ - test/dummy/log/test.log
85
106
  - test/dummy/public/404.html
86
107
  - test/dummy/public/422.html
87
108
  - test/dummy/public/500.html
88
109
  - test/dummy/public/favicon.ico
110
+ - test/dummy/test/fixtures/has_timestamps.yml
111
+ - test/dummy/test/models/has_timestamp_test.rb
89
112
  - test/first_after_created_at_test.rb
90
113
  - test/test_helper.rb
91
114
  homepage: https://github.com/NoRedInk/first_after_created_at
@@ -118,6 +141,7 @@ test_files:
118
141
  - test/dummy/app/assets/stylesheets/application.css
119
142
  - test/dummy/app/controllers/application_controller.rb
120
143
  - test/dummy/app/helpers/application_helper.rb
144
+ - test/dummy/app/models/has_timestamp.rb
121
145
  - test/dummy/app/views/layouts/application.html.erb
122
146
  - test/dummy/bin/bundle
123
147
  - test/dummy/bin/rails
@@ -143,11 +167,18 @@ test_files:
143
167
  - test/dummy/config/routes.rb
144
168
  - test/dummy/config/secrets.yml
145
169
  - test/dummy/config.ru
170
+ - test/dummy/db/migrate/20170802143942_create_has_timestamps.rb
171
+ - test/dummy/db/schema.rb
172
+ - test/dummy/db/test.sqlite3
173
+ - test/dummy/log/development.log
174
+ - test/dummy/log/test.log
146
175
  - test/dummy/public/404.html
147
176
  - test/dummy/public/422.html
148
177
  - test/dummy/public/500.html
149
178
  - test/dummy/public/favicon.ico
150
179
  - test/dummy/Rakefile
151
180
  - test/dummy/README.rdoc
181
+ - test/dummy/test/fixtures/has_timestamps.yml
182
+ - test/dummy/test/models/has_timestamp_test.rb
152
183
  - test/first_after_created_at_test.rb
153
184
  - test/test_helper.rb
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = FirstAfterCreatedAt
2
-
3
- This project rocks and uses MIT-LICENSE.