curation_concerns 0.12.0.pre8 → 0.12.0.pre9
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/app/actors/curation_concerns/file_set_actor.rb +13 -0
- data/app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb +4 -14
- data/config/routes.rb +2 -2
- data/lib/curation_concerns/version.rb +1 -1
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +9 -4
- data/spec/controllers/curation_concerns/single_use_links_controller_spec.rb +10 -10
- data/spec/routing/curation_concerns/routes_spec.rb +4 -4
- metadata +2 -6
- data/app/views/curation_concerns/single_use_links/new_download.html.erb +0 -5
- data/app/views/curation_concerns/single_use_links/new_show.html.erb +0 -5
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eab5f25a1495de88c62656c40d9261594057c45
|
4
|
+
data.tar.gz: d2cc26ee39bd02be81ade88945c8ef17082f6eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb783ae9f39849fe73f11ececb03330d491632dc0cec1e9d522070d547ebd06bc28728d7162d61907660361b88e59f25fc1571fbed711945415244f66c9b8e6
|
7
|
+
data.tar.gz: b042084b5e0fe0509620b6b6fe42b82f595b22317df8b1a664591e7f6885e97ca4d9c0b3abd15a7aa1e9380acdaad8f73aa796136453a463b499024cc7fa2f4d
|
@@ -76,6 +76,7 @@ module CurationConcerns
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def destroy
|
79
|
+
unlink_from_work
|
79
80
|
file_set.destroy
|
80
81
|
CurationConcerns.config.callback.run(:after_destroy, file_set.id, user)
|
81
82
|
end
|
@@ -142,5 +143,17 @@ module CurationConcerns
|
|
142
143
|
return unless work.thumbnail_id.blank?
|
143
144
|
work.thumbnail = file_set
|
144
145
|
end
|
146
|
+
|
147
|
+
def unlink_from_work
|
148
|
+
work = file_set.in_works.first
|
149
|
+
return unless work && (work.thumbnail_id == file_set.id || work.representative_id == file_set.id)
|
150
|
+
# This is required to clear the thumbnail_id and representative_id fields on the work
|
151
|
+
# and force it to be re-solrized. Although ActiveFedora::Aggregation clears the
|
152
|
+
# children nodes it leaves the GenericWork.thumbnail_id and GenericWork.representative_id
|
153
|
+
# fields in Solr populated.
|
154
|
+
work.thumbnail = nil if work.thumbnail_id == file_set.id
|
155
|
+
work.representative = nil if work.representative_id == file_set.id
|
156
|
+
work.save!
|
157
|
+
end
|
145
158
|
end
|
146
159
|
end
|
@@ -15,24 +15,14 @@ module CurationConcerns
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def create_download
|
19
19
|
@su = SingleUseLink.create itemId: params[:id], path: main_app.download_path(id: asset)
|
20
|
-
|
21
|
-
|
22
|
-
respond_to do |format|
|
23
|
-
format.html
|
24
|
-
format.js { render js: @link }
|
25
|
-
end
|
20
|
+
render text: curation_concerns.download_single_use_link_url(@su.downloadKey)
|
26
21
|
end
|
27
22
|
|
28
|
-
def
|
23
|
+
def create_show
|
29
24
|
@su = SingleUseLink.create itemId: params[:id], path: polymorphic_path([main_app, asset])
|
30
|
-
|
31
|
-
|
32
|
-
respond_to do |format|
|
33
|
-
format.html
|
34
|
-
format.js { render js: @link }
|
35
|
-
end
|
25
|
+
render text: curation_concerns.show_single_use_link_url(@su.downloadKey)
|
36
26
|
end
|
37
27
|
|
38
28
|
protected
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
CurationConcerns::Engine.routes.draw do
|
2
2
|
get 'single_use_link/show/:id' => 'single_use_links_viewer#show', as: :show_single_use_link
|
3
3
|
get 'single_use_link/download/:id' => 'single_use_links_viewer#download', as: :download_single_use_link
|
4
|
-
|
5
|
-
|
4
|
+
post 'single_use_link/generate_download/:id' => 'single_use_links#create_download', as: :generate_download_single_use_link
|
5
|
+
post 'single_use_link/generate_show/:id' => 'single_use_links#create_show', as: :generate_show_single_use_link
|
6
6
|
|
7
7
|
# mount BrowseEverything::Engine => '/remote_files/browse'
|
8
8
|
resources :classify_concerns, only: [:new, :create]
|
@@ -151,21 +151,26 @@ describe CurationConcerns::FileSetActor do
|
|
151
151
|
expect { file_set.reload }.to raise_error ActiveFedora::ObjectNotFoundError
|
152
152
|
end
|
153
153
|
|
154
|
-
context "representative of a work" do
|
154
|
+
context "representative and thumbnail of a work" do
|
155
155
|
let!(:work) do
|
156
156
|
work = create(:generic_work)
|
157
157
|
# this is not part of a block on the create, since the work must be saved
|
158
158
|
# before the representative can be assigned
|
159
159
|
work.ordered_members << file_set
|
160
160
|
work.representative = file_set
|
161
|
+
work.thumbnail = file_set
|
161
162
|
work.save
|
162
163
|
work
|
163
164
|
end
|
164
165
|
|
165
|
-
it "removes representative and the proxy association" do
|
166
|
-
|
166
|
+
it "removes representative, thumbnail, and the proxy association" do
|
167
|
+
gw = GenericWork.load_instance_from_solr(work.id)
|
168
|
+
expect(gw.representative_id).to eq(file_set.id)
|
169
|
+
expect(gw.thumbnail_id).to eq(file_set.id)
|
167
170
|
expect { actor.destroy }.to change { ActiveFedora::Aggregation::Proxy.count }.by(-1)
|
168
|
-
|
171
|
+
gw = GenericWork.load_instance_from_solr(work.id)
|
172
|
+
expect(gw.representative_id).to be_nil
|
173
|
+
expect(gw.thumbnail_id).to be_nil
|
169
174
|
end
|
170
175
|
end
|
171
176
|
end
|
@@ -21,17 +21,17 @@ describe CurationConcerns::SingleUseLinksController, type: :controller do
|
|
21
21
|
|
22
22
|
describe "GET 'download'" do
|
23
23
|
it "and_return http success" do
|
24
|
-
|
24
|
+
post 'create_download', id: file
|
25
25
|
expect(response).to be_success
|
26
|
-
expect(
|
26
|
+
expect(response.body).to eq download_single_use_link_url(hash)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "GET 'show'" do
|
31
31
|
it "and_return http success" do
|
32
|
-
|
32
|
+
post 'create_show', id: file
|
33
33
|
expect(response).to be_success
|
34
|
-
expect(
|
34
|
+
expect(response.body).to eq show_single_use_link_url(hash)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -40,22 +40,22 @@ describe CurationConcerns::SingleUseLinksController, type: :controller do
|
|
40
40
|
before do
|
41
41
|
@other_user = create(:user)
|
42
42
|
file.read_users << @other_user
|
43
|
-
file.save
|
43
|
+
file.save!
|
44
44
|
sign_in @other_user
|
45
45
|
file.read_users << @other_user
|
46
|
-
file.save
|
46
|
+
file.save!
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "GET 'download'" do
|
50
50
|
it "and_return http success" do
|
51
|
-
|
51
|
+
post 'create_download', id: file
|
52
52
|
expect(response).not_to be_success
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "GET 'show'" do
|
57
57
|
it "and_return http success" do
|
58
|
-
|
58
|
+
post 'create_show', id: file
|
59
59
|
expect(response).not_to be_success
|
60
60
|
end
|
61
61
|
end
|
@@ -64,14 +64,14 @@ describe CurationConcerns::SingleUseLinksController, type: :controller do
|
|
64
64
|
describe "unknown user" do
|
65
65
|
describe "GET 'download'" do
|
66
66
|
it "and_return http failure" do
|
67
|
-
|
67
|
+
post 'create_download', id: file
|
68
68
|
expect(response).not_to be_success
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "GET 'show'" do
|
73
73
|
it "and_return http failure" do
|
74
|
-
|
74
|
+
post 'create_show', id: file
|
75
75
|
expect(response).not_to be_success
|
76
76
|
end
|
77
77
|
end
|
@@ -29,14 +29,14 @@ module CurationConcerns
|
|
29
29
|
|
30
30
|
describe 'Single Use Link Generator' do
|
31
31
|
routes { CurationConcerns::Engine.routes }
|
32
|
-
it 'routes to #
|
32
|
+
it 'routes to #create_show' do
|
33
33
|
expect(generate_show_single_use_link_path('abc123')).to eq '/single_use_link/generate_show/abc123'
|
34
|
-
expect(
|
34
|
+
expect(post("/single_use_link/generate_show/abc123")).to route_to("curation_concerns/single_use_links#create_show", id: 'abc123')
|
35
35
|
end
|
36
36
|
|
37
|
-
it 'routes to #
|
37
|
+
it 'routes to #create_download' do
|
38
38
|
expect(generate_download_single_use_link_path('abc123')).to eq '/single_use_link/generate_download/abc123'
|
39
|
-
expect(
|
39
|
+
expect(post("/single_use_link/generate_download/abc123")).to route_to("curation_concerns/single_use_links#create_download", id: 'abc123')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curation_concerns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.0.
|
4
|
+
version: 0.12.0.pre9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-04-
|
13
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|
@@ -924,8 +924,6 @@ files:
|
|
924
924
|
- app/views/curation_concerns/file_sets/upload/_form_fields.html.erb
|
925
925
|
- app/views/curation_concerns/file_sets/upload/_script_templates.html.erb
|
926
926
|
- app/views/curation_concerns/permissions/confirm.html.erb
|
927
|
-
- app/views/curation_concerns/single_use_links/new_download.html.erb
|
928
|
-
- app/views/curation_concerns/single_use_links/new_show.html.erb
|
929
927
|
- app/views/curation_concerns/single_use_links_viewer/show.html.erb
|
930
928
|
- app/views/embargoes/_embargo_history.html.erb
|
931
929
|
- app/views/embargoes/_list_active_embargoes.html.erb
|
@@ -1198,7 +1196,6 @@ files:
|
|
1198
1196
|
- spec/views/layouts/error.html.erb_spec.rb
|
1199
1197
|
- spec/views/shared/_add_content.html.erb_spec.rb
|
1200
1198
|
- spec/views/shared/_my_actions.html.erb_spec.rb
|
1201
|
-
- spec/views/single_use_links/new_download.html.erb_spec.rb
|
1202
1199
|
- spec/views/single_use_links_viewer/show.html.erb_spec.rb
|
1203
1200
|
- tasks/jasmine.rake
|
1204
1201
|
- vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png
|
@@ -1398,5 +1395,4 @@ test_files:
|
|
1398
1395
|
- spec/views/layouts/error.html.erb_spec.rb
|
1399
1396
|
- spec/views/shared/_add_content.html.erb_spec.rb
|
1400
1397
|
- spec/views/shared/_my_actions.html.erb_spec.rb
|
1401
|
-
- spec/views/single_use_links/new_download.html.erb_spec.rb
|
1402
1398
|
- spec/views/single_use_links_viewer/show.html.erb_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'curation_concerns/single_use_links/new_download.html.erb' do
|
4
|
-
let(:user) { create(:user) }
|
5
|
-
|
6
|
-
let(:f) do
|
7
|
-
file = FileSet.create do |gf|
|
8
|
-
gf.apply_depositor_metadata(user)
|
9
|
-
end
|
10
|
-
Hydra::Works::AddFileToFileSet.call(file, File.open(fixture_path + '/world.png'), :original_file)
|
11
|
-
file
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:hash) { "some-dummy-sha2-hash" }
|
15
|
-
|
16
|
-
before do
|
17
|
-
assign :asset, f
|
18
|
-
assign :link, CurationConcerns::Engine.routes.url_helpers.download_single_use_link_path(hash)
|
19
|
-
render
|
20
|
-
end
|
21
|
-
|
22
|
-
it "has the download link" do
|
23
|
-
expect(rendered).to have_selector "a.download-link"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "has turbolinks disabled in the download link" do
|
27
|
-
expect(rendered).to have_selector "a.download-link[data-no-turbolink]"
|
28
|
-
end
|
29
|
-
end
|