Sha256: e9909dc518482f4549473dcc12811bb9c0692bab764c2238d62d5c24c2fc83c9

Contents?: true

Size: 1.35 KB

Versions: 33

Compression:

Stored size: 1.35 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: current_context,
      )
    end

    describe 'for an admin user' do
      let(:current_context) do
        { scope: 'admin' }
      end
      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_context) do
        {
          scope: 'end-user',
          email: 'user@foo.com',
        }
      end

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

Version data entries

33 entries across 33 versions & 1 rubygems

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