Sha256: b5f7933b5a8ddbe4801a924de93db01f6faaedbeaa1f7cdc2aee379385d16446

Contents?: true

Size: 1.82 KB

Versions: 10

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Osso::GraphQL::Schema do
  describe 'CreateIdentityProvider' do
    let(:domain) { Faker::Internet.domain_name }
    let(:variables) do
      {
        input: {
          name: Faker::Company.name,
          domain: domain,
        },
      }
    end

    let(:mutation) do
      <<~GRAPHQL
         mutation CreateEnterpriseAccount($input: CreateEnterpriseAccountInput!) {
          createEnterpriseAccount(input: $input) {
            enterpriseAccount {
              id
              domain
              name
              status
            }
          }
        }
      GRAPHQL
    end

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

    describe 'for an admin user' do
      let(:current_scope) { :admin }
      it 'creates an Enterprise Account' do
        expect { subject }.to change { Osso::Models::EnterpriseAccount.count }.by(1)
        expect(subject.dig('data', 'createEnterpriseAccount', 'enterpriseAccount', 'domain')).
          to eq(domain)
      end
    end

    describe 'for an email scoped user' do
      let(:current_scope) { domain }

      it 'creates an Enterprise Account' do
        expect { subject }.to change { Osso::Models::EnterpriseAccount.count }.by(1)
        expect(subject.dig('data', 'createEnterpriseAccount', 'enterpriseAccount', 'domain')).
          to eq(domain)
      end
    end
    describe 'for the wrong email scoped user' do
      let(:current_scope) { 'foo.com' }

      it 'does not create an Enterprise Account' do
        expect { subject }.to_not(change { Osso::Models::EnterpriseAccount.count })
        expect(subject.dig('data', 'createEnterpriseAccount', 'enterpriseAccount', 'domain')).
          to be_nil
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
osso-0.0.3.16 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.15 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.14 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.13 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.12 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.11 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.9 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.8 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.7 spec/graphql/mutations/create_enterprise_account_spec.rb
osso-0.0.3.6 spec/graphql/mutations/create_enterprise_account_spec.rb