Sha256: 06b07106dc77fcfa966f2e380d4b46b03045f6d507ed10296de6cf20b38ac97b

Contents?: true

Size: 1.33 KB

Versions: 10

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe Hyrax::SingleUseLinkPresenter do
  subject { described_class.new(link) }

  context "with any kind of link" do
    let(:link) { create(:download_link) }

    describe "#human_readable_expiration" do
      context "in more than one hour" do
        its(:human_readable_expiration) { is_expected.to eq("in 23 hours") }
      end
      context "in less than an hour" do
        before { allow(link).to receive(:expires).and_return(Time.zone.now) }
        its(:human_readable_expiration) { is_expected.to eq("in less than one hour") }
      end
    end

    describe "#short_key" do
      its(:short_key) { is_expected.to eq(link.downloadKey.first(6)) }
    end

    describe "delegated methods" do
      its(:downloadKey) { is_expected.to eq(link.downloadKey) }
      its(:expired?)    { is_expected.to eq(link.expired?) }
      its(:to_param)    { is_expected.to eq(link.to_param) }
    end
  end

  context "with a download link" do
    let(:link)        { create(:download_link) }
    its(:link_type)   { is_expected.to eq("Download") }
    its(:url_helper)  { is_expected.to eq("download_single_use_link_url") }
  end

  context "with a show link" do
    let(:link)        { create(:show_link) }
    its(:link_type)   { is_expected.to eq("Show") }
    its(:url_helper)  { is_expected.to eq("show_single_use_link_url") }
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.1.0 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.5 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.4 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.3 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.2 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.1 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.0.rc2 spec/presenters/hyrax/single_use_link_presenter_spec.rb
hyrax-1.0.0.rc1 spec/presenters/hyrax/single_use_link_presenter_spec.rb
test_hyrax-0.0.1.alpha spec/presenters/hyrax/single_use_link_presenter_spec.rb