date_scopes 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/date_scopes.rb +2 -1
- data/lib/date_scopes/version.rb +1 -1
- data/spec/date_scopes_spec.rb +16 -0
- data/spec/support/test.sqlite3 +0 -0
- metadata +6 -6
data/lib/date_scopes.rb
CHANGED
@@ -39,7 +39,8 @@ module DateScopes
|
|
39
39
|
end
|
40
40
|
|
41
41
|
define_method options[:column].to_s+'=' do |value|
|
42
|
-
value = value.downcase
|
42
|
+
value = %w{true 1}.include? value.downcase if value.is_a? String
|
43
|
+
value = value == 1 if value.is_a? Fixnum
|
43
44
|
|
44
45
|
if value && !self[column_name]
|
45
46
|
|
data/lib/date_scopes/version.rb
CHANGED
data/spec/date_scopes_spec.rb
CHANGED
@@ -59,6 +59,22 @@ describe DateScopes do
|
|
59
59
|
post.should_not be_published
|
60
60
|
end
|
61
61
|
|
62
|
+
it 'copes with integer as string passed to boolean setter' do
|
63
|
+
post = Post.new
|
64
|
+
post.published = '1'
|
65
|
+
post.should be_published
|
66
|
+
post.published = '0'
|
67
|
+
post.should_not be_published
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'copes with integer passed to boolean setter' do
|
71
|
+
post = Post.new
|
72
|
+
post.published = 1
|
73
|
+
post.should be_published
|
74
|
+
post.published = 0
|
75
|
+
post.should_not be_published
|
76
|
+
end
|
77
|
+
|
62
78
|
context 'when published_at is in the past' do
|
63
79
|
before(:all) {@post = Post.create(:published_at => Time.now - 10.minutes)}
|
64
80
|
|
data/spec/support/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_scopes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan Davies
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-01
|
19
|
+
date: 2011-02-01 00:00:00 +00:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements: []
|
149
149
|
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 1.
|
151
|
+
rubygems_version: 1.3.7
|
152
152
|
signing_key:
|
153
153
|
specification_version: 3
|
154
154
|
summary: An ActiveRecord extension for automatic date-based scopes
|