Sha256: 2eb7492f29a8f764220557a0c258287f6af8007dd99e57d3e5e21f71d924507d

Contents?: true

Size: 1.68 KB

Versions: 28

Compression:

Stored size: 1.68 KB

Contents

require 'test_puppet_helper'

module Queries
  class PuppetclassQueryTest < GraphQLQueryTestCase
    let(:query) do
      <<-GRAPHQL
      query (
        $id: String!
      ) {
        puppetclass(id: $id) {
          id
          createdAt
          updatedAt
          name
          environments {
            totalCount
            edges {
              node {
                id
              }
            }
          }
          locations {
            totalCount
            edges {
              node {
                id
              }
            }
          }
          organizations {
            totalCount
            edges {
              node {
                id
              }
            }
          }
        }
      }
      GRAPHQL
    end

    let(:environment) { FactoryBot.create(:environment) }
    let(:puppetclass) { FactoryBot.create(:puppetclass) }

    let(:global_id) { Foreman::GlobalId.for(puppetclass) }
    let(:variables) { { id: global_id } }
    let(:data) { result['data']['puppetclass'] }

    setup do
      FactoryBot.create(:environment_class, puppetclass: puppetclass, environment: environment)
    end

    test 'fetching puppetclass attributes' do
      assert_empty result['errors']

      expect(data['id']).must_equal global_id
      expect(data['createdAt']).must_equal puppetclass.created_at.utc.iso8601
      expect(data['updatedAt']).must_equal puppetclass.updated_at.utc.iso8601
      expect(data['name']).must_equal puppetclass.name

      assert_collection puppetclass.environments, data['environments']
      assert_collection puppetclass.locations, data['locations']
      assert_collection puppetclass.organizations, data['organizations']
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
foreman_puppet-8.0.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.4.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-7.0.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.3.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.2.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.1.1 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-5.1.3 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.1.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.0.1 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-6.0.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-5.1.2 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-4.1.1 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-5.1.1 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-5.1.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-4.1.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-4.0.4 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-5.0.0 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-4.0.3 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-4.0.2 test/graphql/queries/puppetclass_query_test.rb
foreman_puppet-3.0.7 test/graphql/queries/puppetclass_query_test.rb