Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow downloading subject/classification dumps for 24 hours #1275

Merged
merged 1 commit into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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