Skip to content
Snippets Groups Projects
Commit 96c2c29a authored by GitLab Release Tools Bot's avatar GitLab Release Tools Bot
Browse files

Merge remote-tracking branch 'dev/12-2-stable' into 12-2-stable

parents 635e1578 2b354bdc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -117,6 +117,7 @@ module GraphqlHelpers
def all_graphql_fields_for(class_name, parent_types = Set.new)
allow_unlimited_graphql_complexity
allow_unlimited_graphql_depth
allow_high_graphql_recursion
 
type = GitlabSchema.types[class_name.to_s]
return "" unless type
Loading
Loading
@@ -176,6 +177,23 @@ module GraphqlHelpers
end
end
 
def expect_graphql_errors_to_include(regexes_to_match)
raise "No errors. Was expecting to match #{regexes_to_match}" if graphql_errors.nil? || graphql_errors.empty?
error_messages = flattened_errors.collect { |error_hash| error_hash["message"] }
Array.wrap(regexes_to_match).flatten.each do |regex|
expect(error_messages).to include a_string_matching regex
end
end
def expect_graphql_errors_to_be_empty
expect(flattened_errors).to be_empty
end
def flattened_errors
Array.wrap(graphql_errors).flatten.compact
end
# Raises an error if no response is found
def graphql_mutation_response(mutation_name)
graphql_data.fetch(GraphqlHelpers.fieldnamerize(mutation_name))
Loading
Loading
@@ -223,6 +241,10 @@ module GraphqlHelpers
allow_any_instance_of(GitlabSchema).to receive(:max_depth).and_return nil
allow(GitlabSchema).to receive(:max_query_depth).with(any_args).and_return nil
end
def allow_high_graphql_recursion
allow_any_instance_of(Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer).to receive(:recursion_threshold).and_return 1000
end
end
 
# This warms our schema, doing this as part of loading the helpers to avoid
Loading
Loading
Loading
Loading
@@ -39,7 +39,7 @@ shared_examples 'todos actions' do
post_create
end.to change { user.todos.count }.by(0)
 
expect(response).to have_gitlab_http_status(parent.is_a?(Group) ? 401 : 302)
expect(response).to have_gitlab_http_status(302)
end
end
end
Loading
Loading
@@ -312,4 +312,67 @@ describe AddressableUrlValidator do
end
end
end
context 'when require_absolute is' do
let(:validator) { described_class.new(attributes: [:link_url], require_absolute: require_absolute) }
let(:valid_relative_url) { '/relative/path' }
let(:invalid_relative_url) { 'relative/path' }
let(:absolute_url) { 'https://example.com' }
context 'true' do
let(:require_absolute) { true }
it 'prevents valid relative urls' do
badge.link_url = valid_relative_url
subject
expect(badge.errors).to be_present
end
it 'prevents invalid relative urls' do
badge.link_url = invalid_relative_url
subject
expect(badge.errors).to be_present
end
it 'allows absolute urls' do
badge.link_url = absolute_url
subject
expect(badge.errors).to be_empty
end
end
context 'false' do
let(:require_absolute) { false }
it 'allows valid relative urls' do
badge.link_url = valid_relative_url
subject
expect(badge.errors).to be_empty
end
it 'prevents invalid relative urls' do
badge.link_url = invalid_relative_url
subject
expect(badge.errors).to be_present
end
it 'allows absolute urls' do
badge.link_url = absolute_url
subject
expect(badge.errors).to be_empty
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment