Sha256: 493d729984c4f1e6daff301b960b3946813e528454c863d7cfb72809b23943ad

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Osso::GraphQL::Schema do
  describe 'EnterpriseAccount' do
    let(:domain) { Faker::Internet.domain_name }
    let(:variables) { { domain: domain } }
    let(:query) do
      <<~GRAPHQL
        query EnterpriseAccount($domain: String!) {
          enterpriseAccount(domain: $domain) {
            domain
              id
              identityProviders {
                id
                service
                domain
                acsUrl
                ssoCert
                ssoUrl
                status
              }
              name
              status
            }
        }
      GRAPHQL
    end

    before do
      create(:enterprise_account)
      create(:enterprise_account, domain: domain)
    end

    subject do
      described_class.execute(
        query,
        variables: variables,
        context: { scope: current_scope },
      )
    end

    describe 'for an admin user' do
      let(:current_scope) { :admin }
      it 'returns Enterprise Account for domain' do
        expect(subject['errors']).to be_nil
        expect(subject.dig('data', 'enterpriseAccount', 'domain')).to eq(domain)
      end
    end

    describe 'for an email scoped user' do
      let(:current_scope) { domain }
      it 'returns Enterprise Account for domain' do
        expect(subject['errors']).to be_nil
        expect(subject.dig('data', 'enterpriseAccount', 'domain')).to eq(domain)
      end
    end

    describe 'for the wrong email scoped user' do
      let(:current_scope) { 'bar.com' }
      it 'returns Enterprise Account for domain' do
        expect(subject['errors']).to be_nil
        expect(subject.dig('data', 'enterpriseAccount')).to be_nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
osso-0.0.3.16 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.15 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.14 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.13 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.12 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.11 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.9 spec/graphql/query/enterprise_account_spec.rb
osso-0.0.3.8 spec/graphql/query/enterprise_account_spec.rb