File: connection_spec.rb

package info (click to toggle)
ruby-graphql 2.5.19-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,868 kB
  • sloc: ruby: 80,420; ansic: 1,808; yacc: 845; javascript: 480; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Pagination::Connection do
  describe "was_authorized_by_scope_ites?" do
    it "doesn't raise an error for missing runtime state and it updates it if context is assigned later" do
      context = GraphQL::Query.new(GraphQL::Schema, "{ __typename }").context
      conn = GraphQL::Pagination::Connection.new([], context: context)
      assert_nil conn.was_authorized_by_scope_items?

      conn.context = context
      assert_nil conn.was_authorized_by_scope_items?

      Fiber[:__graphql_runtime_info] = { context.query => OpenStruct.new(was_authorized_by_scope_items: true) }
      conn.context = context
      assert_equal true, conn.was_authorized_by_scope_items?
    ensure
      Fiber[:__graphql_runtime_info] = nil
    end
  end
end