Sha256: 0e3e3a18de37d49a1996b24c687f2ec4574e260e07429d38c5a3d7d78ad22bb2

Contents?: true

Size: 1.87 KB

Versions: 33

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Osso::GraphQL::Schema do
  describe 'DeleteEnterpriseAccount' do
    let(:domain) { Faker::Internet.domain_name }
    let!(:enterprise_account) { create(:enterprise_account, domain: domain) }
    let(:variables) do
      {
        input: {
          id: enterprise_account.id,
        },
      }
    end

    let(:mutation) do
      <<~GRAPHQL
         mutation DeleteEnterpriseAccount($input: DeleteEnterpriseAccountInput!) {
          deleteEnterpriseAccount(input: $input) {
            enterpriseAccount {
              id
            }
          }
        }
      GRAPHQL
    end

    subject do
      described_class.execute(
        mutation,
        variables: variables,
        context: current_context,
      )
    end

    describe 'for an admin user' do
      let(:current_context) do
        { scope: 'admin' }
      end

      it 'deletes an Enterprise Account' do
        expect { subject }.to change { Osso::Models::EnterpriseAccount.count }.by(-1)
        expect(subject.dig('data', 'createEnterpriseAccount', 'enterpriseAccount')).
          to be_nil
      end
    end

    describe 'for an email scoped user' do
      let(:current_context) do
        {
          scope: 'end-user',
          email: "user@#{domain}",
        }
      end

      it 'deletes the Enterprise Account' do
        expect { subject }.to change { Osso::Models::EnterpriseAccount.count }.by(-1)
        expect(subject.dig('data', 'createEnterpriseAccount', 'enterpriseAccount')).
          to be_nil
      end
    end

    describe 'for the wrong email scoped user' do
      let(:current_context) do
        {
          scope: 'end-user',
          email: 'user@foo.com',
        }
      end

      it 'does not delete the Enterprise Account' do
        expect { subject }.to_not(change { Osso::Models::EnterpriseAccount.count })
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
osso-0.1.2 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.1.1 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.1.0 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.11 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.10 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.8 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.7 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.6 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.6.alpha spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5 spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.lambda spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.kappa spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.iota spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.theta spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.eta spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.zeta spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.epsilon spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.delta spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.gamma spec/graphql/mutations/delete_enterprise_account_spec.rb
osso-0.0.5.pre.beta spec/graphql/mutations/delete_enterprise_account_spec.rb