Sha256: a70fdea764022fef178cf5cfa26cd4046f32d7d92a1f96d0c1bef8b1c13b2866

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'
require 'gds-sso/user'
require 'gds-sso/lint/user_spec'

require 'ostruct'

describe GDS::SSO::User do
  before :each do
    @auth_hash = {
      'provider' => 'gds',
      'uid' => 'abcde',
      'credentials' => {'token' => 'abcdefg', 'secret' => 'abcdefg'},
      'info' => {'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk'},
      'extra' => {
        'user' => {
          'permissions' => [], 'organisation_slug' => nil, "organisation_content_id" => nil, 'disabled' => false
        }
      }
    }
  end

  it "should extract the user params from the oauth hash" do
    expected = {'uid' => 'abcde',
      'name' => 'Matt Patterson',
      'email' => 'matt@alphagov.co.uk',
      "permissions" => [],
      "organisation_slug" => nil,
      "organisation_content_id" => nil,
      'disabled' => false,
    }
    expect(GDS::SSO::User.user_params_from_auth_hash(@auth_hash)).to eq(expected)
  end

  context "making sure that the lint spec is valid" do
    class TestUser < OpenStruct
      include GDS::SSO::User

      def self.where(opts)
        []
      end

      def self.create!(options, scope = {})
        new(options)
      end

      def update_attribute(key, value)
        send("#{key}=".to_sym, value)
      end

      def update_attributes(options)
        options.each do |key, value|
          update_attribute(key, value)
        end
      end

      def remotely_signed_out?
        remotely_signed_out
      end
    end

    let(:described_class) { TestUser }
    it_behaves_like "a gds-sso user class"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gds-sso-12.1.0 spec/unit/user_spec.rb
gds-sso-12.0.0 spec/unit/user_spec.rb
gds-sso-11.2.1 spec/unit/user_spec.rb
gds-sso-11.2.0 spec/unit/user_spec.rb
gds-sso-11.1.0 spec/unit/user_spec.rb
gds-sso-11.0.0 spec/unit/user_spec.rb
gds-sso-10.1.0 spec/unit/user_spec.rb