acts_as_interval 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENCE.md +21 -0
- data/README.md +42 -0
- data/Rakefile +5 -21
- data/lib/acts_as_interval/version.rb +1 -1
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/{test → spec}/dummy/app/models/interval.rb +0 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +0 -0
- data/{test → spec}/dummy/bin/rake +0 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/{test → spec}/dummy/config/application.rb +0 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +6 -5
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +0 -0
- data/{test → spec}/dummy/config/initializers/assets.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/{test → spec}/dummy/config/routes.rb +0 -0
- data/{test → spec}/dummy/config/secrets.yml +0 -0
- data/{test → spec}/dummy/db/migrate/20150227133736_create_intervals.rb +0 -0
- data/{test → spec}/dummy/db/schema.rb +0 -0
- data/spec/dummy/log/development.log +28 -0
- data/spec/dummy/log/test.log +1190 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/intervals_spec.rb +22 -0
- data/{test → spec}/dummy/test/fixtures/intervals.yml +0 -0
- data/{test → spec}/dummy/test/models/interval_test.rb +0 -0
- data/spec/factories/intervals.rb +17 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/factory_girl.rb +7 -0
- metadata +139 -87
- data/test/acts_as_interval_test.rb +0 -32
- data/test/test_helper.rb +0 -15
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
describe Interval, type: :model do
|
3
|
+
let!(:interval) { create :interval, starts_at: Date.today, ends_at: 1.week.from_now }
|
4
|
+
let!(:past_intervals) { create_list :interval, 3, :past }
|
5
|
+
let!(:future_intervals) { create_list :interval, 3, :future }
|
6
|
+
let!(:overlapping_intervals) { create_list :interval, 3, :future, starts_at: 3.days.from_now }
|
7
|
+
describe '#past_intervals' do
|
8
|
+
it 'returns past intervals only' do
|
9
|
+
expect(interval.past_intervals).to eq past_intervals
|
10
|
+
end
|
11
|
+
end
|
12
|
+
describe '#future_intervals' do
|
13
|
+
it 'returns future intervals only' do
|
14
|
+
expect(interval.future_intervals).to eq future_intervals
|
15
|
+
end
|
16
|
+
end
|
17
|
+
describe '#overlapping_intervals' do
|
18
|
+
it 'returns overlapping intervals only' do
|
19
|
+
expect(interval.overlapping_intervals).to eq overlapping_intervals
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :interval do
|
3
|
+
starts_at { Faker::Date.backward(30) }
|
4
|
+
ends_at { Faker::Date.forward(30) }
|
5
|
+
|
6
|
+
trait :future do
|
7
|
+
starts_at { Faker::Date.between(2.months.from_now, 4.months.from_now) }
|
8
|
+
ends_at { Faker::Date.between(4.months.from_now, 6.months.from_now) }
|
9
|
+
end
|
10
|
+
|
11
|
+
trait :past do
|
12
|
+
starts_at { Faker::Date.between(4.months.ago, 6.months.ago) }
|
13
|
+
ends_at { Faker::Date.between(2.months.ago, 4.months.ago) }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
3
|
+
require 'rspec/rails'
|
4
|
+
require 'factory_girl_rails'
|
5
|
+
require 'faker'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.mock_with :rspec
|
9
|
+
config.use_transactional_fixtures = true
|
10
|
+
config.infer_base_class_for_anonymous_controllers = false
|
11
|
+
config.order = "random"
|
12
|
+
config.include FactoryGirl::Syntax::Methods
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_interval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohammad AbuShady
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -25,19 +25,61 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: mysql2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: factory_girl_rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faker
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1'
|
41
83
|
description: Description of ActsAsInterval.
|
42
84
|
email:
|
43
85
|
- mohammad@abushady.com
|
@@ -45,51 +87,57 @@ executables: []
|
|
45
87
|
extensions: []
|
46
88
|
extra_rdoc_files: []
|
47
89
|
files:
|
90
|
+
- LICENCE.md
|
91
|
+
- README.md
|
48
92
|
- Rakefile
|
49
93
|
- lib/acts_as_interval.rb
|
50
94
|
- lib/acts_as_interval/acts_as_interval.rb
|
51
95
|
- lib/acts_as_interval/version.rb
|
52
96
|
- lib/tasks/acts_as_interval_tasks.rake
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
- test/
|
97
|
+
- spec/dummy/README.rdoc
|
98
|
+
- spec/dummy/Rakefile
|
99
|
+
- spec/dummy/app/assets/javascripts/application.js
|
100
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
101
|
+
- spec/dummy/app/controllers/application_controller.rb
|
102
|
+
- spec/dummy/app/helpers/application_helper.rb
|
103
|
+
- spec/dummy/app/models/interval.rb
|
104
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
105
|
+
- spec/dummy/bin/bundle
|
106
|
+
- spec/dummy/bin/rails
|
107
|
+
- spec/dummy/bin/rake
|
108
|
+
- spec/dummy/config.ru
|
109
|
+
- spec/dummy/config/application.rb
|
110
|
+
- spec/dummy/config/boot.rb
|
111
|
+
- spec/dummy/config/database.yml
|
112
|
+
- spec/dummy/config/environment.rb
|
113
|
+
- spec/dummy/config/environments/development.rb
|
114
|
+
- spec/dummy/config/environments/production.rb
|
115
|
+
- spec/dummy/config/environments/test.rb
|
116
|
+
- spec/dummy/config/initializers/assets.rb
|
117
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
118
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
119
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
120
|
+
- spec/dummy/config/initializers/inflections.rb
|
121
|
+
- spec/dummy/config/initializers/mime_types.rb
|
122
|
+
- spec/dummy/config/initializers/session_store.rb
|
123
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
124
|
+
- spec/dummy/config/locales/en.yml
|
125
|
+
- spec/dummy/config/routes.rb
|
126
|
+
- spec/dummy/config/secrets.yml
|
127
|
+
- spec/dummy/db/migrate/20150227133736_create_intervals.rb
|
128
|
+
- spec/dummy/db/schema.rb
|
129
|
+
- spec/dummy/log/development.log
|
130
|
+
- spec/dummy/log/test.log
|
131
|
+
- spec/dummy/public/404.html
|
132
|
+
- spec/dummy/public/422.html
|
133
|
+
- spec/dummy/public/500.html
|
134
|
+
- spec/dummy/public/favicon.ico
|
135
|
+
- spec/dummy/spec/intervals_spec.rb
|
136
|
+
- spec/dummy/test/fixtures/intervals.yml
|
137
|
+
- spec/dummy/test/models/interval_test.rb
|
138
|
+
- spec/factories/intervals.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
- spec/support/factory_girl.rb
|
93
141
|
homepage: https://github.com/coalwater/acts_as_interval
|
94
142
|
licenses:
|
95
143
|
- MIT
|
@@ -100,9 +148,9 @@ require_paths:
|
|
100
148
|
- lib
|
101
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
150
|
requirements:
|
103
|
-
- - "
|
151
|
+
- - "~>"
|
104
152
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
153
|
+
version: '2'
|
106
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
155
|
requirements:
|
108
156
|
- - ">="
|
@@ -115,43 +163,47 @@ signing_key:
|
|
115
163
|
specification_version: 4
|
116
164
|
summary: Summary of ActsAsInterval.
|
117
165
|
test_files:
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
-
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
155
|
-
-
|
156
|
-
-
|
157
|
-
-
|
166
|
+
- spec/spec_helper.rb
|
167
|
+
- spec/support/factory_girl.rb
|
168
|
+
- spec/factories/intervals.rb
|
169
|
+
- spec/dummy/Rakefile
|
170
|
+
- spec/dummy/bin/rake
|
171
|
+
- spec/dummy/bin/rails
|
172
|
+
- spec/dummy/bin/bundle
|
173
|
+
- spec/dummy/db/migrate/20150227133736_create_intervals.rb
|
174
|
+
- spec/dummy/db/schema.rb
|
175
|
+
- spec/dummy/spec/intervals_spec.rb
|
176
|
+
- spec/dummy/config/environments/production.rb
|
177
|
+
- spec/dummy/config/environments/test.rb
|
178
|
+
- spec/dummy/config/environments/development.rb
|
179
|
+
- spec/dummy/config/locales/en.yml
|
180
|
+
- spec/dummy/config/boot.rb
|
181
|
+
- spec/dummy/config/routes.rb
|
182
|
+
- spec/dummy/config/environment.rb
|
183
|
+
- spec/dummy/config/database.yml
|
184
|
+
- spec/dummy/config/application.rb
|
185
|
+
- spec/dummy/config/secrets.yml
|
186
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
187
|
+
- spec/dummy/config/initializers/session_store.rb
|
188
|
+
- spec/dummy/config/initializers/mime_types.rb
|
189
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
190
|
+
- spec/dummy/config/initializers/inflections.rb
|
191
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
192
|
+
- spec/dummy/config/initializers/assets.rb
|
193
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
194
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
195
|
+
- spec/dummy/app/assets/javascripts/application.js
|
196
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
197
|
+
- spec/dummy/app/models/interval.rb
|
198
|
+
- spec/dummy/app/controllers/application_controller.rb
|
199
|
+
- spec/dummy/app/helpers/application_helper.rb
|
200
|
+
- spec/dummy/public/422.html
|
201
|
+
- spec/dummy/public/404.html
|
202
|
+
- spec/dummy/public/favicon.ico
|
203
|
+
- spec/dummy/public/500.html
|
204
|
+
- spec/dummy/config.ru
|
205
|
+
- spec/dummy/test/fixtures/intervals.yml
|
206
|
+
- spec/dummy/test/models/interval_test.rb
|
207
|
+
- spec/dummy/README.rdoc
|
208
|
+
- spec/dummy/log/test.log
|
209
|
+
- spec/dummy/log/development.log
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ActsAsIntervalTest < ActiveSupport::TestCase
|
4
|
-
def test_future_interval_method
|
5
|
-
interval = Interval.new
|
6
|
-
assert_equal true, interval.respond_to?(:future_intervals)
|
7
|
-
end
|
8
|
-
def test_past_interval_method
|
9
|
-
interval = Interval.new
|
10
|
-
assert_equal true, interval.respond_to?(:past_intervals)
|
11
|
-
end
|
12
|
-
def test_overlapping_interval_method
|
13
|
-
interval = Interval.new
|
14
|
-
assert_equal true, interval.respond_to?(:overlapping_intervals)
|
15
|
-
end
|
16
|
-
def test_intervals_before
|
17
|
-
old_interval = Interval.create(starts_at: 1.month.ago, ends_at: 1.week.ago)
|
18
|
-
older_interval = Interval.create(starts_at: 2.year.ago, ends_at: 1.year.ago)
|
19
|
-
Interval.create(starts_at: 1.month.since, ends_at: 1.year.since)
|
20
|
-
Interval.create(starts_at: 1.years.ago, ends_at: 1.years.since)
|
21
|
-
new_interval = Interval.create(starts_at: 1.day.ago, ends_at: 1.hour.ago)
|
22
|
-
assert_equal new_interval.past_intervals, [old_interval, older_interval]
|
23
|
-
end
|
24
|
-
def test_intervals_after
|
25
|
-
Interval.create(starts_at: 1.month.ago, ends_at: 1.week.ago)
|
26
|
-
Interval.create(starts_at: 2.year.ago, ends_at: 1.year.ago)
|
27
|
-
after_interval = Interval.create(starts_at: 1.month.since, ends_at: 1.year.since)
|
28
|
-
Interval.create(starts_at: 1.years.ago, ends_at: 1.years.since)
|
29
|
-
new_interval = Interval.create(starts_at: 1.day.ago, ends_at: 1.hour.ago)
|
30
|
-
assert_equal new_interval.future_intervals, [after_interval]
|
31
|
-
end
|
32
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
-
require "rails/test_help"
|
6
|
-
|
7
|
-
Rails.backtrace_cleaner.remove_silencers!
|
8
|
-
|
9
|
-
# Load support files
|
10
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
-
|
12
|
-
# Load fixtures from the engine
|
13
|
-
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
-
end
|