Commit 1498baf7 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '35642-add-owner-to-triggers-factory' into 'master'

Make sure we have an owner for triggers

Closes #35642

See merge request !13799
parents 07381107 ed4f5b97
FactoryGirl.define do FactoryGirl.define do
factory :ci_trigger_without_token, class: Ci::Trigger do factory :ci_trigger_without_token, class: Ci::Trigger do
owner
factory :ci_trigger do factory :ci_trigger do
sequence(:token) { |n| "token#{n}" } sequence(:token) { |n| "token#{n}" }
end end
......
...@@ -8,8 +8,8 @@ describe API::Triggers do ...@@ -8,8 +8,8 @@ describe API::Triggers do
let!(:project) { create(:project, :repository, creator: user) } let!(:project) { create(:project, :repository, creator: user) }
let!(:master) { create(:project_member, :master, user: user, project: project) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:developer) { create(:project_member, :developer, user: user2, project: project) } let!(:developer) { create(:project_member, :developer, user: user2, project: project) }
let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) } let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token, owner: user) }
let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2) } let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2, owner: user2) }
let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') } let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') }
describe 'POST /projects/:project_id/trigger/pipeline' do describe 'POST /projects/:project_id/trigger/pipeline' do
...@@ -22,7 +22,6 @@ describe API::Triggers do ...@@ -22,7 +22,6 @@ describe API::Triggers do
before do before do
stub_ci_pipeline_to_return_yaml_file stub_ci_pipeline_to_return_yaml_file
trigger.update(owner: user)
end end
context 'Handles errors' do context 'Handles errors' do
...@@ -254,8 +253,6 @@ describe API::Triggers do ...@@ -254,8 +253,6 @@ describe API::Triggers do
describe 'POST /projects/:id/triggers/:trigger_id/take_ownership' do describe 'POST /projects/:id/triggers/:trigger_id/take_ownership' do
context 'authenticated user with valid permissions' do context 'authenticated user with valid permissions' do
it 'updates owner' do it 'updates owner' do
expect(trigger.owner).to be_nil
post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user) post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
......
...@@ -7,7 +7,10 @@ describe API::V3::Triggers do ...@@ -7,7 +7,10 @@ describe API::V3::Triggers do
let!(:project) { create(:project, :repository, creator: user) } let!(:project) { create(:project, :repository, creator: user) }
let!(:master) { create(:project_member, :master, user: user, project: project) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:developer) { create(:project_member, :developer, user: user2, project: project) } let!(:developer) { create(:project_member, :developer, user: user2, project: project) }
let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) }
let!(:trigger) do
create(:ci_trigger, project: project, token: trigger_token, owner: user)
end
describe 'POST /projects/:project_id/trigger' do describe 'POST /projects/:project_id/trigger' do
let!(:project2) { create(:project) } let!(:project2) { create(:project) }
......
...@@ -470,7 +470,8 @@ describe Ci::CreatePipelineService do ...@@ -470,7 +470,8 @@ describe Ci::CreatePipelineService do
context 'when ref is not protected' do context 'when ref is not protected' do
context 'when trigger belongs to no one' do context 'when trigger belongs to no one' do
let(:user) {} let(:user) {}
let(:trigger_request) { create(:ci_trigger_request) } let(:trigger) { create(:ci_trigger, owner: nil) }
let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) }
it 'creates a pipeline' do it 'creates a pipeline' do
expect(execute_service(trigger_request: trigger_request)) expect(execute_service(trigger_request: trigger_request))
......
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