Sha256: 823ba0d8c4a91c4a7ba0d822b335a8242661dbe520c1d2683d9a13701dde97a7

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe Subscription do
  before do
    client
  end

  context 'new' do

    subject { User.subscriptions.first }

    it 'returns a subscription for current user' do
      expect(subject).to_not be_nil
      expect(subject).to be_a Subscription
    end

    it 'parses info on user correctly' do
      # Test variables from this specific API call.
      # Might break if vcr recording is deleted. If so, use new values
      expect(subject.id).to eq "s29729296"
      expect(subject.description).to eq "Monthly Subscription"
      expect(subject.expiration_time).to eq DateTime.parse("2016-12-28T09:36:49-05:00")
      expect(subject.price_per_download).to be nil
      expect(subject.license).to eq "standard"
      expect(subject.allotment).to be nil
      expect(subject.formats).to be_a Array
      expect(subject.formats.first).to be_a SubscriptionLicenseFormat
      expect(subject.metadata).to eq nil
    end
  end

  context 'allows_image_size_download?' do

    subject { User.subscriptions.active.first }

    it "correctly finds if image size is possible by this subscription" do
      expect(subject.allows_image_size_download?("small")).to be true
      expect(subject.allows_image_size_download?("made_up_size")).to be false
    end

  end

  context 'expired?' do

    subject { Subscription.new("id" => "s1", "expiration_time" => "2016-12-28T09:36:49-05:00") }

    it "correctly calculates not expired plan" do
      allow(DateTime).to receive(:now).and_return(DateTime.parse("2015-12-28T09:36:49-05:00"))

      expect(subject.expired?).to be false
    end

    it "correctly calculates not expired plan" do
      allow(DateTime).to receive(:now).and_return(DateTime.parse("2017-12-28T09:36:49-05:00"))

      expect(subject.expired?).to be true
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shutterstock-v2-0.0.1 spec/client/subscription_spec.rb