simple_record 1.1.67 → 1.1.68
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_record.rb +14 -11
- data/lib/simple_record/attributes.rb +1 -1
- data/test/model_with_enc.rb +0 -1
- data/test/test_base.rb +14 -7
- data/test/test_dirty.rb +79 -0
- data/test/test_global_options.rb +43 -0
- data/test/test_simple_record.rb +52 -1
- metadata +20 -10
- data/test/dirty_test.rb +0 -52
data/lib/simple_record.rb
CHANGED
@@ -135,9 +135,8 @@ module SimpleRecord
|
|
135
135
|
|
136
136
|
attr_accessor :errors
|
137
137
|
|
138
|
-
@domain_prefix = ''
|
139
138
|
class << self;
|
140
|
-
attr_accessor :domain_prefix
|
139
|
+
attr_accessor :domain_prefix
|
141
140
|
end
|
142
141
|
|
143
142
|
#@domain_name_for_class = nil
|
@@ -172,14 +171,14 @@ module SimpleRecord
|
|
172
171
|
|
173
172
|
|
174
173
|
def domain
|
175
|
-
super # super.domain
|
174
|
+
self.class.domain # super # super.domain
|
176
175
|
end
|
177
176
|
|
178
177
|
def self.domain
|
179
178
|
#return self.get_domain_name unless self.get_domain_name.nil?
|
180
179
|
d = super
|
181
|
-
|
182
|
-
domain_name_for_class = SimpleRecord::Base.domain_prefix + d.to_s
|
180
|
+
puts 'in self.domain, d=' + d.to_s + ' domain_prefix=' + SimpleRecord::Base.domain_prefix.to_s
|
181
|
+
domain_name_for_class = (SimpleRecord::Base.domain_prefix || "") + d.to_s
|
183
182
|
#self.set_domain_name(domain_name_for_class)
|
184
183
|
domain_name_for_class
|
185
184
|
end
|
@@ -221,11 +220,11 @@ module SimpleRecord
|
|
221
220
|
# puts "Marking #{arg} dirty with #{value}"
|
222
221
|
if @dirty.include?(sdb_att_name)
|
223
222
|
old = @dirty[sdb_att_name]
|
224
|
-
# puts "
|
223
|
+
# puts "#{sdb_att_name} was already dirty #{old}"
|
225
224
|
@dirty.delete(sdb_att_name) if value == old
|
226
225
|
else
|
227
|
-
old =
|
228
|
-
# puts "dirtifying old=#{old} to new=#{value}"
|
226
|
+
old = get_attribute(arg)
|
227
|
+
# puts "dirtifying #{sdb_att_name} old=#{old.inspect} to new=#{value.inspect}"
|
229
228
|
@dirty[sdb_att_name] = old if value != old
|
230
229
|
end
|
231
230
|
end
|
@@ -338,11 +337,10 @@ module SimpleRecord
|
|
338
337
|
options[:dirty_atts] = @dirty
|
339
338
|
end
|
340
339
|
to_delete = get_atts_to_delete # todo: this should use the @dirty hash now
|
341
|
-
# puts 'done to_delete ' + to_delete.inspect
|
342
|
-
# puts 'options=' + options.inspect
|
343
340
|
SimpleRecord.stats.puts += 1
|
341
|
+
# puts 'SELF BEFORE super=' + self.inspect
|
344
342
|
if super(options)
|
345
|
-
#
|
343
|
+
# puts 'SELF AFTER super=' + self.inspect
|
346
344
|
self.class.cache_results(self)
|
347
345
|
delete_niled(to_delete)
|
348
346
|
if (is_create ? run_after_create : run_after_update) && run_after_save
|
@@ -624,6 +622,11 @@ module SimpleRecord
|
|
624
622
|
end
|
625
623
|
end
|
626
624
|
|
625
|
+
def self.create(attributes={})
|
626
|
+
# puts "About to create in domain #{domain}"
|
627
|
+
super
|
628
|
+
end
|
629
|
+
|
627
630
|
@@regex_no_id = /.*Couldn't find.*with ID.*/
|
628
631
|
|
629
632
|
#
|
@@ -29,7 +29,7 @@ module SimpleRecord
|
|
29
29
|
if arg.is_a?(Hash)
|
30
30
|
# then attribute may have extra options
|
31
31
|
arg_options = arg
|
32
|
-
arg = arg_options[:name]
|
32
|
+
arg = arg_options[:name].to_sym
|
33
33
|
end
|
34
34
|
attr = Attribute.new(:string, arg_options)
|
35
35
|
defined_attributes[arg] = attr if defined_attributes[arg].nil?
|
data/test/model_with_enc.rb
CHANGED
data/test/test_base.rb
CHANGED
@@ -9,15 +9,10 @@ require 'active_support'
|
|
9
9
|
|
10
10
|
class TestBase < Test::Unit::TestCase
|
11
11
|
|
12
|
-
def setup
|
13
|
-
@config = YAML::load(File.open(File.expand_path("~/.test-configs/simple_record.yml")))
|
14
|
-
#puts 'inspecting config = ' + @config.inspect
|
15
12
|
|
16
|
-
|
17
|
-
|
13
|
+
def setup
|
14
|
+
reset_connection()
|
18
15
|
|
19
|
-
SimpleRecord.establish_connection(@config['amazon']['access_key'], @config['amazon']['secret_key'], :connection_mode=>:single)
|
20
|
-
SimpleRecord::Base.set_domain_prefix("simplerecord_tests_")
|
21
16
|
end
|
22
17
|
|
23
18
|
def teardown
|
@@ -25,4 +20,16 @@ class TestBase < Test::Unit::TestCase
|
|
25
20
|
end
|
26
21
|
|
27
22
|
|
23
|
+
def reset_connection
|
24
|
+
@config = YAML::load(File.open(File.expand_path("~/.test-configs/simple_record.yml")))
|
25
|
+
#puts 'inspecting config = ' + @config.inspect
|
26
|
+
|
27
|
+
SimpleRecord::Base.set_domain_prefix("simplerecord_tests_")
|
28
|
+
SimpleRecord.establish_connection(@config['amazon']['access_key'], @config['amazon']['secret_key'], :connection_mode=>:single)
|
29
|
+
|
30
|
+
# Establish AWS connection directly
|
31
|
+
@@sdb = Aws::SdbInterface.new(@config['amazon']['access_key'], @config['amazon']['secret_key'], {:connection_mode => :per_request})
|
32
|
+
|
33
|
+
end
|
34
|
+
|
28
35
|
end
|
data/test/test_dirty.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
|
3
|
+
require "yaml"
|
4
|
+
require 'aws'
|
5
|
+
require 'my_model'
|
6
|
+
require 'my_child_model'
|
7
|
+
require 'active_support'
|
8
|
+
require 'test_base'
|
9
|
+
|
10
|
+
|
11
|
+
class Person < SimpleRecord::Base
|
12
|
+
has_strings :name, :i_as_s
|
13
|
+
has_ints :age
|
14
|
+
end
|
15
|
+
class DirtyTest < TestBase
|
16
|
+
|
17
|
+
def setup
|
18
|
+
super
|
19
|
+
|
20
|
+
Person.create_domain
|
21
|
+
@person = Person.new(:name => 'old', :age => 70)
|
22
|
+
@person.save
|
23
|
+
|
24
|
+
assert !@person.changed?
|
25
|
+
assert !@person.name_changed?
|
26
|
+
end
|
27
|
+
|
28
|
+
def teardown
|
29
|
+
Person.delete_domain
|
30
|
+
SimpleRecord.close_connection
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_same_value_are_not_dirty
|
34
|
+
@person.name = "old"
|
35
|
+
|
36
|
+
assert !@person.changed?
|
37
|
+
assert !@person.name_changed?
|
38
|
+
|
39
|
+
@person.age = 70
|
40
|
+
puts 'age_change2=' + @person.age_change.inspect
|
41
|
+
assert !@person.changed?
|
42
|
+
assert !@person.age_changed?
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_reverted_changes_are_not_dirty
|
46
|
+
@person.name = "new"
|
47
|
+
assert @person.changed?
|
48
|
+
assert @person.name_changed?
|
49
|
+
|
50
|
+
@person.name = "old"
|
51
|
+
assert !@person.changed?
|
52
|
+
assert !@person.name_changed?
|
53
|
+
|
54
|
+
@person.age = 15
|
55
|
+
assert @person.changed?
|
56
|
+
assert @person.age_changed?
|
57
|
+
|
58
|
+
@person.age = 70
|
59
|
+
puts 'age_change2=' + @person.age_change.inspect
|
60
|
+
assert !@person.changed?
|
61
|
+
assert !@person.age_changed?
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_storing_int_as_string
|
65
|
+
@person.i_as_s = 5
|
66
|
+
assert @person.changed?
|
67
|
+
assert @person.i_as_s_changed?
|
68
|
+
@person.save
|
69
|
+
|
70
|
+
sleep 2
|
71
|
+
|
72
|
+
@person.i_as_s = 5
|
73
|
+
puts 'i_as_s_changed=' + @person.i_as_s_change.inspect
|
74
|
+
# Maybe this should fail? What do we expect this behavior to be?
|
75
|
+
# assert !@person.changed?
|
76
|
+
# assert !@person.i_as_s_changed?
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
|
3
|
+
require "yaml"
|
4
|
+
require 'aws'
|
5
|
+
require 'my_model'
|
6
|
+
require 'my_child_model'
|
7
|
+
require 'active_support'
|
8
|
+
require 'test_base'
|
9
|
+
|
10
|
+
|
11
|
+
class Person < SimpleRecord::Base
|
12
|
+
has_strings :name, :i_as_s
|
13
|
+
has_ints :age
|
14
|
+
end
|
15
|
+
class TestGlobalOptions < TestBase
|
16
|
+
|
17
|
+
def setup
|
18
|
+
|
19
|
+
SimpleRecord::Base.set_domain_prefix("someprefix_")
|
20
|
+
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_domain_prefix
|
25
|
+
|
26
|
+
# SimpleRecord::Base.set_domain_prefix("someprefix_")
|
27
|
+
|
28
|
+
p = Person.create(:name=>"my prefix name")
|
29
|
+
|
30
|
+
sleep 1
|
31
|
+
|
32
|
+
sdb_atts = @@sdb.select("select * from someprefix_people")
|
33
|
+
puts 'sdb_atts=' + sdb_atts.inspect
|
34
|
+
|
35
|
+
@@sdb.delete_domain("someprefix_people") # doing it here so it's done before assertions might fail
|
36
|
+
|
37
|
+
assert sdb_atts[:items].size == 1, "hmmm, not size 1: " + sdb_atts[:items].size.to_s
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/test_simple_record.rb
CHANGED
@@ -21,6 +21,7 @@ class TestSimpleRecord < TestBase
|
|
21
21
|
mm.age = 32
|
22
22
|
mm.cool = true
|
23
23
|
mm.save
|
24
|
+
sleep 1
|
24
25
|
|
25
26
|
assert !mm.created.nil?
|
26
27
|
assert !mm.updated.nil?
|
@@ -53,6 +54,40 @@ class TestSimpleRecord < TestBase
|
|
53
54
|
assert mm2.age.nil?, "doh, age is " + mm2.age.inspect
|
54
55
|
end
|
55
56
|
|
57
|
+
|
58
|
+
|
59
|
+
def test_updates
|
60
|
+
mm = MyModel.new
|
61
|
+
mm.name = "Travis"
|
62
|
+
mm.age = 32
|
63
|
+
mm.cool = true
|
64
|
+
mm.s1 = "Initial value"
|
65
|
+
mm.save
|
66
|
+
id = mm.id
|
67
|
+
sleep 1
|
68
|
+
|
69
|
+
mm = MyModel.find(id)
|
70
|
+
mm.name = "Travis2"
|
71
|
+
mm.age = 10
|
72
|
+
mm.cool = false
|
73
|
+
mm.s1 = "" # test blank string
|
74
|
+
|
75
|
+
puts 'mm=' + mm.inspect
|
76
|
+
mm.save
|
77
|
+
sleep 1
|
78
|
+
|
79
|
+
puts 'mm2=' + mm.inspect
|
80
|
+
|
81
|
+
assert mm.s1 == "", "mm.s1 is not empty string, it is " + mm.s1.inspect
|
82
|
+
|
83
|
+
mm = MyModel.find(id)
|
84
|
+
assert mm.name == "Travis2"
|
85
|
+
assert mm.age == 10
|
86
|
+
assert mm.cool == false
|
87
|
+
assert mm.s1 == "", "mm.s1 is not empty string, it is #{mm.s1.inspect}"
|
88
|
+
|
89
|
+
end
|
90
|
+
|
56
91
|
def test_funky_values
|
57
92
|
mm = MyModel.new(:name=>"Funky")
|
58
93
|
mm.s1 = "other/2009-11-10/04/84.eml" # reported here: http://groups.google.com/group/simple-record/browse_thread/thread/3659e82491d03a2c?hl=en
|
@@ -90,6 +125,7 @@ class TestSimpleRecord < TestBase
|
|
90
125
|
mm.cool = false
|
91
126
|
items << mm
|
92
127
|
MyModel.batch_save(items)
|
128
|
+
sleep 1
|
93
129
|
items.each do |item|
|
94
130
|
puts 'id=' + item.id
|
95
131
|
new_item = MyModel.find(item.id)
|
@@ -138,6 +174,7 @@ class TestSimpleRecord < TestBase
|
|
138
174
|
# test queued callback before_create
|
139
175
|
mm.name = "Travis"
|
140
176
|
assert mm.save
|
177
|
+
sleep 1
|
141
178
|
# now nickname should be set on before_create
|
142
179
|
assert mm.nickname == mm.name
|
143
180
|
|
@@ -183,6 +220,8 @@ class TestSimpleRecord < TestBase
|
|
183
220
|
mmc.x = mm
|
184
221
|
mmc.save
|
185
222
|
|
223
|
+
sleep 1
|
224
|
+
|
186
225
|
mmc2 = MyChildModel.find(mmc.id)
|
187
226
|
assert mmc2.my_model_id == mmc.my_model_id, "mm2.my_model_id=#{mmc2.my_model_id} mmc.my_model_id=#{mmc.my_model_id}"
|
188
227
|
puts 'setting my_model to nil'
|
@@ -198,6 +237,8 @@ class TestSimpleRecord < TestBase
|
|
198
237
|
assert mmc2.my_model_id == nil
|
199
238
|
assert mmc2.my_model == nil, "my_model not nil? #{mmc2.my_model.inspect}"
|
200
239
|
|
240
|
+
sleep 1
|
241
|
+
|
201
242
|
mmc3 = MyChildModel.find(mmc.id)
|
202
243
|
puts "mmc3 1 =" + mmc3.inspect
|
203
244
|
assert mmc3.my_model_id == nil, "my_model_id not nil? #{mmc3.my_model_id.inspect}"
|
@@ -205,14 +246,15 @@ class TestSimpleRecord < TestBase
|
|
205
246
|
|
206
247
|
mm3 = MyModel.new(:name=>"test")
|
207
248
|
assert mm3.save
|
249
|
+
sleep 1
|
208
250
|
|
209
251
|
mmc3.my_model = mm3
|
210
252
|
assert mmc3.my_model_changed?
|
211
253
|
assert mmc3.save(:dirty=>true)
|
212
|
-
|
213
254
|
assert mmc3.my_model_id == mm3.id
|
214
255
|
assert mmc3.my_model.id == mm3.id
|
215
256
|
|
257
|
+
sleep 1
|
216
258
|
mmc3 = MyChildModel.find(mmc3.id)
|
217
259
|
puts "mmc3=" + mmc3.inspect
|
218
260
|
assert mmc3.my_model_id == mm3.id, "my_model_id=#{mmc3.my_model_id.inspect} mm3.id=#{mm3.id.inspect}"
|
@@ -331,6 +373,7 @@ class TestSimpleRecord < TestBase
|
|
331
373
|
# my_model should be treated differently since it's a belong_to
|
332
374
|
mcm = MyChildModel.new(:name=>"johnny", :my_model=>mm)
|
333
375
|
mcm.save
|
376
|
+
sleep 1
|
334
377
|
|
335
378
|
assert mcm.my_model != nil
|
336
379
|
|
@@ -376,6 +419,7 @@ class TestSimpleRecord < TestBase
|
|
376
419
|
|
377
420
|
mm.age = nil
|
378
421
|
mm.save
|
422
|
+
sleep 1
|
379
423
|
|
380
424
|
# Should be NIL
|
381
425
|
assert mm.age == nil
|
@@ -422,12 +466,14 @@ class TestSimpleRecord < TestBase
|
|
422
466
|
mm.name = "test name"
|
423
467
|
mm.base_string = "in base class"
|
424
468
|
mm.save_with_validation!
|
469
|
+
sleep 1
|
425
470
|
|
426
471
|
mm2 = MyModel.find(mm.id)
|
427
472
|
assert mm2.base_string == mm.base_string
|
428
473
|
|
429
474
|
mm2.base_string = "changed base string"
|
430
475
|
mm2.save_with_validation!
|
476
|
+
sleep 1
|
431
477
|
|
432
478
|
mm3 = MyModel.find(mm2.id)
|
433
479
|
assert mm3.base_string == mm2.base_string
|
@@ -512,6 +558,7 @@ class TestSimpleRecord < TestBase
|
|
512
558
|
|
513
559
|
mm.save
|
514
560
|
mm2.save
|
561
|
+
sleep 1
|
515
562
|
|
516
563
|
mm = MyModel.find(mm.id)
|
517
564
|
mm2 = MyModel.find(mm2.id)
|
@@ -521,6 +568,7 @@ class TestSimpleRecord < TestBase
|
|
521
568
|
def test_constructor_using_belongs_to_ids
|
522
569
|
mm = MyModel.new({:name=>"myname"})
|
523
570
|
mm.save
|
571
|
+
sleep 1
|
524
572
|
|
525
573
|
mm2 = MyChildModel.new({"name"=>"myname2", :my_model_id=>mm.id})
|
526
574
|
puts 'mm2=' + mm2.inspect
|
@@ -545,6 +593,7 @@ class TestSimpleRecord < TestBase
|
|
545
593
|
def test_explicit_class_name
|
546
594
|
mm = MyModel.new({:name=>"myname"})
|
547
595
|
mm.save
|
596
|
+
sleep 1
|
548
597
|
|
549
598
|
mm2 = MyChildModel.new({"name"=>"myname2"})
|
550
599
|
mm2.x = mm
|
@@ -562,6 +611,7 @@ class TestSimpleRecord < TestBase
|
|
562
611
|
mm.date1 = Time.now
|
563
612
|
mm.date2 = DateTime.now
|
564
613
|
mm.save
|
614
|
+
sleep 1
|
565
615
|
|
566
616
|
raw = @@sdb.get_attributes(MyModel.domain, mm.id)
|
567
617
|
puts "raw=" + raw.inspect
|
@@ -579,4 +629,5 @@ class TestSimpleRecord < TestBase
|
|
579
629
|
mme = ModelWithEnc.new(:ssn=>nil, :password=>nil)
|
580
630
|
end
|
581
631
|
|
632
|
+
|
582
633
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 68
|
9
|
+
version: 1.1.68
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Travis Reeder
|
@@ -11,19 +16,21 @@ autorequire:
|
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
18
|
|
14
|
-
date: 2010-
|
19
|
+
date: 2010-03-07 00:00:00 -08:00
|
15
20
|
default_executable:
|
16
21
|
dependencies:
|
17
22
|
- !ruby/object:Gem::Dependency
|
18
23
|
name: aws
|
19
|
-
|
20
|
-
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
26
|
requirements:
|
23
27
|
- - ">="
|
24
28
|
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
25
31
|
version: "0"
|
26
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
27
34
|
description: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
|
28
35
|
email: travis@appoxy.com
|
29
36
|
executables: []
|
@@ -56,24 +63,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
63
|
requirements:
|
57
64
|
- - ">="
|
58
65
|
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
59
68
|
version: "0"
|
60
|
-
version:
|
61
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
70
|
requirements:
|
63
71
|
- - ">="
|
64
72
|
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
65
75
|
version: "0"
|
66
|
-
version:
|
67
76
|
requirements: []
|
68
77
|
|
69
78
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.6
|
71
80
|
signing_key:
|
72
81
|
specification_version: 3
|
73
82
|
summary: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
|
74
83
|
test_files:
|
75
84
|
- test/conversions.rb
|
76
|
-
- test/dirty_test.rb
|
77
85
|
- test/model_with_enc.rb
|
78
86
|
- test/my_base_model.rb
|
79
87
|
- test/my_child_model.rb
|
@@ -81,6 +89,8 @@ test_files:
|
|
81
89
|
- test/paging_array_test.rb
|
82
90
|
- test/temp_test.rb
|
83
91
|
- test/test_base.rb
|
92
|
+
- test/test_dirty.rb
|
93
|
+
- test/test_global_options.rb
|
84
94
|
- test/test_helpers.rb
|
85
95
|
- test/test_results_array.rb
|
86
96
|
- test/test_simple_record.rb
|
data/test/dirty_test.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
|
3
|
-
require "yaml"
|
4
|
-
require 'right_aws'
|
5
|
-
require 'my_model'
|
6
|
-
require 'my_child_model'
|
7
|
-
require 'active_support'
|
8
|
-
|
9
|
-
|
10
|
-
class Person < SimpleRecord::Base
|
11
|
-
has_strings :name
|
12
|
-
has_ints :age
|
13
|
-
end
|
14
|
-
class DirtyTest < Test::Unit::TestCase
|
15
|
-
|
16
|
-
def setup
|
17
|
-
@config = YAML::load(File.open(File.join(File.dirname(__FILE__), "test-config.yml")))
|
18
|
-
@@sdb = RightAws::SdbInterface.new(@config['amazon']['access_key'], @config['amazon']['secret_key'], {:connection_mode => :per_request, :protocol => "http", :port => 80})
|
19
|
-
|
20
|
-
SimpleRecord.establish_connection(@config['amazon']['access_key'], @config['amazon']['secret_key'], :connection_mode=>:single)
|
21
|
-
SimpleRecord::Base.set_domain_prefix("simplerecord_tests_")
|
22
|
-
|
23
|
-
Person.create_domain
|
24
|
-
@person = Person.new(:name => 'old', :age => '70')
|
25
|
-
@person.save
|
26
|
-
|
27
|
-
assert !@person.changed?
|
28
|
-
assert !@person.name_changed?
|
29
|
-
end
|
30
|
-
|
31
|
-
def teardown
|
32
|
-
Person.delete_domain
|
33
|
-
SimpleRecord.close_connection
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_same_value_are_not_dirty
|
37
|
-
@person.name = "old"
|
38
|
-
|
39
|
-
assert !@person.changed?
|
40
|
-
assert !@person.name_changed?
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_reverted_changes_are_not_dirty
|
44
|
-
@person.name = "new"
|
45
|
-
assert @person.changed?
|
46
|
-
assert @person.name_changed?
|
47
|
-
|
48
|
-
@person.name = "old"
|
49
|
-
assert !@person.changed?
|
50
|
-
assert !@person.name_changed?
|
51
|
-
end
|
52
|
-
end
|