Commit f76c2f15 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'sh-fix-issue-34366' into 'master'

Fix error in updating runner session

Closes #34366

See merge request gitlab-org/gitlab!20902
parents 3f79a595 75dab5a1
......@@ -53,7 +53,7 @@ module Ci
has_one :runner_session, class_name: 'Ci::BuildRunnerSession', validate: true, inverse_of: :build
accepts_nested_attributes_for :runner_session
accepts_nested_attributes_for :runner_session, update_only: true
accepts_nested_attributes_for :job_variables
delegate :url, to: :runner_session, prefix: true, allow_nil: true
......
---
title: Fix error in updating runner session
merge_request: 20902
author:
type: fixed
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Ci::BuildRunnerSession, model: true do
let!(:build) { create(:ci_build, :with_runner_session) }
let(:url) { 'https://new.example.com' }
subject { build.runner_session }
......@@ -12,6 +13,25 @@ describe Ci::BuildRunnerSession, model: true do
it { is_expected.to validate_presence_of(:build) }
it { is_expected.to validate_presence_of(:url).with_message('must be a valid URL') }
context 'nested attribute assignment' do
it 'creates a new session' do
simple_build = create(:ci_build)
simple_build.runner_session_attributes = { url: url }
simple_build.save!
session = simple_build.reload.runner_session
expect(session).to be_a(Ci::BuildRunnerSession)
expect(session.url).to eq(url)
end
it 'updates session with new attributes' do
build.runner_session_attributes = { url: url }
build.save!
expect(build.reload.runner_session.url).to eq(url)
end
end
describe '#terminal_specification' do
let(:specification) { subject.terminal_specification }
......
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