include_date_scopes 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0f891fa15dbec344fb06873f3a5642f41a5bd03
4
- data.tar.gz: 31ab327e5716822e217f2ad00d009d284da1fd9d
3
+ metadata.gz: cee42ed898449ecf0d0043d481554367f1f336cf
4
+ data.tar.gz: 9d9fcc175ec25d960018d25f3418a444bda5b8af
5
5
  SHA512:
6
- metadata.gz: f6dd984249e0aaa39f190487989c6ae63d0a4ac9a06d365507fe7428fa1b54546476e2c0a21becbde6fb2a053f25b81754fbee7657538b978f332ba4cbfb0b6b
7
- data.tar.gz: ccc4476d4f40a75005b0ca3b67f711eceab8c694e03b559ddeb1ca6e4c8e2f3085447c3b832a3b5b4c46eab8aebb9109613d5ba1c50d7cb87c010a681e118170
6
+ metadata.gz: 253e111483d596a0527aec9622fa935adb190e20f06c8a20decb4bcafe67e45190863ac3b052e31d8921f3ac1f0bd94e3d50757516f8b6a54e6415e8392f0b80
7
+ data.tar.gz: 2968b9a43364d6bba30018bff43cb43178e8a40149af7176308d627ab11580e0ffba36772bb2b9779a650dda3e76ade1326ae3e78ec7b8c146d0b454517afec1
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ 0.9.1
2
+ -----
3
+ Removed the Squeel dependency
4
+
5
+ 0.9.0
6
+ -----
7
+ Initial working version
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,10 @@
1
+ Contributing to include_date_scopes:
2
+
3
+ 1. Fork the [official repository](https://github.com/descentintomael/include_date_scopes/tree/master).
4
+ 2. Make your changes in a topic branch.
5
+ 3. Send a pull request.
6
+
7
+ Notes:
8
+
9
+ * Contributions without tests won't be accepted.
10
+ * Please don't update the Gem version.
data/Gemfile.lock CHANGED
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- include_date_scopes (0.0.0)
4
+ include_date_scopes (0.9.0)
5
5
  activerecord (< 4)
6
6
  railties
7
- squeel
8
7
 
9
8
  GEM
10
9
  remote: http://rubygems.org/
@@ -59,8 +58,6 @@ GEM
59
58
  json (1.8.1)
60
59
  method_source (0.8.2)
61
60
  multi_json (1.9.2)
62
- polyamorous (0.6.4)
63
- activerecord (>= 3.0)
64
61
  pry (0.9.12.6)
65
62
  coderay (~> 1.0)
66
63
  method_source (~> 0.8)
@@ -111,10 +108,6 @@ GEM
111
108
  rack (~> 1.0)
112
109
  tilt (~> 1.1, != 1.3.0)
113
110
  sqlite3 (1.3.9)
114
- squeel (1.1.1)
115
- activerecord (>= 3.0)
116
- activesupport (>= 3.0)
117
- polyamorous (~> 0.6.0)
118
111
  thin (1.6.2)
119
112
  daemons (>= 1.0.9)
120
113
  eventmachine (>= 1.0.0)
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Sean Todd
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,31 @@
1
1
  include_date_scopes
2
2
  ===================
3
3
 
4
- Module for mixing in date related scopes to ActiveRecord models
4
+ An ActiveRecord module for automatically including a large list of commonly used date related scopes.
5
+
6
+ Usage
7
+ -----
8
+
9
+ To use in a model on the standard `created_at` column, put the `include_date_scopes` call in your class:
10
+ ```ruby
11
+ class Post < ActiveRecord::Base
12
+ include_date_scopes
13
+ end
14
+ ```
15
+ Now you can call scopes like `Post.after(1.week.ago)` or `Post.yesterday`.
16
+
17
+ If you wish to use this on another column, use `include_dates_scopes_for`:
18
+ ```ruby
19
+ class Post < ActiveRecord::Base
20
+ include_date_scopes_for :show_at
21
+ end
22
+ ```
23
+ Now all of the provided scopes will work with the `show_at` column.
24
+
25
+ If you want to include multiple sets of date scopes, you can use named date scopes:
26
+ ```ruby
27
+ class Post < ActiveRecord::Base
28
+ include_named_date_scopes_for :updated_at
29
+ end
30
+ ```
31
+ Now the scopes will all be prepended with `updated_at_`. So `Post.yesterday` would become `Post.updated_at_yesterday`.
@@ -19,7 +19,6 @@ DESCRIPTION
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "squeel"
23
22
  s.add_dependency "activerecord", '< 4'
24
23
  s.add_dependency "railties"
25
24
  s.add_development_dependency "rspec-rails"
@@ -21,7 +21,6 @@
21
21
  # include_date_scopes_for :net_payment_settlement_date, true # prepend field name -- ex: Payment.net_payment_settlement_date_on(date)
22
22
  #
23
23
  #
24
- require 'squeel'
25
24
 
26
25
  module IncludeDateScopes
27
26
  module DateScopes
@@ -48,35 +47,36 @@ module IncludeDateScopes
48
47
 
49
48
  def define_timestamp_scopes_for(column_name, prepend_name = false)
50
49
  prefix = prepend_name ? "#{column_name}_" : ""
50
+ t = self.arel_table
51
51
 
52
52
  define_singleton_method :"#{prefix}between" do |start_date_or_time, stop_date_or_time|
53
53
  start_time = (start_date_or_time.is_a?(Date) ? start_date_or_time.to_time : start_date_or_time)
54
54
  stop_time = (stop_date_or_time.is_a?(Date) ? stop_date_or_time.to_time + 1.day : stop_date_or_time )
55
- where{(__send__(column_name).gte start_time) & (__send__(column_name).lt stop_time)}
55
+ where(t[column_name].gteq(start_time).and(t[column_name].lt stop_time))
56
56
  end
57
57
 
58
58
  define_singleton_method :"#{prefix}on_or_before_date" do |date|
59
- where{ __send__(column_name).lt date.to_date.tomorrow.midnight.gmtime }
59
+ where( t[column_name].lt date.to_date.tomorrow.midnight.gmtime )
60
60
  end
61
61
 
62
62
  define_singleton_method :"#{prefix}on_or_before" do |time|
63
- where{__send__(column_name).lte (time.is_a?(Date) ? time.to_time : time)}
63
+ where(t[column_name].lte (time.is_a?(Date) ? time.to_time : time))
64
64
  end
65
65
 
66
66
  define_singleton_method :"#{prefix}before" do |time|
67
- where{__send__(column_name).lt (time.is_a?(Date) ? time.to_time : time)}
67
+ where(t[column_name].lt (time.is_a?(Date) ? time.to_time : time))
68
68
  end
69
69
 
70
70
  define_singleton_method :"#{prefix}on_or_after_date" do |time|
71
- where{__send__(column_name).gte time.to_date.midnight.gmtime }
71
+ where(t[column_name].gteq time.to_date.midnight.gmtime )
72
72
  end
73
73
 
74
74
  define_singleton_method :"#{prefix}on_or_after" do |time|
75
- where{__send__(column_name).gte (time.is_a?(Date) ? time.to_time + 1.day : time )}
75
+ where(t[column_name].gteq (time.is_a?(Date) ? time.to_time + 1.day : time ))
76
76
  end
77
77
 
78
78
  define_singleton_method :"#{prefix}after" do |time|
79
- where{__send__(column_name).gt (time.is_a?(Date) ? time.to_time + 1.day : time )}
79
+ where(t[column_name].gt (time.is_a?(Date) ? time.to_time + 1.day : time ))
80
80
  end
81
81
 
82
82
  define_singleton_method :"#{prefix}on" do |day|
@@ -129,27 +129,27 @@ module IncludeDateScopes
129
129
  prefix = prepend_name ? "#{column_name}_" : ""
130
130
 
131
131
  define_singleton_method :"#{prefix}between" do |start_date, stop_date|
132
- where{(__send__(column_name).gte start_date) & (__send__(column_name).lte stop_date)}
132
+ where(t[column_name].gteq(start_date).and(t[column_name].lte stop_date))
133
133
  end
134
134
 
135
135
  define_singleton_method :"#{prefix}on_or_before" do |date|
136
- where{ __send__(column_name).lte date }
136
+ where( t[column_name].lte date )
137
137
  end
138
138
 
139
139
  define_singleton_method :"#{prefix}before" do |date|
140
- where{__send__(column_name).lt date}
140
+ where(t[column_name].lt date)
141
141
  end
142
142
 
143
143
  define_singleton_method :"#{prefix}on_or_after" do |date|
144
- where{__send__(column_name).gte date}
144
+ where(t[column_name].gteq date)
145
145
  end
146
146
 
147
147
  define_singleton_method :"#{prefix}after" do |date|
148
- where{__send__(column_name).gt date}
148
+ where(t[column_name].gt date)
149
149
  end
150
150
 
151
151
  define_singleton_method :"#{prefix}on" do |date|
152
- where{__send__(column_name).eq date}
152
+ where(t[column_name].eq date)
153
153
  end
154
154
 
155
155
  define_singleton_method :"#{prefix}day" do |day|
@@ -1,4 +1,4 @@
1
1
 
2
2
  module IncludeDateScopes
3
- VERSION = '0.9.0'.freeze
3
+ VERSION = '0.9.1'.freeze
4
4
  end
@@ -20,4 +20,192 @@ describe "Post" do
20
20
 
21
21
  it_behaves_like "with basic date scopes", :updated_at
22
22
  end
23
+
24
+ describe 'date scopes with name prepended' do
25
+ before(:all) do
26
+ define_model_class do
27
+ include_named_date_scopes_for :show_at
28
+ end
29
+ end
30
+
31
+ before(:all) { Timecop.freeze Time.local(2013,02,15,06,30) }
32
+
33
+ let!(:last_month_obj) { Post.create! :show_at => 1.month.ago }
34
+ let!(:last_week_obj) { Post.create! :show_at => 1.week.ago }
35
+ let!(:yesterday_obj) { Post.create! :show_at => 24.hours.ago }
36
+ let!(:hour_ago_obj) { Post.create! :show_at => 1.hour.ago }
37
+ let!(:five_minute_ago_obj) { Post.create! :show_at => 5.minutes.ago }
38
+ let!(:after_midnight_ago_obj) { Post.create! :show_at => Date.today.midnight + 5.minutes }
39
+ let!(:before_midnight_ago_obj) { Post.create! :show_at => Date.today.midnight - 5.minutes }
40
+
41
+ describe ":between" do
42
+ context "with DateTime" do
43
+ subject { Post.show_at_between(2.hours.ago, 1.minute.ago) }
44
+
45
+ it { should_not include last_week_obj }
46
+ it { should_not include yesterday_obj }
47
+ it { should include hour_ago_obj }
48
+ it { should include five_minute_ago_obj }
49
+ end
50
+ context "with Date" do
51
+ subject { Post.show_at_between(2.days.ago.to_date, Date.today) }
52
+
53
+ it { should_not include last_week_obj }
54
+ it { should include yesterday_obj }
55
+ it { should include hour_ago_obj }
56
+ it { should include five_minute_ago_obj }
57
+ end
58
+ end
59
+
60
+ describe ":after" do
61
+ context "with DateTime" do
62
+ subject { Post.show_at_after(2.hours.ago) }
63
+
64
+ it { should_not include last_week_obj }
65
+ it { should_not include yesterday_obj }
66
+ it { should include hour_ago_obj }
67
+ it { should include five_minute_ago_obj }
68
+ end
69
+ context "with Date" do
70
+ subject { Post.show_at_after(2.days.ago.to_date) }
71
+
72
+ it { should_not include last_week_obj }
73
+ it { should include yesterday_obj }
74
+ it { should include hour_ago_obj }
75
+ it { should include five_minute_ago_obj }
76
+ end
77
+ end
78
+
79
+ describe ":on_or_after_date" do
80
+ context "with DateTime" do
81
+ subject { Post.show_at_on_or_after_date(2.hours.ago) }
82
+
83
+ it { should_not include last_week_obj }
84
+ it { should_not include yesterday_obj }
85
+ it { should include hour_ago_obj }
86
+ it { should include five_minute_ago_obj }
87
+ end
88
+ context "with Date" do
89
+ subject { Post.show_at_on_or_after_date(2.days.ago.to_date) }
90
+
91
+ it { should_not include last_week_obj }
92
+ it { should include yesterday_obj }
93
+ it { should include hour_ago_obj }
94
+ it { should include five_minute_ago_obj }
95
+ end
96
+ end
97
+
98
+ describe ":before" do
99
+ context "with DateTime" do
100
+ subject { Post.show_at_before(2.hours.ago) }
101
+
102
+ it { should include last_week_obj }
103
+ it { should include yesterday_obj }
104
+ it { should_not include hour_ago_obj }
105
+ it { should_not include five_minute_ago_obj }
106
+ end
107
+ context "with Date" do
108
+ subject { Post.show_at_before(Date.today) }
109
+
110
+ it { should include last_week_obj }
111
+ it { should include yesterday_obj }
112
+ it { should_not include hour_ago_obj }
113
+ it { should_not include five_minute_ago_obj }
114
+ end
115
+ end
116
+
117
+ describe ":on_or_before_date" do
118
+ context "with DateTime" do
119
+ subject { Post.show_at_on_or_before_date(25.hours.ago) }
120
+
121
+ it { should include last_week_obj }
122
+ it { should include yesterday_obj }
123
+ it { should_not include hour_ago_obj }
124
+ it { should_not include five_minute_ago_obj }
125
+ end
126
+ context "with Date" do
127
+ subject { Post.show_at_on_or_before_date(Date.yesterday) }
128
+
129
+ it { should include last_week_obj }
130
+ it { should include yesterday_obj }
131
+ it { should_not include hour_ago_obj }
132
+ it { should_not include five_minute_ago_obj }
133
+ end
134
+ end
135
+
136
+ describe ":today" do
137
+ subject { Post.show_at_today }
138
+
139
+ it { should_not include last_week_obj }
140
+ it { should_not include yesterday_obj }
141
+ it { should include hour_ago_obj }
142
+ it { should include five_minute_ago_obj }
143
+ end
144
+
145
+ describe ":yesterday" do
146
+ subject { Post.show_at_yesterday }
147
+
148
+ it { should_not include last_week_obj }
149
+ it { should include yesterday_obj }
150
+ it { should_not include hour_ago_obj }
151
+ it { should_not include five_minute_ago_obj }
152
+ end
153
+
154
+ describe ":last_24_hours" do
155
+ subject { Post.show_at_last_24_hours }
156
+
157
+ it { should_not include last_week_obj }
158
+ it { should_not include yesterday_obj }
159
+ it { should include hour_ago_obj }
160
+ it { should include five_minute_ago_obj }
161
+ end
162
+
163
+ describe ":last_hour" do
164
+ subject { Post.show_at_last_hour }
165
+
166
+ it { should_not include last_week_obj }
167
+ it { should_not include yesterday_obj }
168
+ it { should_not include hour_ago_obj } # should not because this is exclusive
169
+ it { should include five_minute_ago_obj }
170
+ end
171
+
172
+ describe ":last_week" do
173
+ subject { Post.show_at_last_week }
174
+
175
+ it { should_not include last_week_obj }
176
+ it { should include yesterday_obj }
177
+ it { should include hour_ago_obj }
178
+ it { should include five_minute_ago_obj }
179
+ end
180
+
181
+ describe ":last_30_days" do
182
+ subject { Post.show_at_last_30days }
183
+
184
+ it { should_not include last_month_obj }
185
+ it { should include last_week_obj }
186
+ it { should include yesterday_obj }
187
+ it { should include hour_ago_obj }
188
+ it { should include five_minute_ago_obj }
189
+ end
190
+
191
+ describe ":this_week" do
192
+ subject { Post.show_at_this_week }
193
+
194
+ it { should_not include last_week_obj }
195
+ it { should include yesterday_obj }
196
+ it { should include hour_ago_obj }
197
+ it { should include five_minute_ago_obj }
198
+ it { should include before_midnight_ago_obj }
199
+ end
200
+
201
+ describe ":this_month" do
202
+ subject { Post.show_at_this_month }
203
+
204
+ it { should_not include last_month_obj }
205
+ it { should include last_week_obj }
206
+ it { should include yesterday_obj }
207
+ it { should include hour_ago_obj }
208
+ it { should include five_minute_ago_obj }
209
+ end
210
+ end
23
211
  end
@@ -2,8 +2,9 @@
2
2
  shared_examples "with basic date scopes" do |date_column = :created_at |
3
3
  let!(:test_class) { Post }
4
4
  describe "date scopes" do
5
- before(:each) { Timecop.freeze Time.local(2013,02,01,06,30) }
5
+ before(:all) { Timecop.freeze Time.local(2013,02,15,06,30) }
6
6
 
7
+ let!(:last_month_obj) { test_class.create! date_column.to_sym => 1.month.ago }
7
8
  let!(:last_week_obj) { test_class.create! date_column.to_sym => 1.week.ago }
8
9
  let!(:yesterday_obj) { test_class.create! date_column.to_sym => 24.hours.ago }
9
10
  let!(:hour_ago_obj) { test_class.create! date_column.to_sym => 1.hour.ago }
@@ -13,7 +14,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
13
14
 
14
15
  describe ":between" do
15
16
  context "with DateTime" do
16
- subject {test_class.between(2.hours.ago, 1.minute.ago).all}
17
+ subject { test_class.between(2.hours.ago, 1.minute.ago) }
17
18
 
18
19
  it { should_not include last_week_obj }
19
20
  it { should_not include yesterday_obj }
@@ -21,7 +22,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
21
22
  it { should include five_minute_ago_obj }
22
23
  end
23
24
  context "with Date" do
24
- subject {test_class.between(2.days.ago.to_date, Date.today).all}
25
+ subject { test_class.between(2.days.ago.to_date, Date.today) }
25
26
 
26
27
  it { should_not include last_week_obj }
27
28
  it { should include yesterday_obj }
@@ -32,7 +33,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
32
33
 
33
34
  describe ":after" do
34
35
  context "with DateTime" do
35
- subject {test_class.after(2.hours.ago).all}
36
+ subject { test_class.after(2.hours.ago) }
36
37
 
37
38
  it { should_not include last_week_obj }
38
39
  it { should_not include yesterday_obj }
@@ -40,7 +41,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
40
41
  it { should include five_minute_ago_obj }
41
42
  end
42
43
  context "with Date" do
43
- subject {test_class.after(2.days.ago.to_date).all}
44
+ subject { test_class.after(2.days.ago.to_date) }
44
45
 
45
46
  it { should_not include last_week_obj }
46
47
  it { should include yesterday_obj }
@@ -51,7 +52,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
51
52
 
52
53
  describe ":on_or_after_date" do
53
54
  context "with DateTime" do
54
- subject {test_class.on_or_after_date(2.hours.ago).all}
55
+ subject { test_class.on_or_after_date(2.hours.ago) }
55
56
 
56
57
  it { should_not include last_week_obj }
57
58
  it { should_not include yesterday_obj }
@@ -59,7 +60,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
59
60
  it { should include five_minute_ago_obj }
60
61
  end
61
62
  context "with Date" do
62
- subject {test_class.on_or_after_date(2.days.ago.to_date).all}
63
+ subject { test_class.on_or_after_date(2.days.ago.to_date) }
63
64
 
64
65
  it { should_not include last_week_obj }
65
66
  it { should include yesterday_obj }
@@ -70,7 +71,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
70
71
 
71
72
  describe ":before" do
72
73
  context "with DateTime" do
73
- subject {test_class.before(2.hours.ago).all}
74
+ subject { test_class.before(2.hours.ago) }
74
75
 
75
76
  it { should include last_week_obj }
76
77
  it { should include yesterday_obj }
@@ -78,7 +79,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
78
79
  it { should_not include five_minute_ago_obj }
79
80
  end
80
81
  context "with Date" do
81
- subject {test_class.before(Date.today).all}
82
+ subject { test_class.before(Date.today) }
82
83
 
83
84
  it { should include last_week_obj }
84
85
  it { should include yesterday_obj }
@@ -89,7 +90,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
89
90
 
90
91
  describe ":on_or_before_date" do
91
92
  context "with DateTime" do
92
- subject {test_class.on_or_before_date(25.hours.ago).all}
93
+ subject { test_class.on_or_before_date(25.hours.ago) }
93
94
 
94
95
  it { should include last_week_obj }
95
96
  it { should include yesterday_obj }
@@ -97,7 +98,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
97
98
  it { should_not include five_minute_ago_obj }
98
99
  end
99
100
  context "with Date" do
100
- subject {test_class.on_or_before_date(Date.yesterday).all}
101
+ subject { test_class.on_or_before_date(Date.yesterday) }
101
102
 
102
103
  it { should include last_week_obj }
103
104
  it { should include yesterday_obj }
@@ -107,7 +108,7 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
107
108
  end
108
109
 
109
110
  describe ":today" do
110
- subject {test_class.today.all}
111
+ subject { test_class.today }
111
112
 
112
113
  it { should_not include last_week_obj }
113
114
  it { should_not include yesterday_obj }
@@ -116,13 +117,70 @@ shared_examples "with basic date scopes" do |date_column = :created_at |
116
117
  end
117
118
 
118
119
  describe ":yesterday" do
119
- subject {test_class.yesterday.all}
120
+ subject { test_class.yesterday }
120
121
 
121
122
  it { should_not include last_week_obj }
122
123
  it { should include yesterday_obj }
123
124
  it { should_not include hour_ago_obj }
124
125
  it { should_not include five_minute_ago_obj }
125
126
  end
127
+
128
+ describe ":last_24_hours" do
129
+ subject { test_class.last_24_hours }
130
+
131
+ it { should_not include last_week_obj }
132
+ it { should_not include yesterday_obj }
133
+ it { should include hour_ago_obj }
134
+ it { should include five_minute_ago_obj }
135
+ end
136
+
137
+ describe ":last_hour" do
138
+ subject { test_class.last_hour }
139
+
140
+ it { should_not include last_week_obj }
141
+ it { should_not include yesterday_obj }
142
+ it { should_not include hour_ago_obj } # should not because this is exclusive
143
+ it { should include five_minute_ago_obj }
144
+ end
145
+
146
+ describe ":last_week" do
147
+ subject { test_class.last_week }
148
+
149
+ it { should_not include last_week_obj }
150
+ it { should include yesterday_obj }
151
+ it { should include hour_ago_obj }
152
+ it { should include five_minute_ago_obj }
153
+ end
154
+
155
+ describe ":last_30_days" do
156
+ subject { test_class.last_30days }
157
+
158
+ it { should_not include last_month_obj }
159
+ it { should include last_week_obj }
160
+ it { should include yesterday_obj }
161
+ it { should include hour_ago_obj }
162
+ it { should include five_minute_ago_obj }
163
+ end
164
+
165
+ describe ":this_week" do
166
+ subject { test_class.this_week }
167
+
168
+ it { should_not include last_week_obj }
169
+ it { should include yesterday_obj }
170
+ it { should include hour_ago_obj }
171
+ it { should include five_minute_ago_obj }
172
+ it { should include before_midnight_ago_obj }
173
+ end
174
+
175
+ describe ":this_month" do
176
+ subject { test_class.this_month }
177
+
178
+ it { should_not include last_month_obj }
179
+ it { should include last_week_obj }
180
+ it { should include yesterday_obj }
181
+ it { should include hour_ago_obj }
182
+ it { should include five_minute_ago_obj }
183
+ end
126
184
  end
127
185
  end
128
186
 
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: include_date_scopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Todd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: squeel
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: activerecord
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -106,8 +92,11 @@ files:
106
92
  - ".gitignore"
107
93
  - ".ruby-gemset"
108
94
  - ".ruby-version"
95
+ - CHANGELOG.md
96
+ - CONTRIBUTING.md
109
97
  - Gemfile
110
98
  - Gemfile.lock
99
+ - LICENSE
111
100
  - README.md
112
101
  - include_date_scopes.gemspec
113
102
  - lib/include_date_scopes.rb