Skip to content

Commit

Permalink
Allow downloading subject/classification dumps for 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
marten committed Aug 17, 2015
1 parent 5744cc3 commit 7ed8fa5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/models/medium.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ def url_for_format(format)
end
end

def put_url
def put_url(opts = {})
if external_link
src
else
MediaStorage.put_path(src, indifferent_attributes)
MediaStorage.put_path(src, indifferent_attributes.merge(opts))
end
end

def get_url
def get_url(opts = {})
if external_link
src
else
MediaStorage.get_path(src, indifferent_attributes)
MediaStorage.get_path(src, indifferent_attributes.merge(opts))
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<p>Classification data for <%= @project.display_name %> is ready</p>

<p><a href="<%= @url %>">Click to download your data</a>. This link will be valid for 1 hour.</p>
<p><a href="<%= @url %>">Click to download your data</a>. This link will be valid for 24 hours.</p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Classification data for <%= @project.display_name %> is ready

Download at <%= @url %>. This link will be valid for 1 hour.
Download at <%= @url %>. This link will be valid for 24 hours.
3 changes: 1 addition & 2 deletions app/views/subject_data_mailer/subject_data.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<p>Subject data for <%= @project.display_name %> is ready</p>

<p><a href="<%= @url %>">Click to download your data</a>. This link will be valid for 1 hour.</p>

<p><a href="<%= @url %>">Click to download your data</a>. This link will be valid for 24 hours.</p>
2 changes: 1 addition & 1 deletion app/views/subject_data_mailer/subject_data.text.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Subject data for <%= @project.display_name %> is ready

Download at <%= @url %>. This link will be valid for 1 hour.
Download at <%= @url %>. This link will be valid for 24 hours.
2 changes: 1 addition & 1 deletion app/workers/concerns/dump_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def emails
end

def send_email
mailer.perform_async(@project.id, medium.get_url, emails)
mailer.perform_async(@project.id, medium.get_url(get_expires: 24*60), emails)
end

def to_gzip
Expand Down
10 changes: 10 additions & 0 deletions spec/models/medium_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
.with(anything, be_a(HashWithIndifferentAccess))
medium.put_url
end

it 'should pass opts to MediaStorage' do
expect(MediaStorage).to receive(:put_path).with(anything, hash_including('foo' => 'bar'))
medium.put_url(foo: 'bar')
end
end

context "when externally linked" do
Expand All @@ -111,6 +116,11 @@
.with(anything, be_a(HashWithIndifferentAccess))
medium.get_url
end

it 'should pass opts to MediaStorage' do
expect(MediaStorage).to receive(:get_path).with(anything, hash_including('foo' => 'bar'))
medium.get_url(foo: 'bar')
end
end

context "when externally linked" do
Expand Down

0 comments on commit 7ed8fa5

Please sign in to comment.