Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
44b7005b
Commit
44b7005b
authored
Aug 21, 2020
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up access error specs with shared examples
Moves specs over to using shared_example to avoid duplication..
parent
d7dd2d72
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
29 additions
and
74 deletions
+29
-74
ee/spec/requests/api/graphql/mutations/clusters/agents/create_spec.rb
...ests/api/graphql/mutations/clusters/agents/create_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/epics/add_issue_spec.rb
...ec/requests/api/graphql/mutations/epics/add_issue_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/epics/create_spec.rb
ee/spec/requests/api/graphql/mutations/epics/create_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/epics/set_subscription_spec.rb
...ests/api/graphql/mutations/epics/set_subscription_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/epics/update_spec.rb
ee/spec/requests/api/graphql/mutations/epics/update_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/iterations/create_spec.rb
.../requests/api/graphql/mutations/iterations/create_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/iterations/update_spec.rb
.../requests/api/graphql/mutations/iterations/update_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/requirements_management/create_requirement_spec.rb
...ations/requirements_management/create_requirement_spec.rb
+1
-3
ee/spec/requests/api/graphql/mutations/requirements_management/update_requirement_spec.rb
...ations/requirements_management/update_requirement_spec.rb
+1
-3
spec/requests/api/graphql/mutations/award_emojis/add_spec.rb
spec/requests/api/graphql/mutations/award_emojis/add_spec.rb
+1
-3
spec/requests/api/graphql/mutations/award_emojis/remove_spec.rb
...equests/api/graphql/mutations/award_emojis/remove_spec.rb
+1
-3
spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb
...equests/api/graphql/mutations/award_emojis/toggle_spec.rb
+1
-3
spec/requests/api/graphql/mutations/boards/lists/update_spec.rb
...equests/api/graphql/mutations/boards/lists/update_spec.rb
+1
-2
spec/requests/api/graphql/mutations/branches/create_spec.rb
spec/requests/api/graphql/mutations/branches/create_spec.rb
+1
-2
spec/requests/api/graphql/mutations/commits/create_spec.rb
spec/requests/api/graphql/mutations/commits/create_spec.rb
+1
-2
spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb
.../api/graphql/mutations/discussions/toggle_resolve_spec.rb
+1
-2
spec/requests/api/graphql/mutations/issues/set_locked_spec.rb
.../requests/api/graphql/mutations/issues/set_locked_spec.rb
+1
-6
spec/requests/api/graphql/mutations/issues/update_spec.rb
spec/requests/api/graphql/mutations/issues/update_spec.rb
+1
-2
spec/requests/api/graphql/mutations/merge_requests/create_spec.rb
...uests/api/graphql/mutations/merge_requests/create_spec.rb
+1
-2
spec/requests/api/graphql/mutations/notes/destroy_spec.rb
spec/requests/api/graphql/mutations/notes/destroy_spec.rb
+1
-2
spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb
...pi/graphql/mutations/notes/update/image_diff_note_spec.rb
+1
-2
spec/requests/api/graphql/mutations/notes/update/note_spec.rb
.../requests/api/graphql/mutations/notes/update/note_spec.rb
+1
-2
spec/requests/api/graphql/mutations/todos/mark_all_done_spec.rb
...equests/api/graphql/mutations/todos/mark_all_done_spec.rb
+1
-2
spec/requests/api/graphql/mutations/todos/mark_done_spec.rb
spec/requests/api/graphql/mutations/todos/mark_done_spec.rb
+3
-6
spec/requests/api/graphql/mutations/todos/restore_spec.rb
spec/requests/api/graphql/mutations/todos/restore_spec.rb
+3
-6
No files found.
ee/spec/requests/api/graphql/mutations/clusters/agents/create_spec.rb
View file @
44b7005b
...
@@ -21,9 +21,7 @@ RSpec.describe 'Create a new cluster agent' do
...
@@ -21,9 +21,7 @@ RSpec.describe 'Create a new cluster agent' do
end
end
context
'without project permissions'
do
context
'without project permissions'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not create cluster agent'
do
it
'does not create cluster agent'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Clusters
::
Agent
,
:count
)
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Clusters
::
Agent
,
:count
)
...
...
ee/spec/requests/api/graphql/mutations/epics/add_issue_spec.rb
View file @
44b7005b
...
@@ -18,9 +18,7 @@ RSpec.describe 'Add an issue to an Epic' do
...
@@ -18,9 +18,7 @@ RSpec.describe 'Add an issue to an Epic' do
end
end
shared_examples
'mutation without access'
do
shared_examples
'mutation without access'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not add issue to the epic'
do
it
'does not add issue to the epic'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
...
...
ee/spec/requests/api/graphql/mutations/epics/create_spec.rb
View file @
44b7005b
...
@@ -35,9 +35,7 @@ RSpec.describe 'Creating an Epic' do
...
@@ -35,9 +35,7 @@ RSpec.describe 'Creating an Epic' do
stub_licensed_features
(
epics:
true
)
stub_licensed_features
(
epics:
true
)
end
end
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not create epic'
do
it
'does not create epic'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Epic
,
:count
)
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Epic
,
:count
)
...
...
ee/spec/requests/api/graphql/mutations/epics/set_subscription_spec.rb
View file @
44b7005b
...
@@ -21,9 +21,7 @@ RSpec.describe 'Set an Epic Subscription' do
...
@@ -21,9 +21,7 @@ RSpec.describe 'Set an Epic Subscription' do
end
end
context
'when epics feature is disabled'
do
context
'when epics feature is disabled'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not subscribe user to the epic'
do
it
'does not subscribe user to the epic'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
...
...
ee/spec/requests/api/graphql/mutations/epics/update_spec.rb
View file @
44b7005b
...
@@ -39,9 +39,7 @@ RSpec.describe Mutations::Epics::Update do
...
@@ -39,9 +39,7 @@ RSpec.describe Mutations::Epics::Update do
stub_licensed_features
(
epics:
true
)
stub_licensed_features
(
epics:
true
)
end
end
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not update the epic'
do
it
'does not update the epic'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
...
...
ee/spec/requests/api/graphql/mutations/iterations/create_spec.rb
View file @
44b7005b
...
@@ -38,9 +38,7 @@ RSpec.describe 'Creating an Iteration' do
...
@@ -38,9 +38,7 @@ RSpec.describe 'Creating an Iteration' do
stub_licensed_features
(
iterations:
true
)
stub_licensed_features
(
iterations:
true
)
end
end
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not create iteration'
do
it
'does not create iteration'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Iteration
,
:count
)
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Iteration
,
:count
)
...
...
ee/spec/requests/api/graphql/mutations/iterations/update_spec.rb
View file @
44b7005b
...
@@ -36,9 +36,7 @@ RSpec.describe 'Updating an Iteration' do
...
@@ -36,9 +36,7 @@ RSpec.describe 'Updating an Iteration' do
group
.
add_guest
(
current_user
)
group
.
add_guest
(
current_user
)
end
end
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not update iteration'
do
it
'does not update iteration'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
iteration
,
:title
)
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
iteration
,
:title
)
...
...
ee/spec/requests/api/graphql/mutations/requirements_management/create_requirement_spec.rb
View file @
44b7005b
...
@@ -24,9 +24,7 @@ RSpec.describe 'Creating a Requirement' do
...
@@ -24,9 +24,7 @@ RSpec.describe 'Creating a Requirement' do
stub_licensed_features
(
requirements:
true
)
stub_licensed_features
(
requirements:
true
)
end
end
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not create requirement'
do
it
'does not create requirement'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
RequirementsManagement
::
Requirement
,
:count
)
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
RequirementsManagement
::
Requirement
,
:count
)
...
...
ee/spec/requests/api/graphql/mutations/requirements_management/update_requirement_spec.rb
View file @
44b7005b
...
@@ -17,9 +17,7 @@ RSpec.describe 'Updating a Requirement' do
...
@@ -17,9 +17,7 @@ RSpec.describe 'Updating a Requirement' do
end
end
shared_examples
'requirement update fails'
do
shared_examples
'requirement update fails'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist '
\
'or you don\'t have permission to perform this action'
]
it
'does not update requirement'
do
it
'does not update requirement'
do
expect
do
expect
do
...
...
spec/requests/api/graphql/mutations/award_emojis/add_spec.rb
View file @
44b7005b
...
@@ -32,9 +32,7 @@ RSpec.describe 'Adding an AwardEmoji' do
...
@@ -32,9 +32,7 @@ RSpec.describe 'Adding an AwardEmoji' do
context
'when the user does not have permission'
do
context
'when the user does not have permission'
do
it_behaves_like
'a mutation that does not create an AwardEmoji'
it_behaves_like
'a mutation that does not create an AwardEmoji'
it_behaves_like
'a mutation that returns a top-level access error'
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
context
'when the user has permission'
do
context
'when the user has permission'
do
...
...
spec/requests/api/graphql/mutations/award_emojis/remove_spec.rb
View file @
44b7005b
...
@@ -33,9 +33,7 @@ RSpec.describe 'Removing an AwardEmoji' do
...
@@ -33,9 +33,7 @@ RSpec.describe 'Removing an AwardEmoji' do
shared_examples
'a mutation that does not authorize the user'
do
shared_examples
'a mutation that does not authorize the user'
do
it_behaves_like
'a mutation that does not destroy an AwardEmoji'
it_behaves_like
'a mutation that does not destroy an AwardEmoji'
it_behaves_like
'a mutation that returns a top-level access error'
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
context
'when the current_user does not own the award emoji'
do
context
'when the current_user does not own the award emoji'
do
...
...
spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb
View file @
44b7005b
...
@@ -143,8 +143,6 @@ RSpec.describe 'Toggling an AwardEmoji' do
...
@@ -143,8 +143,6 @@ RSpec.describe 'Toggling an AwardEmoji' do
context
'when the user does not have permission'
do
context
'when the user does not have permission'
do
it_behaves_like
'a mutation that does not create or destroy an AwardEmoji'
it_behaves_like
'a mutation that does not create or destroy an AwardEmoji'
it_behaves_like
'a mutation that returns a top-level access error'
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
end
end
spec/requests/api/graphql/mutations/boards/lists/update_spec.rb
View file @
44b7005b
...
@@ -15,8 +15,7 @@ RSpec.describe 'Update of an existing board list' do
...
@@ -15,8 +15,7 @@ RSpec.describe 'Update of an existing board list' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_board_list
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_board_list
)
}
context
'the user is not allowed to read board lists'
do
context
'the user is not allowed to read board lists'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
before
do
before
do
...
...
spec/requests/api/graphql/mutations/branches/create_spec.rb
View file @
44b7005b
...
@@ -15,8 +15,7 @@ RSpec.describe 'Creation of a new branch' do
...
@@ -15,8 +15,7 @@ RSpec.describe 'Creation of a new branch' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:create_branch
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:create_branch
)
}
context
'the user is not allowed to create a branch'
do
context
'the user is not allowed to create a branch'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
context
'when user has permissions to create a branch'
do
context
'when user has permissions to create a branch'
do
...
...
spec/requests/api/graphql/mutations/commits/create_spec.rb
View file @
44b7005b
...
@@ -24,8 +24,7 @@ RSpec.describe 'Creation of a new commit' do
...
@@ -24,8 +24,7 @@ RSpec.describe 'Creation of a new commit' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:commit_create
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:commit_create
)
}
context
'the user is not allowed to create a commit'
do
context
'the user is not allowed to create a commit'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
context
'when user has permissions to create a commit'
do
context
'when user has permissions to create a commit'
do
...
...
spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb
View file @
44b7005b
...
@@ -20,8 +20,7 @@ RSpec.describe 'Toggling the resolve status of a discussion' do
...
@@ -20,8 +20,7 @@ RSpec.describe 'Toggling the resolve status of a discussion' do
context
'when the user does not have permission'
do
context
'when the user does not have permission'
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
"The resource that you are attempting to access does not exist or you don't have permission to perform this action"
]
end
end
context
'when user has permission'
do
context
'when user has permission'
do
...
...
spec/requests/api/graphql/mutations/issues/set_locked_spec.rb
View file @
44b7005b
...
@@ -32,12 +32,7 @@ RSpec.describe 'Setting an issue as locked' do
...
@@ -32,12 +32,7 @@ RSpec.describe 'Setting an issue as locked' do
end
end
context
'when the user is not allowed to update the issue'
do
context
'when the user is not allowed to update the issue'
do
it
'returns an error'
do
it_behaves_like
'a mutation that returns a top-level access error'
error
=
"The resource that you are attempting to access does not exist or you don't have permission to perform this action"
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
error
))
end
end
end
context
'when user is allowed to update the issue'
do
context
'when user is allowed to update the issue'
do
...
...
spec/requests/api/graphql/mutations/issues/update_spec.rb
View file @
44b7005b
...
@@ -20,8 +20,7 @@ RSpec.describe 'Update of an existing issue' do
...
@@ -20,8 +20,7 @@ RSpec.describe 'Update of an existing issue' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_issue
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_issue
)
}
context
'the user is not allowed to update issue'
do
context
'the user is not allowed to update issue'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
context
'when user has permissions to update issue'
do
context
'when user has permissions to update issue'
do
...
...
spec/requests/api/graphql/mutations/merge_requests/create_spec.rb
View file @
44b7005b
...
@@ -24,8 +24,7 @@ RSpec.describe 'Creation of a new merge request' do
...
@@ -24,8 +24,7 @@ RSpec.describe 'Creation of a new merge request' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:merge_request_create
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:merge_request_create
)
}
context
'the user is not allowed to create a branch'
do
context
'the user is not allowed to create a branch'
do
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
context
'when user has permissions to create a merge request'
do
context
'when user has permissions to create a merge request'
do
...
...
spec/requests/api/graphql/mutations/notes/destroy_spec.rb
View file @
44b7005b
...
@@ -21,8 +21,7 @@ RSpec.describe 'Destroying a Note' do
...
@@ -21,8 +21,7 @@ RSpec.describe 'Destroying a Note' do
context
'when the user does not have permission'
do
context
'when the user does not have permission'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
create
(
:user
)
}
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
it
'does not destroy the Note'
do
it
'does not destroy the Note'
do
expect
do
expect
do
...
...
spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb
View file @
44b7005b
...
@@ -59,8 +59,7 @@ RSpec.describe 'Updating an image DiffNote' do
...
@@ -59,8 +59,7 @@ RSpec.describe 'Updating an image DiffNote' do
context
'when the user does not have permission'
do
context
'when the user does not have permission'
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
it
'does not update the DiffNote'
do
it
'does not update the DiffNote'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
...
...
spec/requests/api/graphql/mutations/notes/update/note_spec.rb
View file @
44b7005b
...
@@ -22,8 +22,7 @@ RSpec.describe 'Updating a Note' do
...
@@ -22,8 +22,7 @@ RSpec.describe 'Updating a Note' do
context
'when the user does not have permission'
do
context
'when the user does not have permission'
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
it
'does not update the Note'
do
it
'does not update the Note'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
...
...
spec/requests/api/graphql/mutations/todos/mark_all_done_spec.rb
View file @
44b7005b
...
@@ -59,7 +59,6 @@ RSpec.describe 'Marking all todos done' do
...
@@ -59,7 +59,6 @@ RSpec.describe 'Marking all todos done' do
context
'when user is not logged in'
do
context
'when user is not logged in'
do
let
(
:current_user
)
{
nil
}
let
(
:current_user
)
{
nil
}
it_behaves_like
'a mutation that returns top-level errors'
,
it_behaves_like
'a mutation that returns a top-level access error'
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
end
end
end
spec/requests/api/graphql/mutations/todos/mark_done_spec.rb
View file @
44b7005b
...
@@ -63,14 +63,11 @@ RSpec.describe 'Marking todos done' do
...
@@ -63,14 +63,11 @@ RSpec.describe 'Marking todos done' do
context
'when todo does not belong to requesting user'
do
context
'when todo does not belong to requesting user'
do
let
(
:input
)
{
{
id:
other_user_todo
.
to_global_id
.
to_s
}
}
let
(
:input
)
{
{
id:
other_user_todo
.
to_global_id
.
to_s
}
}
let
(
:access_error
)
{
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
}
it
'contains the expected error'
do
it_behaves_like
'a mutation that returns a top-level access error'
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
errors
=
json_response
[
'errors'
]
it
'results in the correct todo states'
do
expect
(
errors
).
not_to
be_blank
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
errors
.
first
[
'message'
]).
to
eq
(
access_error
)
expect
(
todo1
.
reload
.
state
).
to
eq
(
'pending'
)
expect
(
todo1
.
reload
.
state
).
to
eq
(
'pending'
)
expect
(
todo2
.
reload
.
state
).
to
eq
(
'done'
)
expect
(
todo2
.
reload
.
state
).
to
eq
(
'done'
)
...
...
spec/requests/api/graphql/mutations/todos/restore_spec.rb
View file @
44b7005b
...
@@ -63,14 +63,11 @@ RSpec.describe 'Restoring Todos' do
...
@@ -63,14 +63,11 @@ RSpec.describe 'Restoring Todos' do
context
'when todo does not belong to requesting user'
do
context
'when todo does not belong to requesting user'
do
let
(
:input
)
{
{
id:
other_user_todo
.
to_global_id
.
to_s
}
}
let
(
:input
)
{
{
id:
other_user_todo
.
to_global_id
.
to_s
}
}
let
(
:access_error
)
{
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
}
it
'contains the expected error'
do
it_behaves_like
'a mutation that returns a top-level access error'
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
errors
=
json_response
[
'errors'
]
it
'results in the correct todo states'
do
expect
(
errors
).
not_to
be_blank
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
errors
.
first
[
'message'
]).
to
eq
(
access_error
)
expect
(
todo1
.
reload
.
state
).
to
eq
(
'done'
)
expect
(
todo1
.
reload
.
state
).
to
eq
(
'done'
)
expect
(
todo2
.
reload
.
state
).
to
eq
(
'pending'
)
expect
(
todo2
.
reload
.
state
).
to
eq
(
'pending'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment