gotime-cassandra_object 4.5.1 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/Gemfile +5 -1
- data/README.rdoc +0 -2
- data/gotime-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/attribute_methods.rb +4 -4
- data/lib/cassandra_object/attribute_methods/dirty.rb +1 -1
- data/lib/cassandra_object/attribute_methods/primary_key.rb +1 -1
- data/lib/cassandra_object/attribute_methods/typecasting.rb +9 -6
- data/lib/cassandra_object/base.rb +11 -43
- data/lib/cassandra_object/belongs_to.rb +1 -1
- data/lib/cassandra_object/belongs_to/association.rb +1 -1
- data/lib/cassandra_object/belongs_to/reflection.rb +2 -2
- data/lib/cassandra_object/config.rb +15 -0
- data/lib/cassandra_object/connection.rb +1 -19
- data/lib/cassandra_object/consistency.rb +1 -1
- data/lib/cassandra_object/core.rb +46 -0
- data/lib/cassandra_object/errors.rb +2 -2
- data/lib/cassandra_object/identity.rb +1 -1
- data/lib/cassandra_object/persistence.rb +21 -7
- data/lib/cassandra_object/railtie.rb +1 -1
- data/lib/cassandra_object/savepoints.rb +1 -1
- data/lib/cassandra_object/schema.rb +30 -15
- data/lib/cassandra_object/schema/tasks.rb +8 -4
- data/lib/cassandra_object/scope.rb +1 -1
- data/lib/cassandra_object/scope/batches.rb +1 -1
- data/lib/cassandra_object/scope/finder_methods.rb +1 -1
- data/lib/cassandra_object/scope/query_methods.rb +1 -1
- data/lib/cassandra_object/tasks/ks.rake +6 -6
- data/lib/cassandra_object/types/array_type.rb +1 -1
- data/lib/cassandra_object/types/base_type.rb +1 -1
- data/lib/cassandra_object/types/boolean_type.rb +2 -2
- data/lib/cassandra_object/types/float_type.rb +1 -1
- data/lib/cassandra_object/types/integer_type.rb +1 -1
- data/lib/cassandra_object/types/json_type.rb +1 -1
- data/lib/cassandra_object/types/string_type.rb +1 -1
- data/lib/cassandra_object/types/time_type.rb +1 -1
- data/lib/cassandra_object/validations.rb +3 -3
- data/lib/gotime-cassandra_object.rb +10 -8
- data/test/support/connect.rb +3 -3
- data/test/support/issue.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/active_model_test.rb +6 -1
- data/test/unit/attribute_methods/definition_test.rb +1 -1
- data/test/unit/attribute_methods/dirty_test.rb +2 -2
- data/test/unit/attribute_methods/primary_key_test.rb +1 -1
- data/test/unit/attribute_methods/typecasting_test.rb +28 -2
- data/test/unit/base_test.rb +1 -43
- data/test/unit/belongs_to/reflection_test.rb +12 -0
- data/test/unit/belongs_to_test.rb +1 -1
- data/test/unit/callbacks_test.rb +1 -1
- data/test/unit/config_test.rb +23 -0
- data/test/unit/connection_test.rb +0 -20
- data/test/unit/consistency_test.rb +1 -1
- data/test/unit/core_test.rb +50 -0
- data/test/unit/identity_test.rb +1 -1
- data/test/unit/inspect_test.rb +1 -1
- data/test/unit/persistence_test.rb +36 -7
- data/test/unit/savepoints_test.rb +7 -7
- data/test/unit/schema_test.rb +1 -1
- data/test/unit/scope/batches_test.rb +4 -4
- data/test/unit/scope/finder_methods_test.rb +3 -3
- data/test/unit/scope/query_methods_test.rb +1 -1
- data/test/unit/scoping_test.rb +1 -1
- data/test/unit/timestamps_test.rb +1 -1
- data/test/unit/types/array_type_test.rb +3 -3
- data/test/unit/types/base_type_test.rb +1 -1
- data/test/unit/types/float_type_test.rb +2 -2
- data/test/unit/types/integer_type_test.rb +1 -1
- data/test/unit/types/string_type_test.rb +1 -1
- data/test/unit/types/time_type_test.rb +1 -1
- data/test/unit/validations_test.rb +1 -1
- metadata +7 -2
@@ -7,24 +7,4 @@ class CassandraObject::ConnectionTest < CassandraObject::TestCase
|
|
7
7
|
test "sanitize supports question marks" do
|
8
8
|
assert_equal 'hello ?', CassandraCQL::Statement.sanitize('hello ?')
|
9
9
|
end
|
10
|
-
|
11
|
-
test 'establish_connection' do
|
12
|
-
TestObject.establish_connection(
|
13
|
-
keyspace: 'place_directory_development',
|
14
|
-
servers: '192.168.0.100:9160',
|
15
|
-
thrift: {'timeout' => 10}
|
16
|
-
)
|
17
|
-
#
|
18
|
-
assert_equal ['192.168.0.100:9160'], TestObject.connection_config.servers
|
19
|
-
assert_equal 'place_directory_development', TestObject.connection_config.keyspace
|
20
|
-
assert_equal 10, TestObject.connection_config.thrift_options[:timeout]
|
21
|
-
end
|
22
|
-
|
23
|
-
test 'establish_connection defaults' do
|
24
|
-
TestObject.establish_connection(
|
25
|
-
keyspace: 'place_directory_development'
|
26
|
-
)
|
27
|
-
|
28
|
-
assert_equal ["127.0.0.1:9160"], TestObject.connection_config.servers
|
29
|
-
end
|
30
10
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CassandraObject::CoreTest < CassandraObject::TestCase
|
4
|
+
test 'initialiaze' do
|
5
|
+
issue = Issue.new
|
6
|
+
|
7
|
+
assert issue.new_record?
|
8
|
+
assert !issue.destroyed?
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'initialize yields self' do
|
12
|
+
issue = Issue.new { |i| i.description = 'bar' }
|
13
|
+
assert_equal 'bar', issue.description
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'dup' do
|
17
|
+
issue = Issue.create description: 'foo'
|
18
|
+
|
19
|
+
dup_issue = issue.dup
|
20
|
+
|
21
|
+
assert dup_issue.new_record?
|
22
|
+
assert_not_equal issue.id, dup_issue.id
|
23
|
+
assert_nil dup_issue.created_at
|
24
|
+
assert_nil dup_issue.updated_at
|
25
|
+
assert_equal 'foo', issue.description
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'equality of new records' do
|
29
|
+
assert_not_equal Issue.new, Issue.new
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'equality' do
|
33
|
+
first_issue = Issue.create
|
34
|
+
second_issue = Issue.create
|
35
|
+
|
36
|
+
assert_equal first_issue, first_issue
|
37
|
+
assert_equal first_issue, Issue.find(first_issue.id)
|
38
|
+
assert_not_equal first_issue, second_issue
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'to_param' do
|
42
|
+
issue = Issue.new
|
43
|
+
assert_equal issue.id, issue.to_param
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'hash' do
|
47
|
+
issue = Issue.create
|
48
|
+
assert_equal issue.id.hash, issue.hash
|
49
|
+
end
|
50
|
+
end
|
data/test/unit/identity_test.rb
CHANGED
data/test/unit/inspect_test.rb
CHANGED
@@ -5,7 +5,7 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
5
5
|
klass = temp_object do
|
6
6
|
string :description
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
assert_equal(
|
10
10
|
{},
|
11
11
|
klass.encode_attributes({})
|
@@ -65,6 +65,12 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
65
65
|
assert !issue.new_record?
|
66
66
|
end
|
67
67
|
|
68
|
+
test 'create' do
|
69
|
+
issue = Issue.create { |i| i.description = 'foo' }
|
70
|
+
assert_equal 'foo', issue.description
|
71
|
+
assert_equal 'foo', Issue.find(issue.id).description
|
72
|
+
end
|
73
|
+
|
68
74
|
test 'save' do
|
69
75
|
issue = Issue.new
|
70
76
|
issue.save
|
@@ -77,7 +83,7 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
77
83
|
string :description
|
78
84
|
validates :description, presence: true
|
79
85
|
end
|
80
|
-
|
86
|
+
|
81
87
|
record = klass.new(description: 'bad')
|
82
88
|
record.save!
|
83
89
|
|
@@ -90,7 +96,7 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
90
96
|
test 'destroy' do
|
91
97
|
issue = Issue.create
|
92
98
|
issue.destroy
|
93
|
-
|
99
|
+
|
94
100
|
assert issue.destroyed?
|
95
101
|
assert !issue.persisted?
|
96
102
|
assert !issue.new_record?
|
@@ -103,7 +109,7 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
103
109
|
assert !issue.changed?
|
104
110
|
assert_equal 'lol', issue.description
|
105
111
|
end
|
106
|
-
|
112
|
+
|
107
113
|
test 'update_attributes' do
|
108
114
|
issue = Issue.create
|
109
115
|
issue.update_attributes(description: 'lol')
|
@@ -118,7 +124,7 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
118
124
|
|
119
125
|
issue = Issue.new(description: 'bad')
|
120
126
|
issue.save!
|
121
|
-
|
127
|
+
|
122
128
|
assert_raise CassandraObject::RecordInvalid do
|
123
129
|
issue.update_attributes! description: ''
|
124
130
|
end
|
@@ -136,13 +142,21 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
136
142
|
assert_nil issue.title
|
137
143
|
end
|
138
144
|
|
145
|
+
test 'becomes' do
|
146
|
+
klass = temp_object do
|
147
|
+
end
|
148
|
+
|
149
|
+
assert_kind_of klass, Issue.new.becomes(klass)
|
150
|
+
end
|
151
|
+
|
139
152
|
test 'reload' do
|
140
153
|
persisted_issue = Issue.create
|
141
154
|
fresh_issue = Issue.find(persisted_issue.id)
|
142
155
|
fresh_issue.update_attribute(:description, 'say what')
|
143
156
|
|
144
|
-
persisted_issue.reload
|
157
|
+
reloaded_issue = persisted_issue.reload
|
145
158
|
assert_equal 'say what', persisted_issue.description
|
159
|
+
assert_equal persisted_issue, reloaded_issue
|
146
160
|
end
|
147
161
|
|
148
162
|
test 'delete with consistency' do
|
@@ -158,4 +172,19 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
|
|
158
172
|
end
|
159
173
|
end
|
160
174
|
|
161
|
-
|
175
|
+
test 'allow CQL keyword in column name' do
|
176
|
+
assert_nothing_raised do
|
177
|
+
Issue.string :text
|
178
|
+
issue = Issue.create :text => 'hello'
|
179
|
+
issue.text = 'world'
|
180
|
+
issue.save!
|
181
|
+
issue.text = nil
|
182
|
+
issue.save!
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
test 'quote_columns' do
|
187
|
+
klass = Class.new { include CassandraObject::Persistence }
|
188
|
+
assert_equal %w{'a' 'b'}, klass.__send__(:quote_columns, %w{a b})
|
189
|
+
end
|
190
|
+
end
|
@@ -6,30 +6,30 @@ class CassandraObject::SavepointsTest < CassandraObject::TestCase
|
|
6
6
|
issue = Issue.create description: 'foo'
|
7
7
|
raise 'lol'
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
assert_nil Issue.first
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
test 'rollback update' do
|
14
14
|
issue = Issue.create description: 'foo'
|
15
|
-
|
15
|
+
|
16
16
|
Issue.savepoint do
|
17
17
|
issue.update_attributes description: 'bar'
|
18
18
|
raise 'lol'
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
issue = Issue.find issue.id
|
22
22
|
assert_equal 'foo', issue.description
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'rollback destroy' do
|
26
26
|
issue = Issue.create description: 'foo'
|
27
|
-
|
27
|
+
|
28
28
|
Issue.savepoint do
|
29
29
|
issue.destroy
|
30
30
|
raise 'lol'
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
assert_nothing_raised { Issue.find issue.id }
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
data/test/unit/schema_test.rb
CHANGED
@@ -2,8 +2,8 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class CassandraObject::BatchesTest < CassandraObject::TestCase
|
4
4
|
test 'find_each' do
|
5
|
-
Issue.create
|
6
|
-
Issue.create
|
5
|
+
Issue.create
|
6
|
+
Issue.create
|
7
7
|
|
8
8
|
issues = []
|
9
9
|
Issue.find_each do |issue|
|
@@ -14,7 +14,7 @@ class CassandraObject::BatchesTest < CassandraObject::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'find_in_batches' do
|
17
|
-
Issue.create
|
17
|
+
Issue.create
|
18
18
|
Issue.create
|
19
19
|
Issue.create
|
20
20
|
|
@@ -27,4 +27,4 @@ class CassandraObject::BatchesTest < CassandraObject::TestCase
|
|
27
27
|
assert issue_batches.any? { |issues| issues.size == 2 }
|
28
28
|
assert issue_batches.any? { |issues| issues.size == 1 }
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
@@ -12,7 +12,7 @@ class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
|
|
12
12
|
rescue => e
|
13
13
|
assert_equal "Couldn't find Issue with key nil", e.message
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
assert_raise CassandraObject::RecordNotFound do
|
17
17
|
Issue.find('what')
|
18
18
|
end
|
@@ -45,7 +45,7 @@ class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
|
|
45
45
|
test 'first' do
|
46
46
|
first_issue = Issue.create
|
47
47
|
second_issue = Issue.create
|
48
|
-
|
48
|
+
|
49
49
|
assert [first_issue, second_issue].include?(Issue.first)
|
50
50
|
end
|
51
|
-
end
|
51
|
+
end
|
data/test/unit/scoping_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class CassandraObject::Types::ArrayTypeTest < CassandraObject::Types::TestCase
|
4
4
|
test 'encode' do
|
5
5
|
assert_equal ['1', '2'].to_json, coder.encode(['1', '2'])
|
6
|
-
|
6
|
+
|
7
7
|
assert_raise ArgumentError do
|
8
8
|
coder.encode('wtf')
|
9
9
|
end
|
@@ -49,10 +49,10 @@ class CassandraObject::Types::ArrayTypeTest < CassandraObject::Types::TestCase
|
|
49
49
|
|
50
50
|
test 'unique array uniquifies' do
|
51
51
|
issue = TestIssue.create favorite_colors: ['blue', 'red']
|
52
|
-
|
52
|
+
|
53
53
|
issue.favorite_colors = ['red', 'red', 'blue']
|
54
54
|
assert !issue.changed?
|
55
|
-
|
55
|
+
|
56
56
|
issue.favorite_colors = ['red', 'green']
|
57
57
|
assert issue.changed?
|
58
58
|
end
|
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class CassandraObject::Types::FloatTypeTest < CassandraObject::Types::TestCase
|
4
4
|
test 'encode' do
|
5
5
|
assert_equal '5.01', coder.encode(5.01)
|
6
|
-
|
6
|
+
|
7
7
|
assert_raise ArgumentError do
|
8
8
|
coder.encode('x')
|
9
9
|
end
|
@@ -17,4 +17,4 @@ class CassandraObject::Types::FloatTypeTest < CassandraObject::Types::TestCase
|
|
17
17
|
coder.decode('xyz')
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotime-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -103,8 +103,10 @@ files:
|
|
103
103
|
- lib/cassandra_object/belongs_to/builder.rb
|
104
104
|
- lib/cassandra_object/belongs_to/reflection.rb
|
105
105
|
- lib/cassandra_object/callbacks.rb
|
106
|
+
- lib/cassandra_object/config.rb
|
106
107
|
- lib/cassandra_object/connection.rb
|
107
108
|
- lib/cassandra_object/consistency.rb
|
109
|
+
- lib/cassandra_object/core.rb
|
108
110
|
- lib/cassandra_object/errors.rb
|
109
111
|
- lib/cassandra_object/identity.rb
|
110
112
|
- lib/cassandra_object/inspect.rb
|
@@ -146,10 +148,13 @@ files:
|
|
146
148
|
- test/unit/attribute_methods/typecasting_test.rb
|
147
149
|
- test/unit/attribute_methods_test.rb
|
148
150
|
- test/unit/base_test.rb
|
151
|
+
- test/unit/belongs_to/reflection_test.rb
|
149
152
|
- test/unit/belongs_to_test.rb
|
150
153
|
- test/unit/callbacks_test.rb
|
154
|
+
- test/unit/config_test.rb
|
151
155
|
- test/unit/connection_test.rb
|
152
156
|
- test/unit/consistency_test.rb
|
157
|
+
- test/unit/core_test.rb
|
153
158
|
- test/unit/identity_test.rb
|
154
159
|
- test/unit/inspect_test.rb
|
155
160
|
- test/unit/log_subscriber_test.rb
|