Sha256: ca8eb70bc8708c6dcd0b9f71ff2254ad87bfc394bc069c8775ee2916c7d35839

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'


describe Lockup::LockupController do
  routes { Lockup::Engine.routes }

  describe 'a malicious user posts invalid data' do
    it 'does not fail' do
      post 'unlock', params: {foo: 'bar'}
    end
  end

  describe 'a malicious user requests a format that is not HTML' do
    it 'throws an unknown format error' do
      lambda { get 'unlock', format: 'text' }.should raise_error(ActionController::UnknownFormat)
    end
  end

  describe "#cookie_lifetime" do
    context "COOKIE_LIFETIME_IN_WEEKS is set to an integer" do
      before { ENV['COOKIE_LIFETIME_IN_WEEKS'] = '52' }

      it "returns the integer" do
        controller.send(:lockup_cookie_lifetime).should eq(52.weeks)
      end
    end

    context "COOKIE_LIFETIME_IN_WEEKS is not a valid integer" do
      before { ENV['COOKIE_LIFETIME_IN_WEEKS'] = 'invalid value' }

      it "returns the integer" do
        controller.send(:lockup_cookie_lifetime).should eq(5.years)
      end
    end

    context "COOKIE_LIFETIME_IN_WEEKS is not set" do
      before { ENV.delete('COOKIE_LIFETIME_IN_WEEKS') }

      it "returns the integer" do
        controller.send(:lockup_cookie_lifetime).should eq(5.years)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lockup-1.7.1 spec/controllers/lockup/lockup_controller_spec.rb
lockup-1.7 spec/controllers/lockup/lockup_controller_spec.rb
lockup-1.6.1 spec/controllers/lockup/lockup_controller_spec.rb
lockup-1.6 spec/controllers/lockup/lockup_controller_spec.rb
lockup-1.5.1 spec/controllers/lockup/lockup_controller_spec.rb
lockup-1.5 spec/controllers/lockup/lockup_controller_spec.rb