Skip to content

Commit

Permalink
Fix code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Aug 29, 2017
1 parent 3751111 commit 9681e28
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -46,7 +46,7 @@ end
QueryType = GraphQL::ObjectType.define do
name "Query"

field :posts, !types[PostType] do
field :posts, !types[!PostType] do
argument :user_id, !types.ID
resolve ->(obj, args, ctx) { Post.where(user_id: args[:user_id]) }
end
Expand Down Expand Up @@ -78,7 +78,7 @@ Now you can define `guard` for a field, which will check permissions before reso
QueryType = GraphQL::ObjectType.define do
name "Query"

<b>field :posts</b>, !types[PostType] do
<b>field :posts</b>, !types[!PostType] do
argument :user_id, !types.ID
<b>guard ->(obj, args, ctx) {</b> args[:user_id] == ctx[:current_user].id <b>}</b>
...
Expand Down Expand Up @@ -215,7 +215,7 @@ end
# Use the ability in your guard
PostType = GraphQL::ObjectType.define do
name "Post"
<b>guard ->(post, args, ctx) { ctx[:current_ability].can?(:read, post) }</b>
guard ->(post, args, ctx) { <b>ctx[:current_ability].can?(:read, post)</b> }
...
end

Expand All @@ -236,7 +236,7 @@ end
# Use the ability in your guard
PostType = GraphQL::ObjectType.define do
name "Post"
<b>guard ->(post, args, ctx) { PostPolicy.new(ctx[:current_user], post).show? }</b>
guard ->(post, args, ctx) { <b>PostPolicy.new(ctx[:current_user], post).show?</b> }
...
end

Expand Down Expand Up @@ -268,7 +268,7 @@ It's possible to test fields with `guard` in isolation:
# Your type
QueryType = GraphQL::ObjectType.define do
name "Query"
<b>field :posts</b>, !types[PostType], <b>guard ->(obj, args, ctx) {</b> ... <b>}</b>
<b>field :posts</b>, !types[!PostType], <b>guard ->(obj, args, ctx) {</b> ... <b>}</b>
end

# Your test
Expand All @@ -286,7 +286,7 @@ If you would like to test your fields with policy objects:
# Your type
QueryType = GraphQL::ObjectType.define do
name "Query"
<b>field :posts</b>, !types[PostType]
<b>field :posts</b>, !types[!PostType]
end

# Your policy object
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/inline_schema.rb
Expand Up @@ -10,7 +10,7 @@ module Inline

QueryType = GraphQL::ObjectType.define do
name "Query"
field :posts, !types[PostType] do
field :posts, !types[!PostType] do
argument :user_id, !types.ID
guard ->(_obj, args, ctx) { args[:user_id] == ctx[:current_user].id }
resolve ->(_obj, args, _ctx) { Post.where(user_id: args[:user_id]) }
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/policy_object_schema.rb
Expand Up @@ -9,7 +9,7 @@ module PolicyObject

QueryType = GraphQL::ObjectType.define do
name "Query"
field :posts, !types[PostType] do
field :posts, !types[!PostType] do
argument :user_id, !types.ID
resolve ->(_obj, args, _ctx) { Post.where(user_id: args[:user_id]) }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/graphql/guard_spec.rb
Expand Up @@ -47,7 +47,7 @@
"locations" => [{"line" => 1, "column" => 51}],
"path" => ["posts", 0, "id"]}
])
expect(result['data']).to eq('posts' => [nil])
expect(result['data']).to eq(nil)
end
end

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
@@ -1,13 +1,14 @@
# frozen_string_literal: true

require "bundler/setup"
require "graphql/guard"

if ENV['CI']
require 'coveralls'
Coveralls.wear!
end

require "graphql/guard"

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
Expand Down

0 comments on commit 9681e28

Please sign in to comment.