Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-08-16 16:04:41 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-06-05 21:47:42 +0300
commit9c6c17cbcdb8bf8185fc1b873dcfd08f723e4df5 (patch)
tree624dba30e87ed0ea39afa0535d92c37c7718daef /spec/graphql/types
parent67dc43db2f30095cce7fe01d7f475d084be936e8 (diff)
Add a minimal GraphQL API
Diffstat (limited to 'spec/graphql/types')
-rw-r--r--spec/graphql/types/query_type_spec.rb37
-rw-r--r--spec/graphql/types/time_type_spec.rb16
2 files changed, 53 insertions, 0 deletions
diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb
new file mode 100644
index 00000000000..17d9395504c
--- /dev/null
+++ b/spec/graphql/types/query_type_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe GitlabSchema.types['Query'] do
+ it 'is called Query' do
+ expect(described_class.name).to eq('Query')
+ end
+
+ it { is_expected.to have_graphql_fields(:project, :merge_request, :echo) }
+
+ describe 'project field' do
+ subject { described_class.fields['project'] }
+
+ it 'finds projects by full path' do
+ is_expected.to have_graphql_arguments(:full_path)
+ is_expected.to have_graphql_type(Types::ProjectType)
+ is_expected.to have_graphql_resolver(Loaders::FullPathLoader[:project])
+ end
+
+ it 'authorizes with read_project' do
+ is_expected.to require_graphql_authorizations(:read_project)
+ end
+ end
+
+ describe 'merge_request field' do
+ subject { described_class.fields['merge_request'] }
+
+ it 'finds MRs by project and IID' do
+ is_expected.to have_graphql_arguments(:project, :iid)
+ is_expected.to have_graphql_type(Types::MergeRequestType)
+ is_expected.to have_graphql_resolver(Loaders::IidLoader[:merge_request])
+ end
+
+ it 'authorizes with read_merge_request' do
+ is_expected.to require_graphql_authorizations(:read_merge_request)
+ end
+ end
+end
diff --git a/spec/graphql/types/time_type_spec.rb b/spec/graphql/types/time_type_spec.rb
new file mode 100644
index 00000000000..087655cc67d
--- /dev/null
+++ b/spec/graphql/types/time_type_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe GitlabSchema.types['Time'] do
+ let(:float) { 1504630455.96215 }
+ let(:time) { Time.at(float) }
+
+ it { expect(described_class.name).to eq('Time') }
+
+ it 'coerces Time into fractional seconds since epoch' do
+ expect(described_class.coerce_isolated_result(time)).to eq(float)
+ end
+
+ it 'coerces fractional seconds since epoch into Time' do
+ expect(described_class.coerce_isolated_input(float)).to eq(time)
+ end
+end