ncs_mdes_warehouse 0.15.0.pre1 → 0.15.0.pre2

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/ci-exec.sh CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  export NCS_NAVIGATOR_ENV=ci
4
4
 
5
- BUNDLER_VERSION=1.2.0
5
+ BUNDLER_VERSION=1.3.5
6
6
  GEMSET=ncs_mdes_warehouse
7
7
 
8
8
  if [ -z $CI_RUBY ]; then
@@ -45,3 +45,16 @@ module DataMapper::Inflector
45
45
  lower_case_and_underscored_word
46
46
  end
47
47
  end
48
+
49
+ # TODO: add/verify there are specs to ensure this does not break the
50
+ # behavior of mdes-wh without --soft_validations
51
+ #
52
+ # This hack is added to get around DataMapper validating :required =>
53
+ # true in dm-core. With dm-validations :required => true is also
54
+ # validated but the validation in dm-core cannot be disabled using
55
+ # save! (or any other known method)
56
+ class DataMapper::Property
57
+ def valid?(*args)
58
+ true
59
+ end
60
+ end
@@ -29,6 +29,13 @@ module NcsNavigator::Warehouse::Models
29
29
  content = %w(-3 -6).detect { |c| prop.options[:set].include?(c) }
30
30
  end
31
31
 
32
+ # If the content is a BigDecimal, we don't want
33
+ # the result in engineering notation, which is the default.
34
+ # We want floating-point notation instead.
35
+ if content.is_a?(BigDecimal)
36
+ content = content.to_s('F')
37
+ end
38
+
32
39
  # Omit if blank and omittable, otherwise have a blast
33
40
  if !content.blank? || !prop.omittable
34
41
  xml.tag!(variable_name, content)
@@ -1,5 +1,5 @@
1
1
  module NcsNavigator
2
2
  module Warehouse
3
- VERSION = '0.15.0.pre1'
3
+ VERSION = '0.15.0.pre2'
4
4
  end
5
5
  end
@@ -33,9 +33,10 @@ module NcsNavigator::Warehouse::Models
33
33
  property :color_scale, NcsNavigator::Warehouse::DataMapper::NcsString,
34
34
  :pii => true,
35
35
  :set => %w(3 4 5 6 7 8 -6)
36
+ property :sample_size, NcsNavigator::Warehouse::DataMapper::NcsDecimal
36
37
  property :size, NcsNavigator::Warehouse::DataMapper::NcsInteger, :omittable => true
37
38
 
38
- mdes_order :tableau_id, :age_span, :context_id, :ssn, :color_scale, :size
39
+ mdes_order :tableau_id, :age_span, :context_id, :ssn, :color_scale, :size, :sample_size
39
40
  end
40
41
 
41
42
  class Spec::Sample::Context
@@ -55,7 +56,7 @@ module NcsNavigator::Warehouse::Models
55
56
  describe '.mdes_order' do
56
57
  it 'is retrievable' do
57
58
  Spec::Sample::GenerationalTableau.mdes_order.
58
- should == [ :tableau_id, :age_span, :context_id, :ssn, :color_scale, :size ]
59
+ should == [ :tableau_id, :age_span, :context_id, :ssn, :color_scale, :size, :sample_size ]
59
60
  end
60
61
  end
61
62
 
@@ -67,7 +68,7 @@ module NcsNavigator::Warehouse::Models
67
68
  subject {
68
69
  Spec::Sample::GenerationalTableau.new(
69
70
  :tableau_id => 4, :age_span => '19-54', :ssn => '555-45-4444', :color_scale => '5',
70
- :size => 14
71
+ :size => 14, :sample_size => 15.01234
71
72
  ).tap do |gt|
72
73
  gt.context_id = 'AB-7833'
73
74
  end
@@ -82,7 +83,11 @@ module NcsNavigator::Warehouse::Models
82
83
  end
83
84
 
84
85
  it 'emits the expected number of columns' do
85
- xml.root.elements.size.should == 7
86
+ xml.root.elements.size.should == 8
87
+ end
88
+
89
+ it 'produces decimals in a floating-point notation' do
90
+ xml.xpath('//sample_size').first.text.strip.should == "15.01234"
86
91
  end
87
92
 
88
93
  it 'produces XML omitting PII by default' do
@@ -104,7 +109,7 @@ module NcsNavigator::Warehouse::Models
104
109
 
105
110
  it 'emits the columns according to the mdes_order' do
106
111
  xml.root.elements.collect(&:name).
107
- should == %w(tableau_id age_span context_id ssn color_scale size transaction_type)
112
+ should == %w(tableau_id age_span context_id ssn color_scale size sample_size transaction_type)
108
113
  end
109
114
 
110
115
  it 'emits the property values as expected' do
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ncs_navigator/warehouse/data_mapper'
4
+
5
+ module NcsNavigator::Warehouse::Transformers
6
+ describe EnumTransformer do
7
+ describe '#transform' do
8
+ context 'soft_validations', :use_database, :modifies_warehouse_state do
9
+
10
+ class Sample
11
+ include ::DataMapper::Resource
12
+
13
+ property :psu_id, String
14
+ property :recruit_type, String, :format => /^\d$/
15
+ property :id, Integer, :key => true
16
+ property :name, String, :required => true
17
+ end
18
+
19
+ before(:all) do
20
+ DataMapper.finalize
21
+ end
22
+
23
+ let(:records) {[Sample.new(:id => 1, :psu_id => '20000030', :name => 'One'),
24
+ Sample.new(:id => 2, :psu_id => '20000030', :name => 'Two'),
25
+ Sample.new(:id => 3, :psu_id => '20000030', :name => 'Three')
26
+ ]}
27
+ let(:transformer) { EnumTransformer.new(spec_config.tap{|c|c.soft_validations = true}, records) }
28
+ let(:transform_status) { NcsNavigator::Warehouse::TransformStatus.memory_only('test') }
29
+
30
+ it 'saves invalid records but still records validation errors' do
31
+ records[2].recruit_type = 'H'
32
+ records[2].should be_dirty
33
+ records[2].should_not be_valid
34
+ transformer.transform(transform_status)
35
+ transform_status.transform_errors.size.should == 1
36
+ records[2].should_not be_dirty
37
+ end
38
+
39
+ context "in combination with drop_all_null_constraints" do
40
+ before(:all) {NcsNavigator::Warehouse::Spec.database_initializer.drop_all_null_constraints(:working)}
41
+ after (:all) {NcsNavigator::Warehouse::Spec.database_initializer.replace_schema}
42
+ it 'saves null records with drop_all_null_constraints' do
43
+ records[2].name = nil
44
+ records[2].should be_dirty
45
+ records[2].should_not be_valid
46
+ transformer.transform(transform_status)
47
+ transform_status.transform_errors.size.should == 1
48
+ records[2].should_not be_dirty
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -309,7 +309,7 @@ module NcsNavigator::Warehouse::Transformers
309
309
  err = transform_status.transform_errors.first
310
310
  err.model_class.should == Sample.to_s
311
311
  err.record_id.should == '2'
312
- err.message.should =~ /^Could not save valid record/
312
+ err.message.should =~ /^Could not save record/
313
313
  end
314
314
 
315
315
  it 'saves the saveable instances' do
data/spec/spec_helper.rb CHANGED
@@ -71,8 +71,9 @@ RSpec.configure do |config|
71
71
  # This interferes with global state (DM's connection setup), so we need
72
72
  # to reconnect for each :use_database group to correct.
73
73
  config.before(:all, :use_database) do
74
- init = NcsNavigator::Warehouse::DatabaseInitializer.new(spec_config)
75
- init.set_up_repository(:both)
74
+ NcsNavigator::Warehouse::Spec.database_initializer(spec_config).tap do |db|
75
+ db.set_up_repository(:both)
76
+ end
76
77
  end
77
78
 
78
79
  config.after(:each, :use_database) do
@@ -23,8 +23,8 @@ module NcsNavigator::Warehouse
23
23
  end
24
24
  end
25
25
 
26
- def self.database_initializer
27
- @database_initializer ||= DatabaseInitializer.new(configuration)
26
+ def self.database_initializer(config = self.configuration)
27
+ @database_initializer ||= DatabaseInitializer.new(config)
28
28
  end
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncs_mdes_warehouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.pre1
4
+ version: 0.15.0.pre2
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-22 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ncs_mdes
@@ -3635,6 +3635,7 @@ files:
3635
3635
  - spec/ncs_navigator/warehouse/transform_load_spec.rb
3636
3636
  - spec/ncs_navigator/warehouse/transform_status_spec.rb
3637
3637
  - spec/ncs_navigator/warehouse/transformers/database_spec.rb
3638
+ - spec/ncs_navigator/warehouse/transformers/enum_transformer_soft_validations_spec.rb
3638
3639
  - spec/ncs_navigator/warehouse/transformers/enum_transformer_spec.rb
3639
3640
  - spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb
3640
3641
  - spec/ncs_navigator/warehouse/transformers/foreign_key_index/database_key_provider_spec.rb
@@ -3669,7 +3670,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
3669
3670
  version: '0'
3670
3671
  segments:
3671
3672
  - 0
3672
- hash: -4565215284799470018
3673
+ hash: 775523728278121596
3673
3674
  required_rubygems_version: !ruby/object:Gem::Requirement
3674
3675
  none: false
3675
3676
  requirements:
@@ -3678,7 +3679,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
3678
3679
  version: 1.3.1
3679
3680
  requirements: []
3680
3681
  rubyforge_project:
3681
- rubygems_version: 1.8.25
3682
+ rubygems_version: 1.8.24
3682
3683
  signing_key:
3683
3684
  specification_version: 3
3684
3685
  summary: Scripts and models for building and maintaining the MDES-based reporting
@@ -3710,6 +3711,7 @@ test_files:
3710
3711
  - spec/ncs_navigator/warehouse/transform_load_spec.rb
3711
3712
  - spec/ncs_navigator/warehouse/transform_status_spec.rb
3712
3713
  - spec/ncs_navigator/warehouse/transformers/database_spec.rb
3714
+ - spec/ncs_navigator/warehouse/transformers/enum_transformer_soft_validations_spec.rb
3713
3715
  - spec/ncs_navigator/warehouse/transformers/enum_transformer_spec.rb
3714
3716
  - spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb
3715
3717
  - spec/ncs_navigator/warehouse/transformers/foreign_key_index/database_key_provider_spec.rb