datastax_rails 2.0.12 → 2.0.15
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.
- checksums.yaml +4 -4
- data/Rakefile +5 -5
- data/lib/blankslate.rb +8 -11
- data/lib/cql-rb_extensions.rb +5 -3
- data/lib/datastax_rails/associations/association.rb +93 -101
- data/lib/datastax_rails/associations/association_scope.rb +7 -7
- data/lib/datastax_rails/associations/belongs_to_association.rb +46 -48
- data/lib/datastax_rails/associations/builder/association.rb +32 -31
- data/lib/datastax_rails/associations/builder/belongs_to.rb +19 -20
- data/lib/datastax_rails/associations/builder/collection_association.rb +32 -32
- data/lib/datastax_rails/associations/builder/has_and_belongs_to_many.rb +21 -21
- data/lib/datastax_rails/associations/builder/has_many.rb +39 -40
- data/lib/datastax_rails/associations/builder/has_one.rb +30 -31
- data/lib/datastax_rails/associations/builder/singular_association.rb +31 -33
- data/lib/datastax_rails/associations/collection_association.rb +129 -135
- data/lib/datastax_rails/associations/collection_proxy.rb +21 -21
- data/lib/datastax_rails/associations/has_and_belongs_to_many_association.rb +26 -26
- data/lib/datastax_rails/associations/has_many_association.rb +38 -38
- data/lib/datastax_rails/associations/has_one_association.rb +31 -32
- data/lib/datastax_rails/associations/singular_association.rb +31 -30
- data/lib/datastax_rails/associations.rb +27 -24
- data/lib/datastax_rails/attribute_assignment.rb +17 -17
- data/lib/datastax_rails/attribute_methods/definition.rb +4 -4
- data/lib/datastax_rails/attribute_methods/dirty.rb +34 -33
- data/lib/datastax_rails/attribute_methods/primary_key.rb +3 -8
- data/lib/datastax_rails/attribute_methods/read.rb +10 -12
- data/lib/datastax_rails/attribute_methods/typecasting.rb +36 -35
- data/lib/datastax_rails/attribute_methods/write.rb +5 -6
- data/lib/datastax_rails/attribute_methods.rb +52 -56
- data/lib/datastax_rails/base.rb +122 -125
- data/lib/datastax_rails/callbacks.rb +15 -9
- data/lib/datastax_rails/cassandra_only_model.rb +6 -6
- data/lib/datastax_rails/collection.rb +5 -7
- data/lib/datastax_rails/column.rb +130 -118
- data/lib/datastax_rails/connection/statement_cache.rb +3 -3
- data/lib/datastax_rails/connection.rb +42 -33
- data/lib/datastax_rails/cql/alter_column_family.rb +19 -21
- data/lib/datastax_rails/cql/base.rb +8 -11
- data/lib/datastax_rails/cql/column_family.rb +11 -10
- data/lib/datastax_rails/cql/consistency.rb +2 -2
- data/lib/datastax_rails/cql/create_column_family.rb +15 -15
- data/lib/datastax_rails/cql/create_index.rb +5 -5
- data/lib/datastax_rails/cql/create_keyspace.rb +7 -7
- data/lib/datastax_rails/cql/delete.rb +16 -29
- data/lib/datastax_rails/cql/drop_column_family.rb +2 -2
- data/lib/datastax_rails/cql/drop_index.rb +2 -2
- data/lib/datastax_rails/cql/drop_keyspace.rb +2 -2
- data/lib/datastax_rails/cql/insert.rb +10 -16
- data/lib/datastax_rails/cql/select.rb +21 -33
- data/lib/datastax_rails/cql/truncate.rb +2 -2
- data/lib/datastax_rails/cql/update.rb +16 -24
- data/lib/datastax_rails/cql/use_keyspace.rb +2 -2
- data/lib/datastax_rails/cql.rb +2 -2
- data/lib/datastax_rails/dynamic_model.rb +32 -29
- data/lib/datastax_rails/errors.rb +6 -6
- data/lib/datastax_rails/grouped_collection.rb +3 -3
- data/lib/datastax_rails/inheritance.rb +9 -9
- data/lib/datastax_rails/payload_model.rb +24 -20
- data/lib/datastax_rails/persistence.rb +116 -110
- data/lib/datastax_rails/railtie.rb +7 -7
- data/lib/datastax_rails/reflection.rb +61 -59
- data/lib/datastax_rails/relation/batches.rb +12 -13
- data/lib/datastax_rails/relation/facet_methods.rb +44 -33
- data/lib/datastax_rails/relation/finder_methods.rb +95 -91
- data/lib/datastax_rails/relation/modification_methods.rb +5 -5
- data/lib/datastax_rails/relation/search_methods.rb +102 -102
- data/lib/datastax_rails/relation/spawn_methods.rb +25 -24
- data/lib/datastax_rails/relation/stats_methods.rb +9 -8
- data/lib/datastax_rails/relation.rb +165 -170
- data/lib/datastax_rails/rsolr_client_wrapper.rb +3 -3
- data/lib/datastax_rails/schema/cassandra.rb +44 -43
- data/lib/datastax_rails/schema/migrator.rb +52 -52
- data/lib/datastax_rails/schema/solr.rb +55 -47
- data/lib/datastax_rails/schema_cache.rb +1 -3
- data/lib/datastax_rails/scoping/default.rb +2 -3
- data/lib/datastax_rails/scoping/named.rb +3 -5
- data/lib/datastax_rails/scoping.rb +11 -12
- data/lib/datastax_rails/serialization.rb +34 -31
- data/lib/datastax_rails/serializers/xml_serializer.rb +178 -175
- data/lib/datastax_rails/timestamps.rb +4 -4
- data/lib/datastax_rails/types/dirty_collection.rb +57 -57
- data/lib/datastax_rails/types/dynamic_list.rb +1 -1
- data/lib/datastax_rails/types/dynamic_map.rb +5 -7
- data/lib/datastax_rails/types/dynamic_set.rb +2 -2
- data/lib/datastax_rails/util/solr_repair.rb +3 -3
- data/lib/datastax_rails/validations/associated.rb +8 -6
- data/lib/datastax_rails/validations/uniqueness.rb +8 -8
- data/lib/datastax_rails/validations.rb +9 -10
- data/lib/datastax_rails/version.rb +2 -1
- data/lib/datastax_rails/wide_storage_model.rb +6 -6
- data/lib/datastax_rails.rb +13 -9
- data/lib/schema_migration.rb +3 -3
- data/spec/datastax_rails/associations/belongs_to_association_spec.rb +2 -2
- data/spec/datastax_rails/associations/collection_association_spec.rb +14 -14
- data/spec/datastax_rails/associations/has_many_association_spec.rb +20 -20
- data/spec/datastax_rails/associations_spec.rb +11 -11
- data/spec/datastax_rails/attribute_methods_spec.rb +25 -25
- data/spec/datastax_rails/base_spec.rb +24 -24
- data/spec/datastax_rails/callbacks_spec.rb +21 -21
- data/spec/datastax_rails/column_spec.rb +133 -132
- data/spec/datastax_rails/connection/statement_cache_spec.rb +2 -2
- data/spec/datastax_rails/cql/base_spec.rb +4 -4
- data/spec/datastax_rails/cql/delete_spec.rb +19 -0
- data/spec/datastax_rails/cql/select_spec.rb +8 -8
- data/spec/datastax_rails/cql/update_spec.rb +8 -10
- data/spec/datastax_rails/dynamic_model_spec.rb +36 -22
- data/spec/datastax_rails/inheritance_spec.rb +11 -14
- data/spec/datastax_rails/persistence_spec.rb +73 -74
- data/spec/datastax_rails/relation/batches_spec.rb +13 -13
- data/spec/datastax_rails/relation/facet_methods_spec.rb +43 -35
- data/spec/datastax_rails/relation/finder_methods_spec.rb +77 -78
- data/spec/datastax_rails/relation/modification_methods_spec.rb +19 -19
- data/spec/datastax_rails/relation/search_methods_spec.rb +160 -160
- data/spec/datastax_rails/relation/spawn_methods_spec.rb +18 -18
- data/spec/datastax_rails/relation_spec.rb +119 -116
- data/spec/datastax_rails/schema/migrator_spec.rb +30 -30
- data/spec/datastax_rails/schema/solr_spec.rb +15 -15
- data/spec/datastax_rails/scoping/default_spec.rb +9 -9
- data/spec/datastax_rails/types/dynamic_list_spec.rb +12 -12
- data/spec/datastax_rails/types/dynamic_map_spec.rb +10 -10
- data/spec/datastax_rails/types/dynamic_set_spec.rb +22 -10
- data/spec/datastax_rails/validations/uniqueness_spec.rb +25 -25
- data/spec/datastax_rails/wide_storage_model_spec.rb +11 -0
- data/spec/datastax_rails_spec.rb +2 -2
- data/spec/dummy/config/application.rb +2 -3
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/development.rb +3 -3
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/factories/audit_logs.rb +6 -0
- data/spec/factories/hobbies.rb +6 -0
- data/spec/factories/people.rb +5 -0
- data/spec/feature/dynamic_fields_spec.rb +4 -4
- data/spec/feature/overloaded_tables_spec.rb +11 -12
- data/spec/spec_helper.rb +17 -14
- data/spec/support/datastax_test_hook.rb +2 -2
- data/spec/support/default_consistency_shared_examples.rb +11 -11
- data/spec/support/models.rb +31 -32
- metadata +40 -6
- data/lib/datastax_rails/attribute_methods/before_type_cast.rb +0 -71
- data/lib/datastax_rails/log_subscriber.rb +0 -0
- data/spec/dummy/ks/migrate/20111117224534_models.rb +0 -20
@@ -2,27 +2,27 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe DatastaxRails::Relation do
|
4
4
|
before(:each) do
|
5
|
-
@relation = DatastaxRails::Relation.new(Hobby,
|
5
|
+
@relation = DatastaxRails::Relation.new(Hobby, 'hobbies')
|
6
6
|
end
|
7
|
-
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
r1 = @relation.where(
|
11
|
-
r2 = @relation.order(
|
12
|
-
r1.merge(r2).
|
7
|
+
|
8
|
+
describe '#merge' do
|
9
|
+
it 'should merge two relations' do
|
10
|
+
r1 = @relation.where('name' => 'biking')
|
11
|
+
r2 = @relation.order('name' => :desc)
|
12
|
+
expect(r1.merge(r2)).to eq(@relation.where('name' => 'biking').order('name' => :desc))
|
13
13
|
end
|
14
|
-
|
15
|
-
it
|
16
|
-
r1 = @relation.where(
|
17
|
-
r2 = @relation.where(
|
18
|
-
r1.merge(r2).where_values.
|
14
|
+
|
15
|
+
it 'should merge where conditions into a single hash' do
|
16
|
+
r1 = @relation.where('name' => 'biking')
|
17
|
+
r2 = @relation.where('complexity' => 1.0)
|
18
|
+
expect(r1.merge(r2).where_values).to eq([{ 'name' => 'biking', 'complexity' => 1.0 }])
|
19
19
|
end
|
20
|
-
|
21
|
-
it
|
22
|
-
r1 = @relation.where(
|
23
|
-
r2 = @relation.where(
|
24
|
-
r1.merge(r2).where_values.
|
25
|
-
r2.merge(r1).where_values.
|
20
|
+
|
21
|
+
it 'should overwrite conditions on the same attribute' do
|
22
|
+
r1 = @relation.where('name' => 'biking')
|
23
|
+
r2 = @relation.where('name' => 'swimming')
|
24
|
+
expect(r1.merge(r2).where_values).to eq([{ 'name' => 'swimming' }])
|
25
|
+
expect(r2.merge(r1).where_values).to eq([{ 'name' => 'biking' }])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -2,175 +2,178 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe DatastaxRails::Relation do
|
4
4
|
before(:each) do
|
5
|
-
@relation = DatastaxRails::Relation.new(Hobby,
|
5
|
+
@relation = DatastaxRails::Relation.new(Hobby, 'hobbies')
|
6
6
|
@relation.default_scoped = true
|
7
7
|
@relation.commit_solr
|
8
8
|
end
|
9
|
-
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
@relation.where(
|
9
|
+
|
10
|
+
describe '#==' do
|
11
|
+
it 'should count two relations with the same parameters as equal' do
|
12
|
+
expect(@relation.where('name' => 'jason')).to eq(@relation.where('name' => 'jason'))
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
|
-
describe
|
17
|
-
it
|
18
|
-
Hobby.create(:
|
15
|
+
|
16
|
+
describe '#any?' do
|
17
|
+
it 'should return true if there are records' do
|
18
|
+
Hobby.create(name: 'fishing')
|
19
19
|
@relation.commit_solr
|
20
|
-
@relation.any
|
20
|
+
expect(@relation.any?).to be_truthy
|
21
21
|
end
|
22
|
-
|
23
|
-
it
|
24
|
-
@relation.any
|
22
|
+
|
23
|
+
it 'should return false if there are no records' do
|
24
|
+
expect(@relation.any?).to be_falsey
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
describe
|
29
|
-
it
|
27
|
+
|
28
|
+
describe '#count' do
|
29
|
+
it 'should use the cached count if it is available' do
|
30
30
|
@relation.instance_variable_set(:@count, 42)
|
31
|
-
@relation.count.
|
31
|
+
expect(@relation.count).to eq(42)
|
32
32
|
end
|
33
|
-
|
34
|
-
it
|
33
|
+
|
34
|
+
it 'should cache the total count on any solr query' do
|
35
35
|
@relation = @relation.with_solr
|
36
|
-
@relation.
|
36
|
+
expect(@relation).to receive(:query_via_solr).and_return(double('ResultSet', total_entries: 42))
|
37
37
|
@relation.all
|
38
|
-
@relation.count.
|
38
|
+
expect(@relation.count).to eq(42)
|
39
39
|
end
|
40
|
-
|
41
|
-
it
|
40
|
+
|
41
|
+
it 'should execute a fast search to determine the count' do
|
42
42
|
mock_relation = double(DatastaxRails::Relation)
|
43
|
-
mock_relation.
|
43
|
+
allow(mock_relation).to receive_message_chain(:select, :to_a, :total_entries).and_return(37)
|
44
44
|
@relation = @relation.with_solr
|
45
|
-
@relation.
|
46
|
-
@relation.count.
|
47
|
-
end
|
48
|
-
|
49
|
-
it
|
50
|
-
Hobby.create(:
|
51
|
-
Hobby.create(:
|
52
|
-
Hobby.create(:
|
53
|
-
Hobby.create(:
|
45
|
+
expect(@relation).to receive(:limit).with(1).and_return(mock_relation)
|
46
|
+
expect(@relation.count).to eq(37)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return the count regardless of limit' do
|
50
|
+
Hobby.create(name: 'hiking')
|
51
|
+
Hobby.create(name: 'boxing')
|
52
|
+
Hobby.create(name: 'fishing')
|
53
|
+
Hobby.create(name: 'running')
|
54
54
|
@relation.commit_solr
|
55
|
-
@relation.count.
|
56
|
-
|
57
|
-
@relation.limit(2).count.
|
55
|
+
expect(@relation.count).to eq(4)
|
56
|
+
|
57
|
+
expect(@relation.limit(2).count).to eq(4)
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
|
-
describe
|
62
|
-
it
|
63
|
-
Hobby.create(:
|
60
|
+
|
61
|
+
describe '#default_scope' do
|
62
|
+
it 'should return a relation that has no scope set' do
|
63
|
+
Hobby.create(name: 'fishing')
|
64
64
|
@relation.commit_solr
|
65
|
-
relation = @relation.where(
|
66
|
-
relation.count.
|
67
|
-
relation.default_scope.count.
|
65
|
+
relation = @relation.where('name' => 'hiking')
|
66
|
+
expect(relation.count).to eq(0)
|
67
|
+
expect(relation.default_scope.count).to eq(1)
|
68
68
|
end
|
69
|
-
|
70
|
-
it
|
71
|
-
relation = DatastaxRails::Relation.new(Boat,
|
69
|
+
|
70
|
+
it 'should return a relation that has a default scope set' do
|
71
|
+
relation = DatastaxRails::Relation.new(Boat, 'boats')
|
72
72
|
relation.default_scoped = true
|
73
|
-
relation.default_scope.order_values.
|
73
|
+
expect(relation.default_scope.order_values).not_to be_empty
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
77
|
-
describe
|
78
|
-
it
|
79
|
-
a_record =
|
80
|
-
@relation.
|
76
|
+
|
77
|
+
describe '#empty?' do
|
78
|
+
it 'should use the loaded result set to determine emptiness' do
|
79
|
+
a_record = build_stubbed(:hobby)
|
80
|
+
allow(@relation).to receive(:loaded?).and_return(true)
|
81
81
|
@relation.instance_variable_set(:@results, [])
|
82
|
-
@relation.
|
82
|
+
expect(@relation).to be_empty
|
83
83
|
@relation.instance_variable_set(:@results, [a_record])
|
84
|
-
@relation.
|
84
|
+
expect(@relation).not_to be_empty
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
88
|
-
describe
|
89
|
-
it
|
90
|
-
Hobby.create(:
|
91
|
-
Hobby.create(:
|
87
|
+
|
88
|
+
describe '#many?' do
|
89
|
+
it 'should return true if there are multiple records matching' do
|
90
|
+
Hobby.create(name: 'hiking')
|
91
|
+
Hobby.create(name: 'swimming')
|
92
92
|
@relation.commit_solr
|
93
|
-
@relation.
|
93
|
+
expect(@relation).to be_many
|
94
94
|
end
|
95
|
-
|
96
|
-
it
|
97
|
-
@relation.
|
98
|
-
Hobby.create(:
|
99
|
-
@relation.
|
95
|
+
|
96
|
+
it 'should return false if there are zero or one records matching' do
|
97
|
+
expect(@relation).not_to be_many
|
98
|
+
Hobby.create(name: 'hiking')
|
99
|
+
expect(@relation).not_to be_many
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
103
|
-
describe
|
104
|
-
it
|
105
|
-
hiking = @relation.new(:
|
106
|
-
hiking.
|
107
|
-
hiking.name.
|
102
|
+
|
103
|
+
describe '#new' do
|
104
|
+
it 'should instantiate a new instance of the class' do
|
105
|
+
hiking = @relation.new(name: 'hiking')
|
106
|
+
expect(hiking).to be_a_kind_of(Hobby)
|
107
|
+
expect(hiking.name).to eq('hiking')
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
111
|
-
describe
|
112
|
-
it
|
113
|
-
@relation.all.
|
114
|
-
Hobby.create(:
|
110
|
+
|
111
|
+
describe '#reload' do
|
112
|
+
it 'should reload the results' do
|
113
|
+
expect(@relation.all).to be_empty
|
114
|
+
Hobby.create(name: 'hiking')
|
115
115
|
@relation.commit_solr
|
116
|
-
@relation.all.
|
117
|
-
@relation.reload.all.
|
116
|
+
expect(@relation.all).to be_empty
|
117
|
+
expect(@relation.reload.all).not_to be_empty
|
118
118
|
end
|
119
119
|
end
|
120
|
-
|
121
|
-
describe
|
122
|
-
it
|
123
|
-
Hobby.create(:
|
124
|
-
Hobby.create(:
|
125
|
-
Hobby.create(:
|
126
|
-
Hobby.create(:
|
120
|
+
|
121
|
+
describe '#size' do
|
122
|
+
it 'should return the size of the current result set (including limit setting)' do
|
123
|
+
Hobby.create(name: 'hiking')
|
124
|
+
Hobby.create(name: 'boxing')
|
125
|
+
Hobby.create(name: 'fishing')
|
126
|
+
Hobby.create(name: 'running')
|
127
127
|
@relation.commit_solr
|
128
|
-
@relation.size.
|
129
|
-
@relation.limit(2).size.
|
128
|
+
expect(@relation.size).to eq(4)
|
129
|
+
expect(@relation.limit(2).size).to eq(2)
|
130
130
|
end
|
131
131
|
end
|
132
|
-
|
133
|
-
describe
|
134
|
-
it
|
132
|
+
|
133
|
+
describe '#total_pages' do
|
134
|
+
it 'should calculate the total number of pages for will_paginate' do
|
135
135
|
relation = @relation.per_page(30)
|
136
|
-
relation.
|
137
|
-
relation.total_pages.
|
136
|
+
allow(relation).to receive(:count).and_return(100)
|
137
|
+
expect(relation.total_pages).to eq(4)
|
138
138
|
end
|
139
139
|
end
|
140
|
-
|
141
|
-
describe
|
140
|
+
|
141
|
+
describe 'grouped queries' do
|
142
142
|
before(:each) do
|
143
143
|
Person.commit_solr
|
144
|
-
Person.create(:
|
145
|
-
Person.create(:
|
146
|
-
Person.create(:
|
147
|
-
Person.create(:
|
148
|
-
Person.create(:
|
149
|
-
Person.create(:
|
144
|
+
Person.create(name: 'John', nickname: 'J')
|
145
|
+
Person.create(name: 'Jason', nickname: 'J')
|
146
|
+
Person.create(name: 'James', nickname: 'J')
|
147
|
+
Person.create(name: 'Kathrine', nickname: 'Kat')
|
148
|
+
Person.create(name: 'Kathy', nickname: 'Kat')
|
149
|
+
Person.create(name: 'Steven', nickname: 'Steve')
|
150
150
|
Person.commit_solr
|
151
151
|
end
|
152
|
-
|
153
|
-
it
|
152
|
+
|
153
|
+
it 'should return matching documents grouped by an attribute' do
|
154
154
|
results = Person.group(:nickname).all
|
155
|
-
results['j'].
|
156
|
-
results['kat'].
|
157
|
-
results['steve'].
|
155
|
+
expect(results['j'].size).to eq(3)
|
156
|
+
expect(results['kat'].size).to eq(2)
|
157
|
+
expect(results['steve'].size).to eq(1)
|
158
158
|
end
|
159
|
-
|
160
|
-
it
|
159
|
+
|
160
|
+
it 'should return total_entries as the highest value of any group' do
|
161
161
|
results = Person.group(:nickname).all
|
162
|
-
results.total_entries.
|
162
|
+
expect(results.total_entries).to eq(3)
|
163
163
|
end
|
164
|
-
|
165
|
-
it
|
166
|
-
|
164
|
+
|
165
|
+
it 'should still return a total count when using the count method' do
|
166
|
+
expect(Person.group(:nickname).count).to eq(6)
|
167
167
|
end
|
168
168
|
end
|
169
|
-
|
170
|
-
describe
|
171
|
-
it
|
172
|
-
solr_query =
|
173
|
-
|
169
|
+
|
170
|
+
describe '#downcase_query' do
|
171
|
+
it 'downcases a solr query while leaving operators untouched' do
|
172
|
+
solr_query = 'This Query needs to be DOWNCASED AND it also searches DATES ' \
|
173
|
+
'[2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] OR maybe it just breaks'
|
174
|
+
expect(@relation.downcase_query(solr_query)).to eq('this query needs to be downcased AND it also searches ' \
|
175
|
+
'dates [2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] ' \
|
176
|
+
'OR maybe it just breaks')
|
174
177
|
end
|
175
178
|
end
|
176
179
|
end
|
@@ -2,83 +2,83 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe DatastaxRails::Schema::Migrator do
|
4
4
|
subject do
|
5
|
-
DatastaxRails::Schema::Migrator.new('datastax_rails_test').tap{|m| m.verbose = false}
|
5
|
+
DatastaxRails::Schema::Migrator.new('datastax_rails_test').tap { |m| m.verbose = false }
|
6
6
|
end
|
7
7
|
|
8
8
|
describe 'payload models' do
|
9
9
|
context 'when column family exists' do
|
10
10
|
before(:each) do
|
11
|
-
subject.
|
11
|
+
allow(subject).to receive(:column_family_exists?).and_return(false)
|
12
12
|
end
|
13
|
-
|
14
|
-
it
|
13
|
+
|
14
|
+
it 'calls #create_payload_column_family' do
|
15
15
|
expect(subject).to receive(:create_cql3_column_family).with(CarPayload)
|
16
16
|
subject.migrate_one(CarPayload)
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
context 'when column family exists' do
|
21
21
|
before(:each) do
|
22
|
-
subject.
|
22
|
+
allow(subject).to receive(:column_family_exists?).and_return(true)
|
23
23
|
end
|
24
|
-
|
25
|
-
it
|
24
|
+
|
25
|
+
it 'does not call #create_payload_column_family' do
|
26
26
|
expect(subject).not_to receive(:create_cql2_column_family).with(CarPayload)
|
27
27
|
subject.migrate_one(CarPayload)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
describe 'wide storage models' do
|
33
33
|
context 'when column family does not exist' do
|
34
34
|
before(:each) do
|
35
|
-
subject.
|
36
|
-
subject.
|
35
|
+
allow(subject).to receive(:column_family_exists?).and_return(false)
|
36
|
+
allow(subject).to receive(:create_cql3_column_family)
|
37
37
|
end
|
38
|
-
|
39
|
-
it
|
38
|
+
|
39
|
+
it 'calls #create_wide_storage_column_family' do
|
40
40
|
expect(subject).to receive(:create_cql3_column_family).with(AuditLog)
|
41
41
|
subject.migrate_one(AuditLog)
|
42
42
|
end
|
43
|
-
|
44
|
-
it
|
43
|
+
|
44
|
+
it 'calls #check_missing_schema' do
|
45
45
|
expect(subject).to receive(:check_missing_schema).with(AuditLog).and_return(0)
|
46
46
|
subject.migrate_one(AuditLog)
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
context 'when column family exists' do
|
51
51
|
before(:each) do
|
52
|
-
subject.
|
52
|
+
allow(subject).to receive(:column_family_exists?).and_return(true)
|
53
53
|
end
|
54
|
-
|
55
|
-
it
|
54
|
+
|
55
|
+
it 'does not call #create_wide_storage_column_family' do
|
56
56
|
expect(subject).not_to receive(:create_cql3_column_family).with(AuditLog)
|
57
57
|
subject.migrate_one(AuditLog)
|
58
58
|
end
|
59
|
-
|
60
|
-
it
|
59
|
+
|
60
|
+
it 'calls #check_missing_schema' do
|
61
61
|
expect(subject).to receive(:check_missing_schema).with(AuditLog).and_return(0)
|
62
62
|
subject.migrate_one(AuditLog)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
67
|
-
describe 'normal models' do
|
68
|
-
it
|
66
|
+
|
67
|
+
describe 'normal models' do
|
68
|
+
it 'calls #check_missing_schema' do
|
69
69
|
expect(subject).to receive(:check_missing_schema).with(Person).and_return(0)
|
70
70
|
subject.migrate_one(Person)
|
71
71
|
end
|
72
|
-
|
73
|
-
context
|
74
|
-
it
|
72
|
+
|
73
|
+
context 'force mode on' do
|
74
|
+
it 'calls #upload_solr_configuation with force true' do
|
75
75
|
expect(subject).to receive(:upload_solr_configuration).with(Person, true).and_return(0)
|
76
76
|
subject.migrate_one(Person, true)
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
context
|
81
|
-
it
|
79
|
+
|
80
|
+
context 'force mode off' do
|
81
|
+
it 'calls #upload_solr_configuation with force false' do
|
82
82
|
expect(subject).to receive(:upload_solr_configuration).with(Person, false).and_return(0)
|
83
83
|
subject.migrate_one(Person, false)
|
84
84
|
end
|