summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/graphql/mutations/spammable_mutation_fields_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/graphql/mutations/spammable_mutation_fields_examples.rb')
-rw-r--r--spec/support/shared_examples/graphql/mutations/spammable_mutation_fields_examples.rb50
1 files changed, 0 insertions, 50 deletions
diff --git a/spec/support/shared_examples/graphql/mutations/spammable_mutation_fields_examples.rb b/spec/support/shared_examples/graphql/mutations/spammable_mutation_fields_examples.rb
deleted file mode 100644
index 8678b23ad31..00000000000
--- a/spec/support/shared_examples/graphql/mutations/spammable_mutation_fields_examples.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.shared_examples 'spam flag is present' do
- specify :aggregate_failures do
- subject
-
- expect(mutation_response).to have_key('spam')
- expect(mutation_response['spam']).to be_falsey
- end
-end
-
-RSpec.shared_examples 'can raise spam flag' do
- it 'spam parameters are passed to the service' do
- args = [anything, anything, hash_including(api: true, request: instance_of(ActionDispatch::Request))]
- expect(service).to receive(:new).with(*args).and_call_original
-
- subject
- end
-
- context 'when the snippet is detected as spam' do
- it 'raises spam flag' do
- allow_next_instance_of(service) do |instance|
- allow(instance).to receive(:spam_check) do |snippet, user, _|
- snippet.spam!
- end
- end
-
- subject
-
- expect(mutation_response['spam']).to be true
- expect(mutation_response['errors']).to include("Your snippet has been recognized as spam and has been discarded.")
- end
- end
-
- context 'when :snippet_spam flag is disabled' do
- before do
- stub_feature_flags(snippet_spam: false)
- end
-
- it 'request parameter is not passed to the service' do
- expect(service).to receive(:new)
- .with(anything, anything, hash_not_including(request: instance_of(ActionDispatch::Request)))
- .and_call_original
-
- subject
- end
- end
-end