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:
Diffstat (limited to 'spec/graphql/mutations/todos/restore_many_spec.rb')
-rw-r--r--spec/graphql/mutations/todos/restore_many_spec.rb33
1 files changed, 5 insertions, 28 deletions
diff --git a/spec/graphql/mutations/todos/restore_many_spec.rb b/spec/graphql/mutations/todos/restore_many_spec.rb
index b3b3e057745..59995e33f2d 100644
--- a/spec/graphql/mutations/todos/restore_many_spec.rb
+++ b/spec/graphql/mutations/todos/restore_many_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe Mutations::Todos::RestoreMany do
+ include GraphqlHelpers
+
let_it_be(:current_user) { create(:user) }
let_it_be(:author) { create(:user) }
let_it_be(:other_user) { create(:user) }
@@ -44,8 +46,9 @@ RSpec.describe Mutations::Todos::RestoreMany do
expect_states_were_not_changed
end
- it 'ignores invalid GIDs' do
- expect { mutation.resolve(ids: ['invalid_gid']) }.to raise_error(URI::BadURIError)
+ it 'raises an error with invalid or non-Todo GIDs' do
+ expect { mutation.resolve(ids: [author.to_global_id.to_s]) }
+ .to raise_error(GraphQL::CoercionError)
expect_states_were_not_changed
end
@@ -78,38 +81,12 @@ RSpec.describe Mutations::Todos::RestoreMany do
it 'fails if too many todos are requested for update' do
expect { restore_mutation([todo1] * 51) }.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
end
-
- it 'does not update todos from another app' do
- todo4 = create(:todo)
- todo4_gid = ::URI::GID.parse("gid://otherapp/Todo/#{todo4.id}")
-
- result = mutation.resolve(ids: [todo4_gid.to_s])
-
- expect(result[:updated_ids]).to be_empty
-
- expect_states_were_not_changed
- end
-
- it 'does not update todos from another model' do
- todo4 = create(:todo)
- todo4_gid = ::URI::GID.parse("gid://#{GlobalID.app}/Project/#{todo4.id}")
-
- result = mutation.resolve(ids: [todo4_gid.to_s])
-
- expect(result[:updated_ids]).to be_empty
-
- expect_states_were_not_changed
- end
end
def restore_mutation(todos)
mutation.resolve(ids: todos.map { |todo| global_id_of(todo) } )
end
- def global_id_of(todo)
- todo.to_global_id.to_s
- end
-
def expect_states_were_not_changed
expect(todo1.reload.state).to eq('done')
expect(todo2.reload.state).to eq('pending')