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.0.5.pre.alpha spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.4 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.27 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.26 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.25 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.24 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.23 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.22 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.21 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.20 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.19 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.18 spec/graphql/mutations/create_oauth_client_spec.rb
osso-0.0.3.17 spec/graphql/mutations/create_oauth_client_spec.rb