redis_orm 0.6.1 → 0.6.2
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/CHANGELOG +8 -0
- data/Manifest +32 -0
- data/Rakefile +7 -15
- data/TODO +5 -0
- data/lib/redis_orm/associations/belongs_to.rb +37 -3
- data/lib/redis_orm/associations/has_one.rb +32 -0
- data/lib/redis_orm/redis_orm.rb +47 -9
- data/redis_orm.gemspec +4 -4
- data/test/association_indices_test.rb +51 -28
- data/test/associations_test.rb +0 -59
- data/test/atomicity_test.rb +0 -7
- data/test/basic_functionality_test.rb +12 -28
- data/test/callbacks_test.rb +0 -70
- data/test/changes_array_test.rb +0 -6
- data/test/classes/album.rb +6 -0
- data/test/classes/article.rb +7 -0
- data/test/classes/book.rb +6 -0
- data/test/classes/catalog_item.rb +5 -0
- data/test/classes/category.rb +7 -0
- data/test/classes/city.rb +7 -0
- data/test/classes/comment.rb +26 -0
- data/test/classes/country.rb +5 -0
- data/test/classes/custom_user.rb +8 -0
- data/test/classes/cutout.rb +20 -0
- data/test/classes/cutout_aggregator.rb +5 -0
- data/test/classes/default_user.rb +10 -0
- data/test/classes/dynamic_finder_user.rb +8 -0
- data/test/classes/empty_person.rb +2 -0
- data/test/classes/giftcard.rb +6 -0
- data/test/classes/jigsaw.rb +4 -0
- data/test/classes/location.rb +5 -0
- data/test/classes/message.rb +4 -0
- data/test/classes/note.rb +5 -0
- data/test/classes/omni_user.rb +8 -0
- data/test/classes/person.rb +6 -0
- data/test/classes/photo.rb +21 -0
- data/test/classes/profile.rb +8 -0
- data/test/classes/sortable_user.rb +11 -0
- data/test/classes/timestamp.rb +3 -0
- data/test/classes/user.rb +39 -0
- data/test/classes/uuid_default_user.rb +12 -0
- data/test/classes/uuid_timestamp.rb +5 -0
- data/test/classes/uuid_user.rb +13 -0
- data/test/dynamic_finders_test.rb +9 -26
- data/test/exceptions_test.rb +1 -21
- data/test/has_one_has_many_test.rb +0 -12
- data/test/indices_test.rb +0 -18
- data/test/modules/belongs_to_model_within_module.rb +6 -0
- data/test/modules/has_many_model_within_module.rb +11 -0
- data/test/options_test.rb +0 -37
- data/test/polymorphic_test.rb +0 -39
- data/test/sortable_test.rb +60 -74
- data/test/test_helper.rb +4 -0
- data/test/uuid_as_id_test.rb +38 -70
- data/test/validations_test.rb +0 -8
- metadata +45 -12
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,10 @@ require 'rspec'
|
|
2
2
|
require 'rspec/autorun'
|
3
3
|
require File.dirname(File.expand_path(__FILE__)) + '/../lib/redis_orm.rb'
|
4
4
|
|
5
|
+
Dir.glob(['test/classes/*.rb', 'test/modules/*.rb']).each do |klassfile|
|
6
|
+
require File.dirname(File.expand_path(__FILE__)) + '/../' + klassfile
|
7
|
+
end
|
8
|
+
|
5
9
|
RSpec.configure do |config|
|
6
10
|
config.before(:all) do
|
7
11
|
path_to_conf = File.dirname(File.expand_path(__FILE__)) + "/redis.conf"
|
data/test/uuid_as_id_test.rb
CHANGED
@@ -1,42 +1,10 @@
|
|
1
1
|
require File.dirname(File.expand_path(__FILE__)) + '/test_helper.rb'
|
2
2
|
|
3
|
-
class User < RedisOrm::Base
|
4
|
-
use_uuid_as_id
|
5
|
-
|
6
|
-
property :name, String
|
7
|
-
property :age, Integer
|
8
|
-
property :wage, Float
|
9
|
-
property :male, RedisOrm::Boolean
|
10
|
-
|
11
|
-
property :created_at, Time
|
12
|
-
property :modified_at, Time
|
13
|
-
|
14
|
-
has_many :users, :as => :friends
|
15
|
-
end
|
16
|
-
|
17
|
-
class DefaultUser < RedisOrm::Base
|
18
|
-
use_uuid_as_id
|
19
|
-
|
20
|
-
property :name, String, :default => "german"
|
21
|
-
property :age, Integer, :default => 26
|
22
|
-
property :wage, Float, :default => 256.25
|
23
|
-
property :male, RedisOrm::Boolean, :default => true
|
24
|
-
property :admin, RedisOrm::Boolean, :default => false
|
25
|
-
|
26
|
-
property :created_at, Time
|
27
|
-
property :modified_at, Time
|
28
|
-
end
|
29
|
-
|
30
|
-
class TimeStamp < RedisOrm::Base
|
31
|
-
use_uuid_as_id
|
32
|
-
timestamps
|
33
|
-
end
|
34
|
-
|
35
3
|
describe "check basic functionality" do
|
36
4
|
it "test_simple_creation" do
|
37
|
-
|
5
|
+
UuidUser.count.should == 0
|
38
6
|
|
39
|
-
user =
|
7
|
+
user = UuidUser.new :name => "german"
|
40
8
|
user.save
|
41
9
|
|
42
10
|
user.should be
|
@@ -47,14 +15,14 @@ describe "check basic functionality" do
|
|
47
15
|
|
48
16
|
user.name.should == "german"
|
49
17
|
|
50
|
-
|
51
|
-
|
18
|
+
UuidUser.count.should == 1
|
19
|
+
UuidUser.first.name.should == "german"
|
52
20
|
end
|
53
21
|
|
54
22
|
it "should test different ways to update a record" do
|
55
|
-
|
23
|
+
UuidUser.count.should == 0
|
56
24
|
|
57
|
-
user =
|
25
|
+
user = UuidUser.new :name => "german"
|
58
26
|
user.should be
|
59
27
|
user.save
|
60
28
|
|
@@ -63,70 +31,70 @@ describe "check basic functionality" do
|
|
63
31
|
user.name = "nobody"
|
64
32
|
user.save
|
65
33
|
|
66
|
-
|
67
|
-
|
34
|
+
UuidUser.count.should == 1
|
35
|
+
UuidUser.first.name.should == "nobody"
|
68
36
|
|
69
|
-
u =
|
37
|
+
u = UuidUser.first
|
70
38
|
u.should be
|
71
39
|
u.id.should_not == 1
|
72
40
|
u.id.length.should == 32
|
73
41
|
u.update_attribute :name, "root"
|
74
|
-
|
42
|
+
UuidUser.first.name.should == "root"
|
75
43
|
|
76
|
-
u =
|
44
|
+
u = UuidUser.first
|
77
45
|
u.should be
|
78
46
|
u.update_attributes :name => "german"
|
79
|
-
|
47
|
+
UuidUser.first.name.should == "german"
|
80
48
|
end
|
81
49
|
|
82
50
|
it "test_deletion" do
|
83
|
-
|
51
|
+
UuidUser.count.should == 0
|
84
52
|
|
85
|
-
user =
|
53
|
+
user = UuidUser.new :name => "german"
|
86
54
|
user.save
|
87
55
|
user.should be
|
88
56
|
|
89
57
|
user.name.should == "german"
|
90
58
|
|
91
|
-
|
59
|
+
UuidUser.count.should == 1
|
92
60
|
id = user.id
|
93
61
|
|
94
62
|
user.destroy
|
95
|
-
|
63
|
+
UuidUser.count.should == 0
|
96
64
|
$redis.zrank("user:ids", id).should == nil
|
97
65
|
$redis.hgetall("user:#{id}").should == {}
|
98
66
|
end
|
99
67
|
|
100
68
|
it "should return first and last objects" do
|
101
|
-
|
102
|
-
|
103
|
-
|
69
|
+
UuidUser.count.should == 0
|
70
|
+
UuidUser.first.should == nil
|
71
|
+
UuidUser.last.should == nil
|
104
72
|
|
105
|
-
user1 =
|
73
|
+
user1 = UuidUser.new :name => "german"
|
106
74
|
user1.save
|
107
75
|
user1.should be
|
108
76
|
user1.name.should == "german"
|
109
77
|
user1.id.should_not == 1
|
110
78
|
user1.id.length.should == 32 # b57525b09a69012e8fbe001d61192f09 for example
|
111
79
|
|
112
|
-
user2 =
|
80
|
+
user2 = UuidUser.new :name => "nobody"
|
113
81
|
user2.save
|
114
82
|
user2.should be
|
115
83
|
user2.name.should == "nobody"
|
116
84
|
user2.id.should_not == 2
|
117
85
|
user2.id.length.should == 32
|
118
86
|
|
119
|
-
|
87
|
+
UuidUser.count.should == 2
|
120
88
|
|
121
|
-
|
122
|
-
|
89
|
+
UuidUser.first.should be
|
90
|
+
UuidUser.last.should be
|
123
91
|
|
124
|
-
|
125
|
-
|
92
|
+
UuidUser.first.id.should == user1.id
|
93
|
+
UuidUser.last.id.should == user2.id
|
126
94
|
end
|
127
95
|
|
128
96
|
it "should return values with correct classes" do
|
129
|
-
user =
|
97
|
+
user = UuidUser.new
|
130
98
|
user.name = "german"
|
131
99
|
user.age = 26
|
132
100
|
user.wage = 124.34
|
@@ -135,7 +103,7 @@ describe "check basic functionality" do
|
|
135
103
|
|
136
104
|
user.should be
|
137
105
|
|
138
|
-
u =
|
106
|
+
u = UuidUser.first
|
139
107
|
|
140
108
|
u.created_at.class.should == Time
|
141
109
|
u.modified_at.class.should == Time
|
@@ -152,11 +120,11 @@ describe "check basic functionality" do
|
|
152
120
|
end
|
153
121
|
|
154
122
|
it "should return correct saved defaults" do
|
155
|
-
|
156
|
-
|
157
|
-
|
123
|
+
UuidDefaultUser.count.should == 0
|
124
|
+
UuidDefaultUser.create
|
125
|
+
UuidDefaultUser.count.should == 1
|
158
126
|
|
159
|
-
u =
|
127
|
+
u = UuidDefaultUser.first
|
160
128
|
|
161
129
|
u.created_at.class.should == Time
|
162
130
|
u.modified_at.class.should == Time
|
@@ -173,11 +141,11 @@ describe "check basic functionality" do
|
|
173
141
|
u.id.should_not == 1
|
174
142
|
u.id.length.should == 32
|
175
143
|
|
176
|
-
du =
|
144
|
+
du = UuidDefaultUser.new
|
177
145
|
du.name = "germaninthetown"
|
178
146
|
du.save
|
179
147
|
|
180
|
-
du_saved =
|
148
|
+
du_saved = UuidDefaultUser.last
|
181
149
|
du_saved.name.should == "germaninthetown"
|
182
150
|
du_saved.admin.should == false
|
183
151
|
du.id.should_not == 2
|
@@ -186,7 +154,7 @@ describe "check basic functionality" do
|
|
186
154
|
end
|
187
155
|
|
188
156
|
it "should expand timestamps declaration properly" do
|
189
|
-
t =
|
157
|
+
t = UuidTimeStamp.new
|
190
158
|
t.save
|
191
159
|
|
192
160
|
t.created_at.should be
|
@@ -197,9 +165,9 @@ describe "check basic functionality" do
|
|
197
165
|
|
198
166
|
# from associations_test.rb
|
199
167
|
it "should maintain correct self referencing link" do
|
200
|
-
me =
|
201
|
-
friend1 =
|
202
|
-
friend2 =
|
168
|
+
me = UuidUser.create :name => "german", :age => 26, :wage => 10.0, :male => true
|
169
|
+
friend1 = UuidUser.create :name => "friend1", :age => 26, :wage => 7.0, :male => true
|
170
|
+
friend2 = UuidUser.create :name => "friend2", :age => 25, :wage => 5.0, :male => true
|
203
171
|
|
204
172
|
me.friends << [friend1, friend2]
|
205
173
|
|
data/test/validations_test.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
require File.dirname(File.expand_path(__FILE__)) + '/test_helper.rb'
|
2
2
|
|
3
|
-
class Photo < RedisOrm::Base
|
4
|
-
property :image, String
|
5
|
-
|
6
|
-
validates_presence_of :image
|
7
|
-
validates_length_of :image, :in => 7..32
|
8
|
-
validates_format_of :image, :with => /\w*\.(gif|jpe?g|png)/
|
9
|
-
end
|
10
|
-
|
11
3
|
describe "check associations" do
|
12
4
|
it "should validate presence if image in photo" do
|
13
5
|
p = Photo.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_orm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-05-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &11707440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11707440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &11706780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11706780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: redis
|
38
|
-
requirement: &
|
38
|
+
requirement: &11706160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.2.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11706160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: uuid
|
49
|
-
requirement: &
|
49
|
+
requirement: &11705440 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.3.2
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *11705440
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &11704820 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 2.5.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *11704820
|
69
69
|
description: ORM for Redis (advanced key-value storage) with ActiveRecord API
|
70
70
|
email: germaninthetown@gmail.com
|
71
71
|
executables: []
|
@@ -74,6 +74,7 @@ extra_rdoc_files:
|
|
74
74
|
- CHANGELOG
|
75
75
|
- LICENSE
|
76
76
|
- README.md
|
77
|
+
- TODO
|
77
78
|
- lib/redis_orm.rb
|
78
79
|
- lib/redis_orm/active_model_behavior.rb
|
79
80
|
- lib/redis_orm/associations/belongs_to.rb
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- Manifest
|
91
92
|
- README.md
|
92
93
|
- Rakefile
|
94
|
+
- TODO
|
93
95
|
- benchmarks/sortable_benchmark.rb
|
94
96
|
- lib/redis_orm.rb
|
95
97
|
- lib/redis_orm/active_model_behavior.rb
|
@@ -107,10 +109,41 @@ files:
|
|
107
109
|
- test/basic_functionality_test.rb
|
108
110
|
- test/callbacks_test.rb
|
109
111
|
- test/changes_array_test.rb
|
112
|
+
- test/classes/album.rb
|
113
|
+
- test/classes/article.rb
|
114
|
+
- test/classes/book.rb
|
115
|
+
- test/classes/catalog_item.rb
|
116
|
+
- test/classes/category.rb
|
117
|
+
- test/classes/city.rb
|
118
|
+
- test/classes/comment.rb
|
119
|
+
- test/classes/country.rb
|
120
|
+
- test/classes/custom_user.rb
|
121
|
+
- test/classes/cutout.rb
|
122
|
+
- test/classes/cutout_aggregator.rb
|
123
|
+
- test/classes/default_user.rb
|
124
|
+
- test/classes/dynamic_finder_user.rb
|
125
|
+
- test/classes/empty_person.rb
|
126
|
+
- test/classes/giftcard.rb
|
127
|
+
- test/classes/jigsaw.rb
|
128
|
+
- test/classes/location.rb
|
129
|
+
- test/classes/message.rb
|
130
|
+
- test/classes/note.rb
|
131
|
+
- test/classes/omni_user.rb
|
132
|
+
- test/classes/person.rb
|
133
|
+
- test/classes/photo.rb
|
134
|
+
- test/classes/profile.rb
|
135
|
+
- test/classes/sortable_user.rb
|
136
|
+
- test/classes/timestamp.rb
|
137
|
+
- test/classes/user.rb
|
138
|
+
- test/classes/uuid_default_user.rb
|
139
|
+
- test/classes/uuid_timestamp.rb
|
140
|
+
- test/classes/uuid_user.rb
|
110
141
|
- test/dynamic_finders_test.rb
|
111
142
|
- test/exceptions_test.rb
|
112
143
|
- test/has_one_has_many_test.rb
|
113
144
|
- test/indices_test.rb
|
145
|
+
- test/modules/belongs_to_model_within_module.rb
|
146
|
+
- test/modules/has_many_model_within_module.rb
|
114
147
|
- test/options_test.rb
|
115
148
|
- test/polymorphic_test.rb
|
116
149
|
- test/redis.conf
|