Sha256: 92e674ad129bf7256f77e4961f9d4afd7db3d4242eecbeddb15839de553dd413

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

    let(:mutation) do
      <<~GRAPHQL
         mutation CreateOauthClient($input: CreateOauthClientInput!) {
          createOauthClient(input: $input) {
            oauthClient {
              id
              name
              clientId
              clientSecret
            }
          }
        }
      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 OauthClient' do
        expect { subject }.to change { Osso::Models::OauthClient.count }.by(1)
        expect(subject.dig('data', 'createOauthClient', 'oauthClient', 'clientId')).
          to_not be_nil
      end
    end

    describe 'for an email scoped user' do
      let(:current_scope) { 'foo.com' }

      it 'does not create an OauthClient Account' do
        expect { subject }.to_not(change { Osso::Models::OauthClient.count })
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
osso-0.0.3.16 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.15 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.14 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.13 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.12 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.11 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.9 spec/graphql/mutations/create_oauth_client_spec.rb