summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb b/spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb
index 759b22f794e..eafa589a1d3 100644
--- a/spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb
+++ b/spec/support/shared_examples/models/diff_positionable_note_shared_examples.rb
@@ -71,5 +71,38 @@ RSpec.shared_examples 'a valid diff positionable note' do |factory_on_commit|
end
end
end
+
+ describe 'schema validation' do
+ where(:position_attrs) do
+ [
+ { old_path: SecureRandom.alphanumeric(1001) },
+ { new_path: SecureRandom.alphanumeric(1001) },
+ { old_line: "foo" }, # this should be an integer
+ { new_line: "foo" }, # this should be an integer
+ { line_range: { "foo": "bar" } },
+ { line_range: { "line_code": SecureRandom.alphanumeric(101) } },
+ { line_range: { "type": SecureRandom.alphanumeric(101) } },
+ { line_range: { "old_line": "foo" } },
+ { line_range: { "new_line": "foo" } }
+ ]
+ end
+
+ with_them do
+ let(:position) do
+ Gitlab::Diff::Position.new(
+ {
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ old_line: nil,
+ new_line: 14,
+ line_range: nil,
+ diff_refs: diff_refs
+ }.merge(position_attrs)
+ )
+ end
+
+ it { is_expected.to be_invalid }
+ end
+ end
end
end