diff options
Diffstat (limited to 'spec/support/shared_examples')
4 files changed, 39 insertions, 3 deletions
diff --git a/spec/support/shared_examples/controllers/deploy_token_shared_examples.rb b/spec/support/shared_examples/controllers/deploy_token_shared_examples.rb index 791eb0b68e0..bd4eeff81a0 100644 --- a/spec/support/shared_examples/controllers/deploy_token_shared_examples.rb +++ b/spec/support/shared_examples/controllers/deploy_token_shared_examples.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true RSpec.shared_examples 'a created deploy token' do + let(:read_repository) { '1' } let(:deploy_token_params) do { name: 'deployer_token', expires_at: 1.month.from_now.to_date.to_s, username: 'deployer', - read_repository: '1', + read_repository: read_repository, deploy_token_type: deploy_token_type } end @@ -19,4 +20,15 @@ RSpec.shared_examples 'a created deploy token' do expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:show) end + + context 'when no scope is selected' do + let(:read_repository) { '0' } + + it 'creates a variable with a errored deploy token' do + expect { create_deploy_token }.not_to change { DeployToken.active.count } + + expect(assigns(:new_deploy_token)).to be_a(DeployToken) + expect(assigns(:new_deploy_token).errors.full_messages.first).to eq('Scopes can\'t be blank') + end + end end 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 38a9f1fe098..aa8979603b6 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 @@ -13,6 +13,7 @@ RSpec.shared_examples 'a valid diff positionable note' do |factory_on_commit| new_path: "files/ruby/popen.rb", old_line: nil, new_line: 14, + line_range: nil, diff_refs: diff_refs ) end diff --git a/spec/support/shared_examples/quick_actions/merge_request/merge_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/merge_request/merge_quick_action_shared_examples.rb index fa163b54405..e0edbc5637a 100644 --- a/spec/support/shared_examples/quick_actions/merge_request/merge_quick_action_shared_examples.rb +++ b/spec/support/shared_examples/quick_actions/merge_request/merge_quick_action_shared_examples.rb @@ -10,10 +10,27 @@ RSpec.shared_examples 'merge quick action' do it 'merges the MR', :sidekiq_might_not_need_inline do add_note("/merge") - expect(page).to have_content 'Scheduled to merge this merge request when the pipeline succeeds.' + expect(page).to have_content 'Merged this merge request.' expect(merge_request.reload).to be_merged end + + context 'when auto merge is avialable' do + before do + create(:ci_pipeline, :detached_merge_request_pipeline, + project: project, merge_request: merge_request) + merge_request.update_head_pipeline + end + + it 'schedules to merge the MR' do + add_note("/merge") + + expect(page).to have_content "Scheduled to merge this merge request (Merge when pipeline succeeds)." + + expect(merge_request.reload).to be_auto_merge_enabled + expect(merge_request.reload).not_to be_merged + end + end end context 'when the head diff changes in the meanwhile' do diff --git a/spec/support/shared_examples/requests/api/diff_discussions_shared_examples.rb b/spec/support/shared_examples/requests/api/diff_discussions_shared_examples.rb index 583475678f1..3d25b9076ad 100644 --- a/spec/support/shared_examples/requests/api/diff_discussions_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/diff_discussions_shared_examples.rb @@ -22,12 +22,18 @@ RSpec.shared_examples 'diff discussions API' do |parent_type, noteable_type, id_ expect(json_response['id']).to eq(diff_note.discussion_id) expect(json_response['notes'].first['body']).to eq(diff_note.note) expect(json_response['notes'].first['position']).to eq(diff_note.position.to_h.stringify_keys) + expect(json_response['notes'].first['line_range']).to eq(nil) end end describe "POST /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do it "creates a new diff note" do - position = diff_note.position.to_h + line_range = { + "start_line_code" => Gitlab::Git.diff_line_code(diff_note.position.file_path, 1, 1), + "end_line_code" => Gitlab::Git.diff_line_code(diff_note.position.file_path, 2, 2) + } + + position = diff_note.position.to_h.merge({ line_range: line_range }) post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!', position: position } |