Commit 8818ae8f authored by Igor Drozdov's avatar Igor Drozdov

Add a test for a position without lines

parent 0826e332
......@@ -9,8 +9,9 @@ RSpec.describe 'Adding a DiffNote' do
let(:noteable) { create(:merge_request, source_project: project, target_project: project) }
let(:project) { create(:project, :repository) }
let(:diff_refs) { noteable.diff_refs }
let(:mutation) do
variables = {
let(:base_variables) do
{
noteable_id: GitlabSchema.id_from_object(noteable).to_s,
body: 'Body text',
position: {
......@@ -18,16 +19,16 @@ RSpec.describe 'Adding a DiffNote' do
old_path: 'files/ruby/popen.rb',
new_path: 'files/ruby/popen2.rb'
},
new_line: 14,
base_sha: diff_refs.base_sha,
head_sha: diff_refs.head_sha,
start_sha: diff_refs.start_sha
}
}
graphql_mutation(:create_diff_note, variables)
end
let(:variables) { base_variables.deep_merge({ position: { new_line: 14 } }) }
let(:mutation) { graphql_mutation(:create_diff_note, variables) }
def mutation_response
graphql_mutation_response(:create_diff_note)
end
......@@ -42,28 +43,17 @@ RSpec.describe 'Adding a DiffNote' do
it_behaves_like 'a Note mutation that creates a Note'
context 'add comment to old line' do
let(:mutation) do
variables = {
noteable_id: GitlabSchema.id_from_object(noteable).to_s,
body: 'Body text',
position: {
paths: {
old_path: 'files/ruby/popen.rb',
new_path: 'files/ruby/popen.rb'
},
old_line: 14,
base_sha: diff_refs.base_sha,
head_sha: diff_refs.head_sha,
start_sha: diff_refs.start_sha
}
}
graphql_mutation(:create_diff_note, variables)
end
let(:variables) { base_variables.deep_merge({ position: { old_line: 14 } }) }
it_behaves_like 'a Note mutation that creates a Note'
end
context 'add a comment with a position without lines' do
let(:variables) { base_variables }
it_behaves_like 'a Note mutation that does not create a Note'
end
it_behaves_like 'a Note mutation when there are active record validation errors', model: DiffNote
it_behaves_like 'a Note mutation when there are rate limit validation errors'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment