dm-timestamps 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 0.9.9 / 2009-01-04
2
+
3
+ * 1 bug fix:
4
+
5
+ * Updated auto_validation to false for timestamps
6
+
1
7
  === 0.9.8 / 2008-12-07
2
8
 
3
9
  * 2 minor enhancements:
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
 
3
- gem 'dm-core', '~>0.9.8'
3
+ gem 'dm-core', '~>0.9.9'
4
4
  require 'dm-core'
5
5
 
6
6
  module DataMapper
@@ -39,7 +39,7 @@ module DataMapper
39
39
  case name
40
40
  when *TIMESTAMP_PROPERTIES.keys
41
41
  type = TIMESTAMP_PROPERTIES[name].first
42
- property name, type, :nullable => false
42
+ property name, type, :nullable => false, :auto_validation => false
43
43
  when :at
44
44
  timestamps(:created_at, :updated_at)
45
45
  when :on
@@ -53,4 +53,6 @@ module DataMapper
53
53
 
54
54
  class InvalidTimestampName < RuntimeError; end
55
55
  end # module Timestamp
56
+ # include Timestamp or Timestamps, it still works
57
+ Timestamps = Timestamp
56
58
  end # module DataMapper
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Timestamps
3
- VERSION = '0.9.8'
3
+ VERSION = '0.9.9'
4
4
  end
5
5
  end
@@ -1,92 +1,90 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
3
3
 
4
+ # run the specs with dm-validations, if available
5
+ begin
6
+ gem 'dm-validations', '~>0.9.9'
7
+ require 'dm-validations'
8
+ rescue LoadError
9
+ # do nothing
10
+ end
11
+
4
12
  if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
5
13
  describe 'DataMapper::Timestamp' do
6
14
  describe "Timestamp (shared behavior)", :shared => true do
7
15
  it "should not set the created_at/on fields if they're already set" do
8
- repository(:default) do
9
- green_smoothie = GreenSmoothie.new(:name => 'Banana')
10
- time = (DateTime.now - 100)
11
- green_smoothie.created_at = time
12
- green_smoothie.created_on = time
13
- green_smoothie.save
14
- green_smoothie.created_at.should == time
15
- green_smoothie.created_on.should == time
16
- green_smoothie.created_at.should be_a_kind_of(DateTime)
17
- green_smoothie.created_on.should be_a_kind_of(Date)
18
- end
16
+ green_smoothie = GreenSmoothie.new(:name => 'Banana')
17
+ time = (DateTime.now - 100)
18
+ green_smoothie.created_at = time
19
+ green_smoothie.created_on = time
20
+ green_smoothie.save
21
+ green_smoothie.created_at.should == time
22
+ green_smoothie.created_on.should == time
23
+ green_smoothie.created_at.should be_a_kind_of(DateTime)
24
+ green_smoothie.created_on.should be_a_kind_of(Date)
19
25
  end
20
26
 
21
27
  it "should set the created_at/on fields on creation" do
22
- repository(:default) do
23
- green_smoothie = GreenSmoothie.new(:name => 'Banana')
24
- green_smoothie.created_at.should be_nil
25
- green_smoothie.created_on.should be_nil
26
- green_smoothie.save
27
- green_smoothie.created_at.should be_a_kind_of(DateTime)
28
- green_smoothie.created_on.should be_a_kind_of(Date)
29
- end
28
+ green_smoothie = GreenSmoothie.new(:name => 'Banana')
29
+ green_smoothie.created_at.should be_nil
30
+ green_smoothie.created_on.should be_nil
31
+ green_smoothie.save
32
+ green_smoothie.created_at.should be_a_kind_of(DateTime)
33
+ green_smoothie.created_on.should be_a_kind_of(Date)
30
34
  end
31
35
 
32
36
  it "should not alter the create_at/on fields on model updates" do
33
- repository(:default) do
34
- green_smoothie = GreenSmoothie.new(:id => 2, :name => 'Berry')
35
- green_smoothie.created_at.should be_nil
36
- green_smoothie.created_on.should be_nil
37
- green_smoothie.save
38
- original_created_at = green_smoothie.created_at
39
- original_created_on = green_smoothie.created_on
40
- green_smoothie.name = 'Strawberry'
41
- green_smoothie.save
42
- green_smoothie.created_at.should eql(original_created_at)
43
- green_smoothie.created_on.should eql(original_created_on)
44
- end
37
+ green_smoothie = GreenSmoothie.new(:id => 2, :name => 'Berry')
38
+ green_smoothie.created_at.should be_nil
39
+ green_smoothie.created_on.should be_nil
40
+ green_smoothie.save
41
+ original_created_at = green_smoothie.created_at
42
+ original_created_on = green_smoothie.created_on
43
+ green_smoothie.name = 'Strawberry'
44
+ green_smoothie.save
45
+ green_smoothie.created_at.should eql(original_created_at)
46
+ green_smoothie.created_on.should eql(original_created_on)
45
47
  end
46
48
 
47
49
  it "should set the updated_at/on fields on creation and on update" do
48
- repository(:default) do
49
- green_smoothie = GreenSmoothie.new(:name => 'Mango')
50
- green_smoothie.updated_at.should be_nil
51
- green_smoothie.updated_on.should be_nil
52
- green_smoothie.save
53
- green_smoothie.updated_at.should be_a_kind_of(DateTime)
54
- green_smoothie.updated_on.should be_a_kind_of(Date)
55
- original_updated_at = green_smoothie.updated_at
56
- original_updated_on = green_smoothie.updated_on
57
- time_tomorrow = DateTime.now + 1
58
- date_tomorrow = Date.today + 1
59
- DateTime.stub!(:now).and_return { time_tomorrow }
60
- Date.stub!(:today).and_return { date_tomorrow }
61
- green_smoothie.name = 'Cranberry Mango'
62
- green_smoothie.save
63
- green_smoothie.updated_at.should_not eql(original_updated_at)
64
- green_smoothie.updated_on.should_not eql(original_updated_on)
65
- green_smoothie.updated_at.should eql(time_tomorrow)
66
- green_smoothie.updated_on.should eql(date_tomorrow)
67
- end
50
+ green_smoothie = GreenSmoothie.new(:name => 'Mango')
51
+ green_smoothie.updated_at.should be_nil
52
+ green_smoothie.updated_on.should be_nil
53
+ green_smoothie.save
54
+ green_smoothie.updated_at.should be_a_kind_of(DateTime)
55
+ green_smoothie.updated_on.should be_a_kind_of(Date)
56
+ original_updated_at = green_smoothie.updated_at
57
+ original_updated_on = green_smoothie.updated_on
58
+ time_tomorrow = DateTime.now + 1
59
+ date_tomorrow = Date.today + 1
60
+ DateTime.stub!(:now).and_return { time_tomorrow }
61
+ Date.stub!(:today).and_return { date_tomorrow }
62
+ green_smoothie.name = 'Cranberry Mango'
63
+ green_smoothie.save
64
+ green_smoothie.updated_at.should_not eql(original_updated_at)
65
+ green_smoothie.updated_on.should_not eql(original_updated_on)
66
+ green_smoothie.updated_at.should eql(time_tomorrow)
67
+ green_smoothie.updated_on.should eql(date_tomorrow)
68
68
  end
69
69
 
70
70
  it "should only set the updated_at/on fields on dirty objects" do
71
- repository(:default) do
72
- green_smoothie = GreenSmoothie.new(:name => 'Mango')
73
- green_smoothie.updated_at.should be_nil
74
- green_smoothie.updated_on.should be_nil
75
- green_smoothie.save
76
- green_smoothie.updated_at.should be_a_kind_of(DateTime)
77
- green_smoothie.updated_on.should be_a_kind_of(Date)
78
- original_updated_at = green_smoothie.updated_at
79
- original_updated_on = green_smoothie.updated_on
80
- time_tomorrow = DateTime.now + 1
81
- date_tomorrow = Date.today + 1
82
- DateTime.stub!(:now).and_return { time_tomorrow }
83
- Date.stub!(:today).and_return { date_tomorrow }
84
- green_smoothie.save
85
- green_smoothie.updated_at.should_not eql(time_tomorrow)
86
- green_smoothie.updated_on.should_not eql(date_tomorrow)
87
- green_smoothie.updated_at.should eql(original_updated_at)
88
- green_smoothie.updated_on.should eql(original_updated_on)
89
- end
71
+ green_smoothie = GreenSmoothie.new(:name => 'Mango')
72
+ green_smoothie.updated_at.should be_nil
73
+ green_smoothie.updated_on.should be_nil
74
+ green_smoothie.save
75
+ green_smoothie.updated_at.should be_a_kind_of(DateTime)
76
+ green_smoothie.updated_on.should be_a_kind_of(Date)
77
+ original_updated_at = green_smoothie.updated_at
78
+ original_updated_on = green_smoothie.updated_on
79
+ time_tomorrow = DateTime.now + 1
80
+ date_tomorrow = Date.today + 1
81
+ DateTime.stub!(:now).and_return { time_tomorrow }
82
+ Date.stub!(:today).and_return { date_tomorrow }
83
+ green_smoothie.save
84
+ green_smoothie.updated_at.should_not eql(time_tomorrow)
85
+ green_smoothie.updated_on.should_not eql(date_tomorrow)
86
+ green_smoothie.updated_at.should eql(original_updated_at)
87
+ green_smoothie.updated_on.should eql(original_updated_on)
90
88
  end
91
89
  end
92
90
 
@@ -96,14 +94,14 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
96
94
  class GreenSmoothie
97
95
  include DataMapper::Resource
98
96
 
99
- property :id, Integer, :serial => true
100
- property :name, String
97
+ property :id, Serial
98
+ property :name, String
101
99
  property :created_at, DateTime
102
100
  property :created_on, Date
103
101
  property :updated_at, DateTime
104
102
  property :updated_on, Date
105
103
 
106
- auto_migrate!(:default)
104
+ auto_migrate!
107
105
  end
108
106
  end
109
107
 
@@ -162,12 +160,12 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
162
160
  class GreenSmoothie
163
161
  include DataMapper::Resource
164
162
 
165
- property :id, Integer, :serial => true
163
+ property :id, Serial
166
164
  property :name, String
167
165
 
168
166
  timestamps :at, :on
169
167
 
170
- auto_migrate!(:default)
168
+ auto_migrate!
171
169
  end
172
170
  end
173
171
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-timestamps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foy Savas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-07 00:00:00 -08:00
12
+ date: 2009-01-04 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.8
23
+ version: 0.9.9
24
24
  version:
25
25
  description: DataMapper plugin for magical timestamps
26
26
  email: