Sha256: ae44a12cacb481f9aa7120a340a73d477243a7ea10a2619f0b8e52e04bb846e1

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe "Create and use single-use links" do
  include Warden::Test::Helpers
  Warden.test_mode!
  include Sufia::Engine.routes.url_helpers

  before do
    user = User.find_by_email('jilluser@example.com') || FactoryGirl.create(:user)
    
    login_as(user, :scope => :user)

    
    @file = GenericFile.new
    @file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
    @file.apply_depositor_metadata(user)
    @file.save
  end

  it "should generate a single-use link to show the record" do
    visit generate_show_single_use_link_path(:id => @file)
    
    expect(page).to have_css '.single-use-link a'
    find('.single-use-link a').click
    expect(page).to have_content 'world.png'
    expect(page).to have_content "Download (can only be used once)"
  end

  it "should download the file contents" do

    visit generate_download_single_use_link_path(:id => @file)

    expect(page).to have_css '.download-link'
    find('.download-link').click
    expected_content = ActiveFedora::Base.find(@file.pid).content.content
    expect(page.body).to eq expected_content
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sufia-3.3.1 spec/features/single_use_links_spec.rb
sufia-3.3.0 spec/features/single_use_links_spec.rb