daengine 0.6.5 → 0.6.8

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.
@@ -1 +1 @@
1
- last_read_time: 2014-02-05 12:48:02 -0700
1
+ last_read_time: 2014-02-07 08:20:30 -0700
@@ -1 +1 @@
1
- last_read_time: 2014-02-05 12:48:06 -0700
1
+ last_read_time: 2014-02-07 08:20:33 -0700
@@ -0,0 +1,136 @@
1
+ require 'spec_helper'
2
+ require 'app/models/service_digital_asset'
3
+
4
+ describe ServiceDigitalAsset do
5
+
6
+ subject { FactoryGirl.build :service_digital_asset }
7
+
8
+ context '#fields' do
9
+ let(:defined_fields) {
10
+ [:title, :changed_at, :sami_code, :product_ids, :program_ids, :summary,
11
+ :published_at, :expires_at, :digital_asset_id, :audiences,
12
+ :path, :doc_changed_at, :content_type, :pages, :size, :mime_type, :subject,
13
+ :keywords, :author, :finra_path, :fund_codes, :display_on_website]
14
+ }
15
+ it 'has all defined fields' do
16
+ defined_fields.each { |f| should respond_to(f) }
17
+ end
18
+ end
19
+
20
+ context '#validation' do
21
+ required_fields = [:digital_asset_id, :title, :changed_at, :published_at, :expires_at, :path, :audiences]
22
+ required_fields.each do |f|
23
+ it "validates #{f} is required" do
24
+ should be_valid
25
+ subject.send("#{f}=", nil)
26
+ should be_invalid "should be invalid if #{f} is missing"
27
+ end
28
+ end
29
+
30
+ it 'cannot have a past expiration date' do
31
+ subject.expires_at = 2.hours.ago
32
+ subject.should be_invalid
33
+ end
34
+
35
+ it "cannot have duplicate digital_asset_id" do
36
+ FactoryGirl.create :digital_asset, :digital_asset_id => "aaaa_kkkk_1234"
37
+ digital_asset = FactoryGirl.build :digital_asset, :digital_asset_id => "aaaa_kkkk_1234"
38
+ # p "errors = #{digital_asset.errors.inspect}"
39
+ digital_asset.should be_invalid
40
+ end
41
+ end
42
+
43
+ context 'helper functions' do
44
+ let(:asset) { FactoryGirl.build :service_digital_asset }
45
+
46
+ it 'is effective if displayed on website and has an expiration date' do
47
+ asset.display_on_website = true
48
+ asset.expires_at = Time.now
49
+
50
+ asset.effective?.should == true
51
+ end
52
+
53
+ it 'is not effective if not displayed on website' do
54
+ asset.display_on_website = false
55
+ asset.expires_at = Time.now
56
+
57
+ asset.effective?.should == false
58
+ end
59
+
60
+ it 'is not effective if not it does not have an expiration date' do
61
+ asset.display_on_website = true
62
+ asset.expires_at = nil
63
+
64
+ asset.effective?.should == false
65
+ end
66
+
67
+ it 'is expired if it does not have an expiration date' do
68
+ asset.expires_at = nil
69
+
70
+ asset.expired?.should == true
71
+ end
72
+
73
+ it 'is expired if its expiration date is in the past' do
74
+ asset.expires_at = 1.hour.ago
75
+
76
+ asset.expired?.should == true
77
+ end
78
+
79
+ it 'is not expired if its expiration date is in the future' do
80
+ asset.expires_at = 1.hour.from_now
81
+
82
+ asset.expired?.should == false
83
+ end
84
+
85
+ it 'is a FINRA document if the content type is the appropriate value' do
86
+ asset.content_type = DigitalAsset::ContentType::FINRA
87
+
88
+ asset.finra?.should == true
89
+ end
90
+
91
+ it 'is a not FINRA document if the content type is some other value' do
92
+ asset.content_type = DigitalAsset::ContentType::PROSPECTUS
93
+
94
+ asset.finra?.should == false
95
+ end
96
+
97
+ it 'is not ready for deletion if there is no unpublished at date' do
98
+ asset.unpublished_at = nil
99
+
100
+ asset.delete?.should == false
101
+ end
102
+
103
+ it 'is ready for deletion if there is a unpublished at date' do
104
+ asset.unpublished_at = Time.now
105
+
106
+ asset.delete?.should == true
107
+ end
108
+
109
+ it 'is ready for deletion if it is expired' do
110
+ asset.expires_at = nil
111
+
112
+ asset.delete?.should == true
113
+ end
114
+
115
+ it 'is ready for deletion when marked for deletion' do
116
+ asset.delete?.should == false
117
+ asset.mark_for_deletion
118
+ asset.delete?.should == true
119
+ end
120
+
121
+ it 'returns a 10 year old date if the time field is blank' do
122
+ asset.published_at = nil
123
+
124
+ result = asset.default_blank_time(:published_at)
125
+ result.to_i.should == 10.years.ago.to_i
126
+ end
127
+
128
+ it 'returns the time field value if it is not blank' do
129
+ expected = asset.published_at
130
+
131
+ result = asset.default_blank_time(:published_at)
132
+
133
+ result.to_i.should == expected.to_i
134
+ end
135
+ end
136
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - sbhatia
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-05 00:00:00.000000000 Z
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -73,12 +73,40 @@ dependencies:
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: '1.6'
76
+ version: 1.6.0
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ~>
80
80
  - !ruby/object:Gem::Version
81
- version: '1.6'
81
+ version: 1.6.0
82
+ prerelease: false
83
+ type: :runtime
84
+ - !ruby/object:Gem::Dependency
85
+ name: activerecord-tableless
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '1.3'
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '1.3'
96
+ prerelease: false
97
+ type: :runtime
98
+ - !ruby/object:Gem::Dependency
99
+ name: httparty
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '='
103
+ - !ruby/object:Gem::Version
104
+ version: 0.10.2
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.10.2
82
110
  prerelease: false
83
111
  type: :runtime
84
112
  - !ruby/object:Gem::Dependency
@@ -123,6 +151,7 @@ files:
123
151
  - app/helpers/digital_assets_helper.rb
124
152
  - app/models/content_service_resource.rb
125
153
  - app/models/digital_asset.rb
154
+ - app/models/service_digital_asset.rb
126
155
  - app/models/taxonomy_term.rb
127
156
  - app/models/teamsite_digital_asset_shim.rb
128
157
  - app/service/digital_asset_lookup_service.rb
@@ -134,10 +163,12 @@ files:
134
163
  - lib/daengine/content_service_processor.rb
135
164
  - lib/daengine/digital_asset_processor.rb
136
165
  - lib/daengine/engine.rb
166
+ - lib/daengine/http_client.rb
137
167
  - lib/daengine/railtie.rb
138
168
  - lib/daengine/taxonomy_parser.rb
139
169
  - lib/daengine/taxonomy_processor.rb
140
170
  - lib/daengine/teamsite_metadata_parser.rb
171
+ - lib/daengine/teamsite_metadata_processor.rb
141
172
  - lib/daengine/version.rb
142
173
  - lib/tasks/daengine_tasks.rake
143
174
  - MIT-LICENSE
@@ -183,6 +214,7 @@ files:
183
214
  - spec/lib/digital_asset_processor_spec.rb
184
215
  - spec/lib/taxonomy_processor_spec.rb
185
216
  - spec/lib/teamsite_metadata_parser_spec.rb
217
+ - spec/lib/teamsite_metadata_processor_spec.rb
186
218
  - spec/mock_data/bulk-ssc_deploy.xml
187
219
  - spec/mock_data/daengine.yml
188
220
  - spec/mock_data/selective-ssc_2012_05_18_13_48_03_publish.xml
@@ -209,6 +241,7 @@ files:
209
241
  - spec/mock_data/taxonomy/taxonomy.xml
210
242
  - spec/mock_data/taxonomy/taxonomyengine.yml
211
243
  - spec/models/digital_asset_spec.rb
244
+ - spec/models/service_digital_asset_spec.rb
212
245
  - spec/service/digital_asset_lookup_service_spec.rb
213
246
  - bin/process_assets
214
247
  - bin/process_taxonomy
@@ -276,6 +309,7 @@ test_files:
276
309
  - spec/lib/digital_asset_processor_spec.rb
277
310
  - spec/lib/taxonomy_processor_spec.rb
278
311
  - spec/lib/teamsite_metadata_parser_spec.rb
312
+ - spec/lib/teamsite_metadata_processor_spec.rb
279
313
  - spec/mock_data/bulk-ssc_deploy.xml
280
314
  - spec/mock_data/daengine.yml
281
315
  - spec/mock_data/selective-ssc_2012_05_18_13_48_03_publish.xml
@@ -302,4 +336,5 @@ test_files:
302
336
  - spec/mock_data/taxonomy/taxonomy.xml
303
337
  - spec/mock_data/taxonomy/taxonomyengine.yml
304
338
  - spec/models/digital_asset_spec.rb
339
+ - spec/models/service_digital_asset_spec.rb
305
340
  - spec/service/digital_asset_lookup_service_spec.rb