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.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -5
  3. data/lib/blankslate.rb +8 -11
  4. data/lib/cql-rb_extensions.rb +5 -3
  5. data/lib/datastax_rails/associations/association.rb +93 -101
  6. data/lib/datastax_rails/associations/association_scope.rb +7 -7
  7. data/lib/datastax_rails/associations/belongs_to_association.rb +46 -48
  8. data/lib/datastax_rails/associations/builder/association.rb +32 -31
  9. data/lib/datastax_rails/associations/builder/belongs_to.rb +19 -20
  10. data/lib/datastax_rails/associations/builder/collection_association.rb +32 -32
  11. data/lib/datastax_rails/associations/builder/has_and_belongs_to_many.rb +21 -21
  12. data/lib/datastax_rails/associations/builder/has_many.rb +39 -40
  13. data/lib/datastax_rails/associations/builder/has_one.rb +30 -31
  14. data/lib/datastax_rails/associations/builder/singular_association.rb +31 -33
  15. data/lib/datastax_rails/associations/collection_association.rb +129 -135
  16. data/lib/datastax_rails/associations/collection_proxy.rb +21 -21
  17. data/lib/datastax_rails/associations/has_and_belongs_to_many_association.rb +26 -26
  18. data/lib/datastax_rails/associations/has_many_association.rb +38 -38
  19. data/lib/datastax_rails/associations/has_one_association.rb +31 -32
  20. data/lib/datastax_rails/associations/singular_association.rb +31 -30
  21. data/lib/datastax_rails/associations.rb +27 -24
  22. data/lib/datastax_rails/attribute_assignment.rb +17 -17
  23. data/lib/datastax_rails/attribute_methods/definition.rb +4 -4
  24. data/lib/datastax_rails/attribute_methods/dirty.rb +34 -33
  25. data/lib/datastax_rails/attribute_methods/primary_key.rb +3 -8
  26. data/lib/datastax_rails/attribute_methods/read.rb +10 -12
  27. data/lib/datastax_rails/attribute_methods/typecasting.rb +36 -35
  28. data/lib/datastax_rails/attribute_methods/write.rb +5 -6
  29. data/lib/datastax_rails/attribute_methods.rb +52 -56
  30. data/lib/datastax_rails/base.rb +122 -125
  31. data/lib/datastax_rails/callbacks.rb +15 -9
  32. data/lib/datastax_rails/cassandra_only_model.rb +6 -6
  33. data/lib/datastax_rails/collection.rb +5 -7
  34. data/lib/datastax_rails/column.rb +130 -118
  35. data/lib/datastax_rails/connection/statement_cache.rb +3 -3
  36. data/lib/datastax_rails/connection.rb +42 -33
  37. data/lib/datastax_rails/cql/alter_column_family.rb +19 -21
  38. data/lib/datastax_rails/cql/base.rb +8 -11
  39. data/lib/datastax_rails/cql/column_family.rb +11 -10
  40. data/lib/datastax_rails/cql/consistency.rb +2 -2
  41. data/lib/datastax_rails/cql/create_column_family.rb +15 -15
  42. data/lib/datastax_rails/cql/create_index.rb +5 -5
  43. data/lib/datastax_rails/cql/create_keyspace.rb +7 -7
  44. data/lib/datastax_rails/cql/delete.rb +16 -29
  45. data/lib/datastax_rails/cql/drop_column_family.rb +2 -2
  46. data/lib/datastax_rails/cql/drop_index.rb +2 -2
  47. data/lib/datastax_rails/cql/drop_keyspace.rb +2 -2
  48. data/lib/datastax_rails/cql/insert.rb +10 -16
  49. data/lib/datastax_rails/cql/select.rb +21 -33
  50. data/lib/datastax_rails/cql/truncate.rb +2 -2
  51. data/lib/datastax_rails/cql/update.rb +16 -24
  52. data/lib/datastax_rails/cql/use_keyspace.rb +2 -2
  53. data/lib/datastax_rails/cql.rb +2 -2
  54. data/lib/datastax_rails/dynamic_model.rb +32 -29
  55. data/lib/datastax_rails/errors.rb +6 -6
  56. data/lib/datastax_rails/grouped_collection.rb +3 -3
  57. data/lib/datastax_rails/inheritance.rb +9 -9
  58. data/lib/datastax_rails/payload_model.rb +24 -20
  59. data/lib/datastax_rails/persistence.rb +116 -110
  60. data/lib/datastax_rails/railtie.rb +7 -7
  61. data/lib/datastax_rails/reflection.rb +61 -59
  62. data/lib/datastax_rails/relation/batches.rb +12 -13
  63. data/lib/datastax_rails/relation/facet_methods.rb +44 -33
  64. data/lib/datastax_rails/relation/finder_methods.rb +95 -91
  65. data/lib/datastax_rails/relation/modification_methods.rb +5 -5
  66. data/lib/datastax_rails/relation/search_methods.rb +102 -102
  67. data/lib/datastax_rails/relation/spawn_methods.rb +25 -24
  68. data/lib/datastax_rails/relation/stats_methods.rb +9 -8
  69. data/lib/datastax_rails/relation.rb +165 -170
  70. data/lib/datastax_rails/rsolr_client_wrapper.rb +3 -3
  71. data/lib/datastax_rails/schema/cassandra.rb +44 -43
  72. data/lib/datastax_rails/schema/migrator.rb +52 -52
  73. data/lib/datastax_rails/schema/solr.rb +55 -47
  74. data/lib/datastax_rails/schema_cache.rb +1 -3
  75. data/lib/datastax_rails/scoping/default.rb +2 -3
  76. data/lib/datastax_rails/scoping/named.rb +3 -5
  77. data/lib/datastax_rails/scoping.rb +11 -12
  78. data/lib/datastax_rails/serialization.rb +34 -31
  79. data/lib/datastax_rails/serializers/xml_serializer.rb +178 -175
  80. data/lib/datastax_rails/timestamps.rb +4 -4
  81. data/lib/datastax_rails/types/dirty_collection.rb +57 -57
  82. data/lib/datastax_rails/types/dynamic_list.rb +1 -1
  83. data/lib/datastax_rails/types/dynamic_map.rb +5 -7
  84. data/lib/datastax_rails/types/dynamic_set.rb +2 -2
  85. data/lib/datastax_rails/util/solr_repair.rb +3 -3
  86. data/lib/datastax_rails/validations/associated.rb +8 -6
  87. data/lib/datastax_rails/validations/uniqueness.rb +8 -8
  88. data/lib/datastax_rails/validations.rb +9 -10
  89. data/lib/datastax_rails/version.rb +2 -1
  90. data/lib/datastax_rails/wide_storage_model.rb +6 -6
  91. data/lib/datastax_rails.rb +13 -9
  92. data/lib/schema_migration.rb +3 -3
  93. data/spec/datastax_rails/associations/belongs_to_association_spec.rb +2 -2
  94. data/spec/datastax_rails/associations/collection_association_spec.rb +14 -14
  95. data/spec/datastax_rails/associations/has_many_association_spec.rb +20 -20
  96. data/spec/datastax_rails/associations_spec.rb +11 -11
  97. data/spec/datastax_rails/attribute_methods_spec.rb +25 -25
  98. data/spec/datastax_rails/base_spec.rb +24 -24
  99. data/spec/datastax_rails/callbacks_spec.rb +21 -21
  100. data/spec/datastax_rails/column_spec.rb +133 -132
  101. data/spec/datastax_rails/connection/statement_cache_spec.rb +2 -2
  102. data/spec/datastax_rails/cql/base_spec.rb +4 -4
  103. data/spec/datastax_rails/cql/delete_spec.rb +19 -0
  104. data/spec/datastax_rails/cql/select_spec.rb +8 -8
  105. data/spec/datastax_rails/cql/update_spec.rb +8 -10
  106. data/spec/datastax_rails/dynamic_model_spec.rb +36 -22
  107. data/spec/datastax_rails/inheritance_spec.rb +11 -14
  108. data/spec/datastax_rails/persistence_spec.rb +73 -74
  109. data/spec/datastax_rails/relation/batches_spec.rb +13 -13
  110. data/spec/datastax_rails/relation/facet_methods_spec.rb +43 -35
  111. data/spec/datastax_rails/relation/finder_methods_spec.rb +77 -78
  112. data/spec/datastax_rails/relation/modification_methods_spec.rb +19 -19
  113. data/spec/datastax_rails/relation/search_methods_spec.rb +160 -160
  114. data/spec/datastax_rails/relation/spawn_methods_spec.rb +18 -18
  115. data/spec/datastax_rails/relation_spec.rb +119 -116
  116. data/spec/datastax_rails/schema/migrator_spec.rb +30 -30
  117. data/spec/datastax_rails/schema/solr_spec.rb +15 -15
  118. data/spec/datastax_rails/scoping/default_spec.rb +9 -9
  119. data/spec/datastax_rails/types/dynamic_list_spec.rb +12 -12
  120. data/spec/datastax_rails/types/dynamic_map_spec.rb +10 -10
  121. data/spec/datastax_rails/types/dynamic_set_spec.rb +22 -10
  122. data/spec/datastax_rails/validations/uniqueness_spec.rb +25 -25
  123. data/spec/datastax_rails/wide_storage_model_spec.rb +11 -0
  124. data/spec/datastax_rails_spec.rb +2 -2
  125. data/spec/dummy/config/application.rb +2 -3
  126. data/spec/dummy/config/boot.rb +1 -1
  127. data/spec/dummy/config/environments/development.rb +3 -3
  128. data/spec/dummy/config/environments/test.rb +1 -1
  129. data/spec/dummy/config/initializers/session_store.rb +1 -1
  130. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  131. data/spec/factories/audit_logs.rb +6 -0
  132. data/spec/factories/hobbies.rb +6 -0
  133. data/spec/factories/people.rb +5 -0
  134. data/spec/feature/dynamic_fields_spec.rb +4 -4
  135. data/spec/feature/overloaded_tables_spec.rb +11 -12
  136. data/spec/spec_helper.rb +17 -14
  137. data/spec/support/datastax_test_hook.rb +2 -2
  138. data/spec/support/default_consistency_shared_examples.rb +11 -11
  139. data/spec/support/models.rb +31 -32
  140. metadata +40 -6
  141. data/lib/datastax_rails/attribute_methods/before_type_cast.rb +0 -71
  142. data/lib/datastax_rails/log_subscriber.rb +0 -0
  143. data/spec/dummy/ks/migrate/20111117224534_models.rb +0 -20
@@ -2,33 +2,33 @@ require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Schema::Solr 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
-
8
- describe "#reindex_solr" do
9
- it "calls curl to post the reindex command" do
7
+
8
+ describe '#reindex_solr' do
9
+ it 'calls curl to post the reindex command' do
10
10
  url = "#{DatastaxRails::Base.solr_base_url}/admin/cores?action=RELOAD&name=datastax_rails_test.people&reindex=true&deleteAll=false"
11
11
  expect(subject).to receive(:`).with("curl -s -X POST '#{url}'")
12
12
  subject.reindex_solr(Person)
13
13
  end
14
14
  end
15
-
16
- describe "#create_solr_core" do
17
- it "calls curl to post the solr create core command" do
15
+
16
+ describe '#create_solr_core' do
17
+ it 'calls curl to post the solr create core command' do
18
18
  url = "#{DatastaxRails::Base.solr_base_url}/admin/cores?action=CREATE&name=datastax_rails_test.people"
19
19
  expect(subject).to receive(:`).with("curl -s -X POST '#{url}'")
20
20
  subject.create_solr_core(Person)
21
21
  end
22
22
  end
23
-
24
- describe "#generate_solr_schema" do
25
- it "uses a custom config if one is present" do
26
- model = mock_model("Article", :column_family => 'articles', :name => 'Article', :attribute_definitions => {}, :primary_key => 'id', :<= => false)
23
+
24
+ describe '#generate_solr_schema' do
25
+ it 'uses a custom config if one is present' do
26
+ model = double('Article', :column_family => 'articles', :name => 'Article', :attribute_definitions => {}, :primary_key => 'id', :<= => false)
27
27
  expect(subject.generate_solr_schema(model)).to match(/This is my custom schema/)
28
28
  end
29
29
  end
30
-
31
- describe "#upload_solr_configuration" do
32
-
30
+
31
+ describe '#upload_solr_configuration' do
32
+
33
33
  end
34
- end
34
+ end
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper.rb'
2
2
 
3
3
  describe DatastaxRails::Base do
4
- context "Scoping" do
5
- context "Default" do
6
- it "applies the default scope" do
7
- Boat.create(:name => 'WindDancer', :registration => 1)
8
- Boat.create(:name => 'Misty', :registration => 2)
9
- Boat.create(:name => 'Voyager', :registration => 3)
10
- Boat.create(:name => 'Aquacadabra', :registration => 4)
4
+ context 'Scoping' do
5
+ context 'Default' do
6
+ it 'applies the default scope' do
7
+ Boat.create(name: 'WindDancer', registration: 1)
8
+ Boat.create(name: 'Misty', registration: 2)
9
+ Boat.create(name: 'Voyager', registration: 3)
10
+ Boat.create(name: 'Aquacadabra', registration: 4)
11
11
  Boat.commit_solr
12
-
13
- Boat.where(:registration => [1,2,3,4]).collect(&:name).should == ['Aquacadabra', 'Misty', 'Voyager', 'WindDancer']
12
+
13
+ expect(Boat.where(registration: [1, 2, 3, 4]).map(&:name)).to eq(%w(Aquacadabra Misty Voyager WindDancer))
14
14
  end
15
15
  end
16
16
  end
@@ -1,20 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Types::DynamicList do
4
- subject {described_class.new(double("record", :changed_attributes => {}, :attributes => {}), 'list', [])}
5
-
4
+ subject { described_class.new(double('record', changed_attributes: {}, attributes: {}), 'list', []) }
5
+
6
6
  before(:each) do
7
- subject << "Test String 1"
8
- subject << "Another Test String"
9
- subject << "Test String 1"
7
+ subject << 'Test String 1'
8
+ subject << 'Another Test String'
9
+ subject << 'Test String 1'
10
10
  end
11
-
12
- it { should eq(["Test String 1", "Another Test String", "Test String 1"])}
11
+
12
+ it { is_expected.to eq(['Test String 1', 'Another Test String', 'Test String 1']) }
13
13
  its('record.changed_attributes') { should include('list' => []) }
14
- its('record.attributes') { should include('list' => ["Test String 1", "Another Test String", "Test String 1"])}
15
-
16
- it "preserves ordering" do
17
- subject[1] = "Test String 2"
18
- subject.should eq(["Test String 1", "Test String 2", "Test String 1"])
14
+ its('record.attributes') { should include('list' => ['Test String 1', 'Another Test String', 'Test String 1']) }
15
+
16
+ it 'preserves ordering' do
17
+ subject[1] = 'Test String 2'
18
+ expect(subject).to eq(['Test String 1', 'Test String 2', 'Test String 1'])
19
19
  end
20
20
  end
@@ -1,22 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Types::DynamicMap do
4
- subject {described_class.new(double("record", :changed_attributes => {}, :attributes => {}), 'map', {})}
5
-
4
+ subject { described_class.new(double('record', changed_attributes: {}, attributes: {}), 'map', {}) }
5
+
6
6
  before(:each) do
7
- subject['mapkey'] = "Test String"
7
+ subject['mapkey'] = 'Test String'
8
8
  end
9
-
10
- its(['mapkey']) { should eq("Test String")}
9
+
10
+ its(['mapkey']) { should eq('Test String') }
11
11
  its('record.changed_attributes') { should include('map' => {}) }
12
- its('record.attributes') { should include('map' => {'mapkey' => 'Test String'})}
13
-
14
- it "automatically maps key names when setting values" do
12
+ its('record.attributes') { should include('map' => { 'mapkey' => 'Test String' }) }
13
+
14
+ it 'automatically maps key names when setting values' do
15
15
  subject['test'] = 'Test String'
16
16
  expect(subject).to have_key('maptest')
17
17
  end
18
-
19
- it "automatically maps key names when reading values" do
18
+
19
+ it 'automatically maps key names when reading values' do
20
20
  expect(subject['key']).to eq('Test String')
21
21
  end
22
22
  end
@@ -1,16 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Types::DynamicSet do
4
- subject {described_class.new(double("record", :changed_attributes => {}, :attributes => {}), 'set', [])}
5
-
4
+ let(:set) { described_class.new(double('record', changed_attributes: {}, attributes: {}), 'set', []) }
5
+ subject { set }
6
6
  before(:each) do
7
- subject << "Test String 1"
8
- subject << "Another Test String"
9
- subject.add("Test String 1")
10
- subject << nil
7
+ set << 'Test String 1'
8
+ set << 'Another Test String'
9
+ set.add('Test String 1')
10
+ set << nil
11
+ end
12
+
13
+ it { is_expected.to eq(Set.new(['Test String 1', 'Another Test String', nil])) }
14
+ its('record.changed_attributes') { is_expected.to include('set' => Set.new) }
15
+ its('record.attributes') { is_expected.to include('set' => Set.new(['Test String 1', 'Another Test String', nil])) }
16
+
17
+ context 'updating an existing record' do
18
+ subject { FactoryGirl.build_stubbed(:person, email_addresses: Set.new(['john@example.com'])) }
19
+
20
+ before do
21
+ subject.changed_attributes.clear
22
+ subject.email_addresses << 'john@compuserve.com'
23
+ end
24
+
25
+ it { is_expected.to be_changed }
26
+ its(:changed_attributes) { is_expected.to include('email_addresses' => Set.new(['john@example.com'])) }
11
27
  end
12
-
13
- it { should eq(Set.new(["Test String 1", "Another Test String", nil]))}
14
- its('record.changed_attributes') { should include('set' => Set.new) }
15
- its('record.attributes') { should include('set' => Set.new(["Test String 1", "Another Test String", nil]))}
16
28
  end
@@ -1,43 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Base do
4
- describe "uniqueness validation" do
5
- it "should validate uniqueness" do
4
+ describe 'uniqueness validation' do
5
+ it 'should validate uniqueness' do
6
6
  Person.commit_solr
7
- Person.create!(:name => "Jason")
7
+ Person.create!(name: 'Jason')
8
8
  Person.commit_solr
9
9
  Person.commit_solr
10
- person = Person.new(:name => "Jason")
11
- person.should_not be_valid
12
- person.name = "John"
13
- person.should be_valid
10
+ person = Person.new(name: 'Jason')
11
+ expect(person).not_to be_valid
12
+ person.name = 'John'
13
+ expect(person).to be_valid
14
14
  end
15
-
16
- it "should allow an update to a model without triggering a uniqueness error" do
15
+
16
+ it 'should allow an update to a model without triggering a uniqueness error' do
17
17
  Person.commit_solr
18
- p=Person.create!(:name => "Jason", :birthdate => Date.strptime("10/19/1985", '%m/%d/%Y'))
18
+ p = Person.create!(name: 'Jason', birthdate: Date.strptime('10/19/1985', '%m/%d/%Y'))
19
19
  Person.commit_solr
20
- p.birthdate = Date.strptime("10/19/1980", '%m/%d/%Y')
20
+ p.birthdate = Date.strptime('10/19/1980', '%m/%d/%Y')
21
21
  p.save!
22
22
  end
23
-
24
- it "should not break when negative numbers are entered" do
25
- j = Job.new(:title => 'Mouseketeer', :position_number => -1)
26
- j.should be_valid
23
+
24
+ it 'should not break when negative numbers are entered' do
25
+ j = Job.new(title: 'Mouseketeer', position_number: -1)
26
+ expect(j).to be_valid
27
27
  end
28
-
29
- it "should not enforce uniqueness of blanks if specified" do
30
- Job.create!(:title => 'Engineer')
28
+
29
+ it 'should not enforce uniqueness of blanks if specified' do
30
+ Job.create!(title: 'Engineer')
31
31
  Job.commit_solr
32
- j = Job.new(:title => 'Analyst')
33
- j.should be_valid
32
+ j = Job.new(title: 'Analyst')
33
+ expect(j).to be_valid
34
34
  end
35
-
36
- it "should enforce uniqueness of blanks if not instructed otherwise" do
37
- Boat.create!(:name => nil)
35
+
36
+ it 'should enforce uniqueness of blanks if not instructed otherwise' do
37
+ Boat.create!(name: nil)
38
38
  Boat.commit_solr
39
- b=Boat.new
40
- b.should_not be_valid
39
+ b = Boat.new
40
+ expect(b).not_to be_valid
41
41
  end
42
42
  end
43
43
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe DatastaxRails::WideStorageModel do
4
+ subject { build_stubbed(:audit_log) }
5
+
6
+ context '#id_for_update' do
7
+ subject { super().id_for_update }
8
+ it { is_expected.to have_key('uuid') }
9
+ it { is_expected.to have_key('created_at') }
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails do
4
-
5
- end
4
+
5
+ end
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'active_model/railtie'
4
4
 
5
5
  Bundler.require
6
- require "datastax_rails"
6
+ require 'datastax_rails'
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
@@ -30,7 +30,7 @@ module Dummy
30
30
  # config.i18n.default_locale = :de
31
31
 
32
32
  # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
33
+ config.encoding = 'utf-8'
34
34
 
35
35
  # Configure sensitive parameters which will be filtered from the log file.
36
36
  config.filter_parameters += [:password]
@@ -42,4 +42,3 @@ module Dummy
42
42
  config.assets.version = '1.0'
43
43
  end
44
44
  end
45
-
@@ -7,4 +7,4 @@ if File.exist?(gemfile)
7
7
  Bundler.setup
8
8
  end
9
9
 
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
10
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -5,15 +5,15 @@ Dummy::Application.configure do
5
5
  # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
-
8
+
9
9
  config.eager_load = false
10
10
 
11
11
  # Show full error reports and disable caching
12
12
  config.consider_all_requests_local = true
13
- #config.action_controller.perform_caching = false
13
+ # config.action_controller.perform_caching = false
14
14
 
15
15
  # Don't care if the mailer can't send
16
- #config.action_mailer.raise_delivery_errors = false
16
+ # config.action_mailer.raise_delivery_errors = false
17
17
 
18
18
  # Print deprecation notices to the Rails logger
19
19
  config.active_support.deprecation = :log
@@ -11,7 +11,7 @@ Dummy::Application.configure do
11
11
 
12
12
  # Configure static asset server for tests with Cache-Control for performance
13
13
  config.serve_static_assets = true
14
- config.static_cache_control = "public, max-age=3600"
14
+ config.static_cache_control = 'public, max-age=3600'
15
15
 
16
16
  # Show full error reports and disable caching
17
17
  config.consider_all_requests_local = true
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
4
 
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
8
+ wrap_parameters format: [:json]
9
9
  end
10
10
 
11
11
  # Disable root element in JSON by default.
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory(:audit_log) do
3
+ message 'Updated something'
4
+ user 'jimbob'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory(:hobby) do
3
+ name 'Biking'
4
+ complexity 2.0
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory(:person) do
3
+ name 'John'
4
+ end
5
+ end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature "Dynamic Fields" do
4
- scenario "map entries dynamically populate solr fields" do
5
- Person.create!(:name => 'Steve', :str_ => {'str_favorite_color' => 'blue'})
3
+ feature 'Dynamic Fields' do
4
+ scenario 'map entries dynamically populate solr fields' do
5
+ Person.create!(name: 'Steve', str_: { 'str_favorite_color' => 'blue' })
6
6
  Person.commit_solr
7
- expect(Person.where(:str_favorite_color => 'blue')).to have(1).entry
7
+ expect(Person.where(str_favorite_color: 'blue').entries.size).to eq(1)
8
8
  end
9
9
  end
@@ -1,24 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature "Table Overloads" do
4
- scenario "models writing to the same column family do not collide" do
3
+ feature 'Table Overloads' do
4
+ scenario 'models writing to the same column family do not collide' do
5
5
  core_meta = CoreMetadata.new
6
- core_meta.strings[:source] = "BBC"
7
- core_meta.strings[:author] = "John"
6
+ core_meta.strings[:source] = 'BBC'
7
+ core_meta.strings[:author] = 'John'
8
8
  core_meta.timestamps[:published_at] = Time.now
9
9
  core_meta.save
10
-
10
+
11
11
  team_meta = TeamMetadata.new
12
12
  team_meta.id = core_meta.id
13
- team_meta.strings[:source] = "TV"
13
+ team_meta.strings[:source] = 'TV'
14
14
  team_meta.strings[:medium] = 'television'
15
15
  team_meta.dates[:published_on] = Date.today
16
16
  team_meta.save
17
-
17
+
18
18
  CoreMetadata.commit_solr
19
-
20
-
21
- expect(CoreMetadata.fulltext('BBC')).to have(1).entry
22
- expect(CoreMetadata.fulltext('TV')).to have(0).entries
19
+
20
+ expect(CoreMetadata.fulltext('BBC').entries.size).to eq(1)
21
+ expect(CoreMetadata.fulltext('TV').entries.size).to eq(0)
23
22
  end
24
- end
23
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,42 +1,45 @@
1
1
  # configure Rails Envinronment
2
- ENV["RAILS_ENV"] = "test"
3
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
2
+ ENV['RAILS_ENV'] = 'test'
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
4
 
5
5
  require 'rspec/rails'
6
+ require 'rspec/its'
7
+ require 'factory_girl_rails'
6
8
 
7
- ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
9
+ ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
8
10
 
9
11
  # Requires supporting ruby files with custom matchers and macros, etc,
10
12
  # in spec/support/ and its subdirectories.
11
- Dir[File.expand_path(File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb"))].each {|f| require f }
13
+ Dir[File.expand_path(File.join(ENGINE_RAILS_ROOT, 'spec/support/**/*.rb'))].each { |f| require f }
12
14
 
13
15
  RSpec.configure do |config|
16
+ config.include FactoryGirl::Syntax::Methods
17
+
14
18
  config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
15
-
19
+
16
20
  # Use a focus tag to filter specific specs. This helps if you need to
17
21
  # focus on one spec instead of the whole suite.
18
22
  config.filter_run focus: true
19
23
  config.run_all_when_everything_filtered = true
20
-
24
+
21
25
  # Filter slow specs. Add a :slow tag to the spec to keep it from
22
26
  # running unless the SLOW_SPECS environment variable is set.
23
- config.treat_symbols_as_metadata_keys_with_true_values = true
24
27
  # config.filter_run_excluding :slow unless ENV['SLOW_SPECS']
25
-
28
+
26
29
  config.before(:each) do
27
30
  DatastaxRails::Base.recorded_classes = {}
28
31
  DatastaxRails::Base.statement_cache.clear
29
32
  end
30
-
33
+
31
34
  config.after(:each) do
32
35
  DatastaxRails::Base.recorded_classes.keys.each do |klass|
33
- DatastaxRails::Base.connection.execute("TRUNCATE #{klass.column_family.to_s}")
36
+ DatastaxRails::Base.connection.execute("TRUNCATE #{klass.column_family}")
34
37
  end
35
38
  end
36
-
39
+
37
40
  # config.after(:all) do
38
- # DatastaxRails::Base.models.each do |m|
39
- # DatastaxRails::Cql::Truncate.new(m).execute
40
- # end
41
+ # DatastaxRails::Base.models.each do |m|
42
+ # DatastaxRails::Cql::Truncate.new(m).execute
43
+ # end
41
44
  # end
42
45
  end