first_after_created_at 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/first_after_created_at/version.rb +1 -1
- metadata +23 -75
- data/.travis.yml +0 -8
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -166
- data/Rakefile +0 -50
- data/TODO +0 -0
- data/VERSION +0 -1
- data/first_after_created_at.gemspec +0 -111
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/has_timestamp.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -29
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -22
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -11
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20170802143942_create_has_timestamps.rb +0 -8
- data/test/dummy/db/schema.rb +0 -20
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/has_timestamps.yml +0 -11
- data/test/dummy/test/models/has_timestamp_test.rb +0 -7
- data/test/first_after_created_at_test.rb +0 -46
- data/test/test_helper.rb +0 -23
File without changes
|
@@ -1,11 +0,0 @@
|
|
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
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class FirstAfterCreatedAtTest < ActiveSupport::TestCase
|
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)
|
39
|
-
end
|
40
|
-
|
41
|
-
test 'can join to another table' do
|
42
|
-
obj = HasTimestamp.create
|
43
|
-
found_with_join = HasTimestamp.joins('INNER JOIN has_timestamps h ON h.id = has_timestamps.id').first_after_created_at(obj.created_at)
|
44
|
-
assert_equal obj, found_with_join
|
45
|
-
end
|
46
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require_relative "../test/dummy/config/environment"
|
5
|
-
|
6
|
-
require "rails/test_help"
|
7
|
-
ActiveRecord::MigrationContext.new(File.expand_path("../test/dummy/db/migrate", __dir__)).migrate
|
8
|
-
|
9
|
-
# Filter out the backtrace from minitest while preserving the one from other libraries.
|
10
|
-
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
11
|
-
|
12
|
-
require "rails/test_unit/reporter"
|
13
|
-
|
14
|
-
Rails::TestUnitReporter.executable = 'bin/test'
|
15
|
-
|
16
|
-
|
17
|
-
# Load fixtures from the engine
|
18
|
-
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
19
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
|
20
|
-
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
21
|
-
ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
|
22
|
-
ActiveSupport::TestCase.fixtures :all
|
23
|
-
end
|