simple_record 2.0.2 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +26 -2
- data/lib/simple_record/attributes.rb +7 -5
- data/lib/simple_record.rb +869 -831
- data/test/test_base.rb +5 -3
- data/test/test_global_options.rb +31 -11
- metadata +3 -3
data/test/test_base.rb
CHANGED
@@ -30,7 +30,7 @@ class TestBase < Test::Unit::TestCase
|
|
30
30
|
# end
|
31
31
|
end
|
32
32
|
|
33
|
-
def reset_connection
|
33
|
+
def reset_connection(options={})
|
34
34
|
puts 'reset_connection'
|
35
35
|
@config = YAML::load(File.open(File.expand_path("~/.test_configs/simple_record.yml")))
|
36
36
|
#puts 'inspecting config = ' + @config.inspect
|
@@ -38,11 +38,13 @@ class TestBase < Test::Unit::TestCase
|
|
38
38
|
SimpleRecord.enable_logging
|
39
39
|
|
40
40
|
SimpleRecord::Base.set_domain_prefix("simplerecord_tests_")
|
41
|
-
SimpleRecord.establish_connection(@config['amazon']['access_key'], @config['amazon']['secret_key'],
|
41
|
+
SimpleRecord.establish_connection(@config['amazon']['access_key'], @config['amazon']['secret_key'],
|
42
|
+
{:connection_mode=>:single}.merge(options))
|
42
43
|
|
43
44
|
|
44
45
|
# Establish AWS connection directly
|
45
|
-
@@sdb = Aws::SdbInterface.new(@config['amazon']['access_key'], @config['amazon']['secret_key'],
|
46
|
+
@@sdb = Aws::SdbInterface.new(@config['amazon']['access_key'], @config['amazon']['secret_key'],
|
47
|
+
{:connection_mode => :single}.merge(options))
|
46
48
|
|
47
49
|
end
|
48
50
|
|
data/test/test_global_options.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
|
2
|
+
require_relative "../lib/simple_record"
|
3
3
|
require "yaml"
|
4
4
|
require 'aws'
|
5
|
-
|
6
|
-
|
7
|
-
require 'active_support'
|
8
|
-
|
5
|
+
require_relative 'my_model'
|
6
|
+
require_relative 'my_child_model'
|
7
|
+
require 'active_support/core_ext'
|
8
|
+
require_relative 'test_base'
|
9
9
|
|
10
10
|
|
11
11
|
class Person < SimpleRecord::Base
|
@@ -15,27 +15,47 @@ end
|
|
15
15
|
class TestGlobalOptions < TestBase
|
16
16
|
|
17
17
|
def setup
|
18
|
-
|
19
|
-
SimpleRecord::Base.set_domain_prefix("someprefix_")
|
20
|
-
|
21
18
|
super
|
22
19
|
end
|
23
20
|
|
24
21
|
def test_domain_prefix
|
25
22
|
|
26
|
-
|
23
|
+
SimpleRecord::Base.set_domain_prefix("someprefix_")
|
27
24
|
|
28
25
|
p = Person.create(:name=>"my prefix name")
|
29
26
|
|
30
27
|
sleep 1
|
31
28
|
|
32
|
-
|
29
|
+
sdb_atts = @@sdb.select("select * from someprefix_people")
|
33
30
|
puts 'sdb_atts=' + sdb_atts.inspect
|
34
31
|
|
35
|
-
|
32
|
+
@@sdb.delete_domain("someprefix_people") # doing it here so it's done before assertions might fail
|
36
33
|
|
37
34
|
assert sdb_atts[:items].size == 1, "hmmm, not size 1: " + sdb_atts[:items].size.to_s
|
38
35
|
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_created_col_and_updated_col
|
39
|
+
reset_connection(:created_col=>"created_at", :updated_col=>"updated_at")
|
40
|
+
|
41
|
+
p = Person.create(:name=>"my prefix name")
|
42
|
+
sleep 1
|
43
|
+
|
44
|
+
sdb_atts = @@sdb.select("select * from simplerecord_tests_people")
|
45
|
+
puts 'sdb_atts=' + sdb_atts.inspect
|
46
|
+
|
47
|
+
|
48
|
+
@@sdb.delete_domain("simplerecord_tests_people")
|
49
|
+
|
50
|
+
items = sdb_atts[:items][0]
|
51
|
+
first = nil
|
52
|
+
items.each_pair do |k, v|
|
53
|
+
first = v
|
54
|
+
break
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_nil first["created"]
|
58
|
+
assert_not_nil first["created_at"]
|
39
59
|
|
40
60
|
|
41
61
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 4
|
9
|
+
version: 2.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Reeder
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-28 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|