daengine 0.0.10.alpha → 0.1.0
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/Gemfile +17 -17
- data/MIT-LICENSE +20 -20
- data/Rakefile +29 -29
- data/app/assets/javascripts/digital_assets.js +2 -2
- data/app/assets/stylesheets/digital_assets.css +4 -4
- data/app/controllers/digital_assets_controller.rb +76 -76
- data/app/helpers/digital_assets_helper.rb +2 -2
- data/app/views/digital_assets/_form.html.erb +17 -17
- data/app/views/digital_assets/edit.html.erb +6 -6
- data/app/views/digital_assets/index.html.erb +34 -34
- data/app/views/digital_assets/new.html.erb +5 -5
- data/app/views/digital_assets/search.html.erb +46 -46
- data/app/views/digital_assets/show.html.erb +58 -58
- data/config/routes.rb +8 -8
- data/lib/daengine.rb +43 -43
- data/lib/daengine/engine.rb +6 -6
- data/lib/daengine/version.rb +3 -3
- data/lib/tasks/daengine_tasks.rake +4 -4
- data/spec/controllers/digital_assets_controller_spec.rb +202 -202
- data/spec/dummy/README.rdoc +261 -261
- data/spec/dummy/Rakefile +7 -7
- data/spec/dummy/app/assets/javascripts/application.js +15 -15
- data/spec/dummy/app/assets/stylesheets/application.css +13 -13
- data/spec/dummy/app/controllers/application_controller.rb +3 -3
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/views/layouts/application.html.erb +14 -14
- data/spec/dummy/config.ru +4 -4
- data/spec/dummy/config/application.rb +70 -70
- data/spec/dummy/config/boot.rb +9 -9
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +37 -37
- data/spec/dummy/config/environments/production.rb +67 -67
- data/spec/dummy/config/environments/test.rb +37 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/inflections.rb +15 -15
- data/spec/dummy/config/initializers/mime_types.rb +5 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -7
- data/spec/dummy/config/initializers/session_store.rb +8 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +5 -5
- data/spec/dummy/config/mongoid.yml +20 -20
- data/spec/dummy/config/routes.rb +58 -58
- data/spec/dummy/public/404.html +26 -26
- data/spec/dummy/public/422.html +26 -26
- data/spec/dummy/public/500.html +25 -25
- data/spec/dummy/script/rails +6 -6
- data/spec/lib/teamsite_metadata_parser_spec.rb +59 -59
- data/spec/spec_helper.rb +40 -40
- metadata +15 -20
- data/spec/dummy/log/development.log +0 -4
- data/spec/dummy/log/test.log +0 -435
@@ -1,58 +1,58 @@
|
|
1
|
-
<p id="notice"><%= notice %></p>
|
2
|
-
|
3
|
-
<p>
|
4
|
-
<b>Title:</b>
|
5
|
-
<%= @digital_asset.title %>
|
6
|
-
</p>
|
7
|
-
|
8
|
-
<p>
|
9
|
-
<b>Updated at:</b>
|
10
|
-
<%= @digital_asset.updated_at %>
|
11
|
-
</p>
|
12
|
-
|
13
|
-
<p>
|
14
|
-
<b>Audience:</b>
|
15
|
-
<%= @digital_asset.audiences %>
|
16
|
-
</p>
|
17
|
-
|
18
|
-
<p>
|
19
|
-
<b>Sami code:</b>
|
20
|
-
<%= @digital_asset.sami_code %>
|
21
|
-
</p>
|
22
|
-
|
23
|
-
<p>
|
24
|
-
<b>Program:</b>
|
25
|
-
<%= @digital_asset.product_ids %>
|
26
|
-
</p>
|
27
|
-
|
28
|
-
<p>
|
29
|
-
<b>Published at:</b>
|
30
|
-
<%= @digital_asset.published_at %>
|
31
|
-
</p>
|
32
|
-
|
33
|
-
<p>
|
34
|
-
<b>Expires at:</b>
|
35
|
-
<%= @digital_asset.expires_at %>
|
36
|
-
</p>
|
37
|
-
|
38
|
-
<p>
|
39
|
-
<b>Guid:</b>
|
40
|
-
<%= @digital_asset.guid %>
|
41
|
-
</p>
|
42
|
-
|
43
|
-
<% if @digital_asset.documents.size > 0 %>
|
44
|
-
<h2>Current Documents</h2>
|
45
|
-
<table>
|
46
|
-
<tr>
|
47
|
-
<th>Content Type</th>
|
48
|
-
<th>Path</th>
|
49
|
-
</tr>
|
50
|
-
<% for document in @digital_asset.documents %>
|
51
|
-
<tr>
|
52
|
-
<td><%= document.content_type %></td>
|
53
|
-
<td><%= document.path %></td>
|
54
|
-
</tr>
|
55
|
-
<% end %>
|
56
|
-
</table>
|
57
|
-
<% end %>
|
58
|
-
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Title:</b>
|
5
|
+
<%= @digital_asset.title %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Updated at:</b>
|
10
|
+
<%= @digital_asset.updated_at %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Audience:</b>
|
15
|
+
<%= @digital_asset.audiences %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<b>Sami code:</b>
|
20
|
+
<%= @digital_asset.sami_code %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<b>Program:</b>
|
25
|
+
<%= @digital_asset.product_ids %>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<p>
|
29
|
+
<b>Published at:</b>
|
30
|
+
<%= @digital_asset.published_at %>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<p>
|
34
|
+
<b>Expires at:</b>
|
35
|
+
<%= @digital_asset.expires_at %>
|
36
|
+
</p>
|
37
|
+
|
38
|
+
<p>
|
39
|
+
<b>Guid:</b>
|
40
|
+
<%= @digital_asset.guid %>
|
41
|
+
</p>
|
42
|
+
|
43
|
+
<% if @digital_asset.documents.size > 0 %>
|
44
|
+
<h2>Current Documents</h2>
|
45
|
+
<table>
|
46
|
+
<tr>
|
47
|
+
<th>Content Type</th>
|
48
|
+
<th>Path</th>
|
49
|
+
</tr>
|
50
|
+
<% for document in @digital_asset.documents %>
|
51
|
+
<tr>
|
52
|
+
<td><%= document.content_type %></td>
|
53
|
+
<td><%= document.path %></td>
|
54
|
+
</tr>
|
55
|
+
<% end %>
|
56
|
+
</table>
|
57
|
+
<% end %>
|
58
|
+
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
Rails.application.routes.draw do
|
2
|
-
match 'digital_assets/search' => 'digital_assets#search'
|
3
|
-
post "digital_assets/sync" => 'digital_assets#sync_assets'
|
4
|
-
# match 'digital_assets/:id' => 'digital_assets#sami' #, :id => /\w{4,8}.\d*/
|
5
|
-
resources :digital_assets, :only => [:index, :show]
|
6
|
-
#resources :digital_assets
|
7
|
-
#get 'digital_assets' => 'digital_asset#index'
|
8
|
-
end
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
match 'digital_assets/search' => 'digital_assets#search'
|
3
|
+
post "digital_assets/sync" => 'digital_assets#sync_assets'
|
4
|
+
# match 'digital_assets/:id' => 'digital_assets#sami' #, :id => /\w{4,8}.\d*/
|
5
|
+
resources :digital_assets, :only => [:index, :show]
|
6
|
+
#resources :digital_assets
|
7
|
+
#get 'digital_assets' => 'digital_asset#index'
|
8
|
+
end
|
data/lib/daengine.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
require "daengine/version"
|
2
|
-
require 'daengine/engine'
|
3
|
-
require File.expand_path('../../app/models/digital_asset',__FILE__)
|
4
|
-
require 'daengine/teamsite_metadata_parser'
|
5
|
-
require 'daengine/digital_asset_processor'
|
6
|
-
require 'mongoid'
|
7
|
-
|
8
|
-
module Daengine
|
9
|
-
@config = {
|
10
|
-
:assets_path => '/digital-assets'
|
11
|
-
}
|
12
|
-
|
13
|
-
@mongoid_config = {
|
14
|
-
'database' => 'ssc_assets', # mongoid database name
|
15
|
-
'host' => nil, # mongoid server
|
16
|
-
'port' => nil, # mongodb server port
|
17
|
-
'hosts' => nil
|
18
|
-
}
|
19
|
-
|
20
|
-
@valid_mongoid_keys = @mongoid_config.keys
|
21
|
-
|
22
|
-
# yaml file config
|
23
|
-
def self.configure(config_options)
|
24
|
-
config_options.each {|k,v| @config[k.to_sym] = v}
|
25
|
-
config_options.each {|k,v|
|
26
|
-
@mongoid_config[k] = v if @valid_mongoid_keys.include? k
|
27
|
-
}
|
28
|
-
Mongoid.configure do |config|
|
29
|
-
config.from_hash(@mongoid_config)
|
30
|
-
end
|
31
|
-
p "configured with keys #{@config.keys}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.config
|
35
|
-
@config
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.execute(config_options)
|
39
|
-
self.configure(config_options)
|
40
|
-
return DigitalAssetProcessor.
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
1
|
+
require "daengine/version"
|
2
|
+
require 'daengine/engine'
|
3
|
+
require File.expand_path('../../app/models/digital_asset',__FILE__)
|
4
|
+
require 'daengine/teamsite_metadata_parser'
|
5
|
+
require 'daengine/digital_asset_processor'
|
6
|
+
require 'mongoid'
|
7
|
+
|
8
|
+
module Daengine
|
9
|
+
@config = {
|
10
|
+
:assets_path => '/digital-assets'
|
11
|
+
}
|
12
|
+
|
13
|
+
@mongoid_config = {
|
14
|
+
'database' => 'ssc_assets', # mongoid database name
|
15
|
+
'host' => nil, # mongoid server
|
16
|
+
'port' => nil, # mongodb server port
|
17
|
+
'hosts' => nil
|
18
|
+
}
|
19
|
+
|
20
|
+
@valid_mongoid_keys = @mongoid_config.keys
|
21
|
+
|
22
|
+
# yaml file config
|
23
|
+
def self.configure(config_options)
|
24
|
+
config_options.each {|k,v| @config[k.to_sym] = v}
|
25
|
+
config_options.each {|k,v|
|
26
|
+
@mongoid_config[k] = v if @valid_mongoid_keys.include? k
|
27
|
+
}
|
28
|
+
Mongoid.configure do |config|
|
29
|
+
config.from_hash(@mongoid_config)
|
30
|
+
end
|
31
|
+
p "configured with keys #{@config.keys}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.config
|
35
|
+
@config
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.execute(config_options)
|
39
|
+
self.configure(config_options)
|
40
|
+
return DigitalAssetProcessor.process_tuple_directory # start the thread daemon
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/lib/daengine/engine.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'rails'
|
2
|
-
|
3
|
-
module Daengine
|
4
|
-
class Engine < ::Rails::Engine
|
5
|
-
end
|
6
|
-
end
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Daengine
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
end
|
6
|
+
end
|
data/lib/daengine/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Daengine
|
2
|
-
VERSION = "0.0
|
3
|
-
end
|
1
|
+
module Daengine
|
2
|
+
VERSION = "0.1.0"
|
3
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# desc "Explaining what the task does"
|
2
|
-
# task :daengine do
|
3
|
-
# # Task goes here
|
4
|
-
# end
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :daengine do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
@@ -1,202 +1,202 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DigitalAssetsController do
|
4
|
-
let(:digital_asset) { FactoryGirl.create :digital_asset }
|
5
|
-
describe "index" do
|
6
|
-
it "assigns all digital_assets as @digital_assets" do
|
7
|
-
get :index
|
8
|
-
assigns(:digital_assets).should eq([digital_asset])
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "show" do
|
13
|
-
it 'returns a single asset when given a guid' do
|
14
|
-
get :show, :id => digital_asset.guid
|
15
|
-
assigns(:digital_asset).guid.should eq(digital_asset.guid)
|
16
|
-
end
|
17
|
-
it 'returns a single asset when given a sami_code' do
|
18
|
-
get :show, :id => digital_asset.sami_code
|
19
|
-
assigns(:digital_asset).should eq(digital_asset)
|
20
|
-
end
|
21
|
-
it 'returns the most recent asset when given a SAMI ID' do
|
22
|
-
FactoryGirl.create :digital_asset, :sami_code => digital_asset.sami_code, :changed_at => 2.years.ago
|
23
|
-
get :show, :id => digital_asset.sami_code
|
24
|
-
assigns(:digital_asset).should eq(digital_asset)
|
25
|
-
end
|
26
|
-
it "assigns the requested digital_asset as @digital_asset" do
|
27
|
-
get :show, :id => digital_asset.id
|
28
|
-
assigns(:digital_asset).should eq(digital_asset)
|
29
|
-
end
|
30
|
-
|
31
|
-
# context "documents" do
|
32
|
-
# it 'can get the individual documents via a nested route' do
|
33
|
-
# get :show, :id => digital_asset.documents.first.id,
|
34
|
-
# :digital_asset_id => digital_asset.id
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
end
|
38
|
-
|
39
|
-
# describe "new" do
|
40
|
-
# it "returns a not allowed" do
|
41
|
-
# get :new, {}
|
42
|
-
# response.should be '404'
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
|
46
|
-
# describe "edit" do
|
47
|
-
# it "returns a not allowed" do
|
48
|
-
# get :edit, {:id => digital_asset.id}
|
49
|
-
# response.should be '404'
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
|
53
|
-
describe 'search' do
|
54
|
-
context 'blank query' do
|
55
|
-
it 'returns nothing' do
|
56
|
-
get :search
|
57
|
-
assigns(:digital_assets).should be_empty
|
58
|
-
end
|
59
|
-
end
|
60
|
-
context 'path' do
|
61
|
-
before do
|
62
|
-
5.times { FactoryGirl.create :digital_asset }
|
63
|
-
@single = FactoryGirl.create :digital_asset
|
64
|
-
@single.documents.clear
|
65
|
-
@single.documents.build(:path => '/one/off.path', :doc_changed_at => Time.now, :content_type => '999')
|
66
|
-
@single.save!
|
67
|
-
end
|
68
|
-
it 'returns a single resource for a complete path' do
|
69
|
-
get :search, :path => '/one/off.path'
|
70
|
-
assigns(:digital_assets).should have(1).result
|
71
|
-
assigns(:digital_assets).first.should eq(@single)
|
72
|
-
end
|
73
|
-
it 'returns an array of resources for a partial match' do
|
74
|
-
end
|
75
|
-
end
|
76
|
-
# /digital_assets/search?content_type[]=777,content_type[]=666
|
77
|
-
context 'content_type' do
|
78
|
-
before do
|
79
|
-
@second = FactoryGirl.create :digital_asset, :guid => 'some-new-asset_134'
|
80
|
-
@second.documents.clear
|
81
|
-
@second.documents << FactoryGirl.build(:document)
|
82
|
-
@second.save!
|
83
|
-
end
|
84
|
-
it 'returns all documents for a single content type' do
|
85
|
-
get :search, :doctype => '666'
|
86
|
-
assigns(:digital_assets).should == [digital_asset]
|
87
|
-
end
|
88
|
-
it 'returns all documents for a set of multiple content_types' do
|
89
|
-
get :search, :doctype => ['666', '777']
|
90
|
-
assigns(:digital_assets).should include(@second)
|
91
|
-
assigns(:digital_assets).should include(digital_asset)
|
92
|
-
# assigns(:digital_assets).entries.count.should be(2)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
context 'sami_code' do
|
96
|
-
before do
|
97
|
-
3.times { FactoryGirl.create :digital_asset, :sami_code => 'SOMETHING.001' }
|
98
|
-
end
|
99
|
-
it 'returns all documents with a particular sami_code' do
|
100
|
-
get :search, :sami => 'SOMETHING.001'
|
101
|
-
assigns(:digital_assets).size.should be(3)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
context 'fund_ids' do
|
105
|
-
before do
|
106
|
-
2.times { FactoryGirl.create :digital_asset, :fund_ids => ['1234', '4567'] }
|
107
|
-
2.times { FactoryGirl.create :digital_asset, :fund_ids => ['1234', '2323'] }
|
108
|
-
1.times { FactoryGirl.create :digital_asset, :fund_ids => ['9999'] }
|
109
|
-
end
|
110
|
-
it 'returns all documents with a particular fund_ids' do
|
111
|
-
get :search, :funds => '1234'
|
112
|
-
assigns(:digital_assets).size.should be(4)
|
113
|
-
end
|
114
|
-
it 'returns all documents for a set of multiple fund_ids' do
|
115
|
-
get :search, :funds => ['1234', '9999']
|
116
|
-
assigns(:digital_assets).size.should be(5)
|
117
|
-
end
|
118
|
-
it 'returns all documents for a set of multiple fund_ids' do
|
119
|
-
get :search, :funds => ['7777', '9999']
|
120
|
-
assigns(:digital_assets).size.should be(1)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
context 'audience' do
|
124
|
-
before do
|
125
|
-
3.times { FactoryGirl.create :digital_asset, :audiences => ['492'] }
|
126
|
-
end
|
127
|
-
it 'returns all documents with a particular audience' do
|
128
|
-
get :search, :audience => '492'
|
129
|
-
assigns(:digital_assets).size.should be(3)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
context 'title' do
|
133
|
-
it 'returns all documents with a particular title' do
|
134
|
-
get :search, :title => 'Doc Title'
|
135
|
-
assigns(:digital_assets).should include(digital_asset)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
context 'guid' do
|
139
|
-
it 'returns all documents with a particular guid' do
|
140
|
-
get :search, :guid => digital_asset.guid
|
141
|
-
assigns(:digital_assets).entries.should == [digital_asset]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
context 'business owner' do
|
145
|
-
it 'returns all documents with a particular business owner' do
|
146
|
-
get :search, :business_owner => 'biz owner'
|
147
|
-
assigns(:digital_assets).should include(digital_asset)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
context "combination searches" do
|
151
|
-
before {5.times {FactoryGirl.create :digital_asset}}
|
152
|
-
it 'returns and-ed results for multiple criteria' do
|
153
|
-
get :search, :guid => digital_asset.guid, :title => digital_asset.title
|
154
|
-
assigns(:digital_assets).entries.should == [digital_asset]
|
155
|
-
end
|
156
|
-
it 'returns multiple results' do
|
157
|
-
get :search, :title => digital_asset.title, :audiences => digital_asset.audiences, :sami => digital_asset.sami_code
|
158
|
-
assigns(:digital_assets).size.should be(6)
|
159
|
-
end
|
160
|
-
it 'returns nothing if not all criteria match' do
|
161
|
-
get :search, :guid => 'blargh-blargh-blargh', :title => 'Doc Title'
|
162
|
-
assigns(:digital_assets).entries.should == []
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe 'sync_assets' do
|
168
|
-
context 'no tuple files' do
|
169
|
-
it 'makes no updates' do
|
170
|
-
pending 'finish specs for DA polling code'
|
171
|
-
# expect {
|
172
|
-
# get :sync_assets
|
173
|
-
# }.to_not change(DigitalAsset, :count)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
context 'bulk file' do
|
177
|
-
before do
|
178
|
-
# touch the bulk file
|
179
|
-
# FileUtils.touch Dir.glob()
|
180
|
-
end
|
181
|
-
it 'updates the count by the # of docs in the bulk' do
|
182
|
-
pending 'add specs for bulk files'
|
183
|
-
# expect {
|
184
|
-
# get :sync_assets
|
185
|
-
# }.to change(DigitalAsset, :count).by(200)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
context 'bulk + selective' do
|
189
|
-
before do
|
190
|
-
# load bulk file into the temp dir
|
191
|
-
# load the selective file into the dir
|
192
|
-
end
|
193
|
-
it 'doesnt re-add existing docs from the selective' do
|
194
|
-
pending 'completion of file polling code'
|
195
|
-
# expect {
|
196
|
-
# get :sync_assets
|
197
|
-
# }.to_not change(DigitalAsset, :count)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DigitalAssetsController do
|
4
|
+
let(:digital_asset) { FactoryGirl.create :digital_asset }
|
5
|
+
describe "index" do
|
6
|
+
it "assigns all digital_assets as @digital_assets" do
|
7
|
+
get :index
|
8
|
+
assigns(:digital_assets).should eq([digital_asset])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "show" do
|
13
|
+
it 'returns a single asset when given a guid' do
|
14
|
+
get :show, :id => digital_asset.guid
|
15
|
+
assigns(:digital_asset).guid.should eq(digital_asset.guid)
|
16
|
+
end
|
17
|
+
it 'returns a single asset when given a sami_code' do
|
18
|
+
get :show, :id => digital_asset.sami_code
|
19
|
+
assigns(:digital_asset).should eq(digital_asset)
|
20
|
+
end
|
21
|
+
it 'returns the most recent asset when given a SAMI ID' do
|
22
|
+
FactoryGirl.create :digital_asset, :sami_code => digital_asset.sami_code, :changed_at => 2.years.ago
|
23
|
+
get :show, :id => digital_asset.sami_code
|
24
|
+
assigns(:digital_asset).should eq(digital_asset)
|
25
|
+
end
|
26
|
+
it "assigns the requested digital_asset as @digital_asset" do
|
27
|
+
get :show, :id => digital_asset.id
|
28
|
+
assigns(:digital_asset).should eq(digital_asset)
|
29
|
+
end
|
30
|
+
|
31
|
+
# context "documents" do
|
32
|
+
# it 'can get the individual documents via a nested route' do
|
33
|
+
# get :show, :id => digital_asset.documents.first.id,
|
34
|
+
# :digital_asset_id => digital_asset.id
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
end
|
38
|
+
|
39
|
+
# describe "new" do
|
40
|
+
# it "returns a not allowed" do
|
41
|
+
# get :new, {}
|
42
|
+
# response.should be '404'
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
|
46
|
+
# describe "edit" do
|
47
|
+
# it "returns a not allowed" do
|
48
|
+
# get :edit, {:id => digital_asset.id}
|
49
|
+
# response.should be '404'
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
|
53
|
+
describe 'search' do
|
54
|
+
context 'blank query' do
|
55
|
+
it 'returns nothing' do
|
56
|
+
get :search
|
57
|
+
assigns(:digital_assets).should be_empty
|
58
|
+
end
|
59
|
+
end
|
60
|
+
context 'path' do
|
61
|
+
before do
|
62
|
+
5.times { FactoryGirl.create :digital_asset }
|
63
|
+
@single = FactoryGirl.create :digital_asset
|
64
|
+
@single.documents.clear
|
65
|
+
@single.documents.build(:path => '/one/off.path', :doc_changed_at => Time.now, :content_type => '999')
|
66
|
+
@single.save!
|
67
|
+
end
|
68
|
+
it 'returns a single resource for a complete path' do
|
69
|
+
get :search, :path => '/one/off.path'
|
70
|
+
assigns(:digital_assets).should have(1).result
|
71
|
+
assigns(:digital_assets).first.should eq(@single)
|
72
|
+
end
|
73
|
+
it 'returns an array of resources for a partial match' do
|
74
|
+
end
|
75
|
+
end
|
76
|
+
# /digital_assets/search?content_type[]=777,content_type[]=666
|
77
|
+
context 'content_type' do
|
78
|
+
before do
|
79
|
+
@second = FactoryGirl.create :digital_asset, :guid => 'some-new-asset_134'
|
80
|
+
@second.documents.clear
|
81
|
+
@second.documents << FactoryGirl.build(:document)
|
82
|
+
@second.save!
|
83
|
+
end
|
84
|
+
it 'returns all documents for a single content type' do
|
85
|
+
get :search, :doctype => '666'
|
86
|
+
assigns(:digital_assets).should == [digital_asset]
|
87
|
+
end
|
88
|
+
it 'returns all documents for a set of multiple content_types' do
|
89
|
+
get :search, :doctype => ['666', '777']
|
90
|
+
assigns(:digital_assets).should include(@second)
|
91
|
+
assigns(:digital_assets).should include(digital_asset)
|
92
|
+
# assigns(:digital_assets).entries.count.should be(2)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
context 'sami_code' do
|
96
|
+
before do
|
97
|
+
3.times { FactoryGirl.create :digital_asset, :sami_code => 'SOMETHING.001' }
|
98
|
+
end
|
99
|
+
it 'returns all documents with a particular sami_code' do
|
100
|
+
get :search, :sami => 'SOMETHING.001'
|
101
|
+
assigns(:digital_assets).size.should be(3)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
context 'fund_ids' do
|
105
|
+
before do
|
106
|
+
2.times { FactoryGirl.create :digital_asset, :fund_ids => ['1234', '4567'] }
|
107
|
+
2.times { FactoryGirl.create :digital_asset, :fund_ids => ['1234', '2323'] }
|
108
|
+
1.times { FactoryGirl.create :digital_asset, :fund_ids => ['9999'] }
|
109
|
+
end
|
110
|
+
it 'returns all documents with a particular fund_ids' do
|
111
|
+
get :search, :funds => '1234'
|
112
|
+
assigns(:digital_assets).size.should be(4)
|
113
|
+
end
|
114
|
+
it 'returns all documents for a set of multiple fund_ids' do
|
115
|
+
get :search, :funds => ['1234', '9999']
|
116
|
+
assigns(:digital_assets).size.should be(5)
|
117
|
+
end
|
118
|
+
it 'returns all documents for a set of multiple fund_ids' do
|
119
|
+
get :search, :funds => ['7777', '9999']
|
120
|
+
assigns(:digital_assets).size.should be(1)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
context 'audience' do
|
124
|
+
before do
|
125
|
+
3.times { FactoryGirl.create :digital_asset, :audiences => ['492'] }
|
126
|
+
end
|
127
|
+
it 'returns all documents with a particular audience' do
|
128
|
+
get :search, :audience => '492'
|
129
|
+
assigns(:digital_assets).size.should be(3)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
context 'title' do
|
133
|
+
it 'returns all documents with a particular title' do
|
134
|
+
get :search, :title => 'Doc Title'
|
135
|
+
assigns(:digital_assets).should include(digital_asset)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
context 'guid' do
|
139
|
+
it 'returns all documents with a particular guid' do
|
140
|
+
get :search, :guid => digital_asset.guid
|
141
|
+
assigns(:digital_assets).entries.should == [digital_asset]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
context 'business owner' do
|
145
|
+
it 'returns all documents with a particular business owner' do
|
146
|
+
get :search, :business_owner => 'biz owner'
|
147
|
+
assigns(:digital_assets).should include(digital_asset)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
context "combination searches" do
|
151
|
+
before {5.times {FactoryGirl.create :digital_asset}}
|
152
|
+
it 'returns and-ed results for multiple criteria' do
|
153
|
+
get :search, :guid => digital_asset.guid, :title => digital_asset.title
|
154
|
+
assigns(:digital_assets).entries.should == [digital_asset]
|
155
|
+
end
|
156
|
+
it 'returns multiple results' do
|
157
|
+
get :search, :title => digital_asset.title, :audiences => digital_asset.audiences, :sami => digital_asset.sami_code
|
158
|
+
assigns(:digital_assets).size.should be(6)
|
159
|
+
end
|
160
|
+
it 'returns nothing if not all criteria match' do
|
161
|
+
get :search, :guid => 'blargh-blargh-blargh', :title => 'Doc Title'
|
162
|
+
assigns(:digital_assets).entries.should == []
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe 'sync_assets' do
|
168
|
+
context 'no tuple files' do
|
169
|
+
it 'makes no updates' do
|
170
|
+
pending 'finish specs for DA polling code'
|
171
|
+
# expect {
|
172
|
+
# get :sync_assets
|
173
|
+
# }.to_not change(DigitalAsset, :count)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
context 'bulk file' do
|
177
|
+
before do
|
178
|
+
# touch the bulk file
|
179
|
+
# FileUtils.touch Dir.glob()
|
180
|
+
end
|
181
|
+
it 'updates the count by the # of docs in the bulk' do
|
182
|
+
pending 'add specs for bulk files'
|
183
|
+
# expect {
|
184
|
+
# get :sync_assets
|
185
|
+
# }.to change(DigitalAsset, :count).by(200)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
context 'bulk + selective' do
|
189
|
+
before do
|
190
|
+
# load bulk file into the temp dir
|
191
|
+
# load the selective file into the dir
|
192
|
+
end
|
193
|
+
it 'doesnt re-add existing docs from the selective' do
|
194
|
+
pending 'completion of file polling code'
|
195
|
+
# expect {
|
196
|
+
# get :sync_assets
|
197
|
+
# }.to_not change(DigitalAsset, :count)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|