Sha256: 191208953fa14ceca8247b467021b471b9e02f67c3c2ef5bd5b3c68fa71ba84d

Contents?: true

Size: 1.52 KB

Versions: 17

Compression:

Stored size: 1.52 KB

Contents

module OpenStax
  module Accounts
    describe Configuration do

      let!(:config) { Configuration.new.tap {|c| c.openstax_accounts_url = "https://accounts.openstax.org"} }
      let!(:a_fake_request) { OpenStruct.new(url: "http://foo.com") }

      it "returns the default logout redirect when no explicit URL is set" do
        expect(config.logout_redirect_url(a_fake_request)).to eq "https://accounts.openstax.org/logout"
      end

      it "returns an explicitly-set string logout redirect URL when set" do
        config.logout_redirect_url = "blah"
        expect(config.logout_redirect_url(a_fake_request)).to eq "blah"
      end

      it "returns the default URL when Proc logout redirect URL set and returns nil" do
        config.logout_redirect_url = ->(request) { nil }
        expect(config.logout_redirect_url(a_fake_request)).to eq "https://accounts.openstax.org/logout"
      end

      it "returns the Proc URL when Proc logout redirect URL set and returns non-nil" do
        config.logout_redirect_url = ->(request) { "howdy" }
        expect(config.logout_redirect_url(a_fake_request)).to eq "howdy"
      end

      it "says return_to urls not approved when nil" do
        config.return_to_url_approver = ->(url) { true }
        expect(config.is_return_to_url_approved?(nil)).to be_falsy
      end

      it "says return_to urls not approved when approver nil" do
        config.return_to_url_approver = nil
        expect(config.is_return_to_url_approved?("http://www.google.com")).to be_falsy
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
openstax_accounts-7.9.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.8.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.7.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.6.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.5.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.4.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.3.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.2.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.1.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.0.1 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-7.0.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-6.4.2 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-6.4.1 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-6.4.0 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-6.3.2 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-6.3.1 spec/lib/openstax/accounts/configuration_spec.rb
openstax_accounts-6.3.0 spec/lib/openstax/accounts/configuration_spec.rb