Sha256: deec574dca1fc91bdd8fff1af35d941b69cb6d4aa4e25bad9787f78f34e7a6dc

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

require "test_helper"

module GraphQL
  module Voyager
    module Rails
      class ConfigTest < ActiveSupport::TestCase
        class MockViewContext
          def form_authenticity_token
            "abc-123"
          end
        end

        setup do
          @config = GraphQL::Voyager::Rails::Config.new
          @view_context = MockViewContext.new
        end

        test "it adds CSRF header if requested" do
          assert_equal "abc-123", @config.resolve_headers(@view_context)["X-CSRF-Token"]
          @config.csrf = false
          assert_nil @config.resolve_headers(@view_context)["X-CSRF-Token"]
        end

        test "it adds JSON header by default" do
          assert_equal "application/json", @config.resolve_headers(@view_context)["Content-Type"]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-voyager-rails-1.0.2 test/graphql/voyager/config_test.rb
graphql-voyager-rails-1.0.1 test/graphql/voyager/config_test.rb