Skip to content
Snippets Groups Projects
Commit 35954572 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files
parent 1c302d56
No related branches found
No related tags found
2 merge requests!4734!4093 is giving me 502,!4093Make it possible to lock runner on a specific project
Loading
@@ -40,7 +40,9 @@ describe Ci::Runner, models: true do
Loading
@@ -40,7 +40,9 @@ describe Ci::Runner, models: true do
let!(:project) { FactoryGirl.create :empty_project } let!(:project) { FactoryGirl.create :empty_project }
let!(:shared_runner) { FactoryGirl.create(:ci_runner, :shared) } let!(:shared_runner) { FactoryGirl.create(:ci_runner, :shared) }
   
before { shared_runner.assign_to(project) } before do
shared_runner.assign_to(project)
end
   
it { expect(shared_runner).to be_specific } it { expect(shared_runner).to be_specific }
it { expect(shared_runner.projects).to eq([project]) } it { expect(shared_runner.projects).to eq([project]) }
Loading
@@ -64,19 +66,25 @@ describe Ci::Runner, models: true do
Loading
@@ -64,19 +66,25 @@ describe Ci::Runner, models: true do
subject { runner.online? } subject { runner.online? }
   
context 'never contacted' do context 'never contacted' do
before { runner.contacted_at = nil } before do
runner.contacted_at = nil
end
   
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
end end
   
context 'contacted long time ago time' do context 'contacted long time ago time' do
before { runner.contacted_at = 1.year.ago } before do
runner.contacted_at = 1.year.ago
end
   
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
end end
   
context 'contacted 1s ago' do context 'contacted 1s ago' do
before { runner.contacted_at = 1.second.ago } before do
runner.contacted_at = 1.second.ago
end
   
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
Loading
@@ -88,25 +96,33 @@ describe Ci::Runner, models: true do
Loading
@@ -88,25 +96,33 @@ describe Ci::Runner, models: true do
subject { runner.status } subject { runner.status }
   
context 'never connected' do context 'never connected' do
before { runner.contacted_at = nil } before do
runner.contacted_at = nil
end
   
it { is_expected.to eq(:not_connected) } it { is_expected.to eq(:not_connected) }
end end
   
context 'contacted 1s ago' do context 'contacted 1s ago' do
before { runner.contacted_at = 1.second.ago } before do
runner.contacted_at = 1.second.ago
end
   
it { is_expected.to eq(:online) } it { is_expected.to eq(:online) }
end end
   
context 'contacted long time ago' do context 'contacted long time ago' do
before { runner.contacted_at = 1.year.ago } before do
runner.contacted_at = 1.year.ago
end
   
it { is_expected.to eq(:offline) } it { is_expected.to eq(:offline) }
end end
   
context 'inactive' do context 'inactive' do
before { runner.active = false } before do
runner.active = false
end
   
it { is_expected.to eq(:paused) } it { is_expected.to eq(:paused) }
end end
Loading
@@ -117,10 +133,14 @@ describe Ci::Runner, models: true do
Loading
@@ -117,10 +133,14 @@ describe Ci::Runner, models: true do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:another_project) { create(:project) } let(:another_project) { create(:project) }
   
before { project.runners << runner } before do
project.runners << runner
end
   
context 'with shared runners' do context 'with shared runners' do
before { runner.update(is_shared: true) } before do
runner.update(is_shared: true)
end
   
context 'should not give owned runner' do context 'should not give owned runner' do
subject { Ci::Runner.specific_for(project) } subject { Ci::Runner.specific_for(project) }
Loading
@@ -150,7 +170,9 @@ describe Ci::Runner, models: true do
Loading
@@ -150,7 +170,9 @@ describe Ci::Runner, models: true do
end end
   
context 'with locked runner' do context 'with locked runner' do
before { runner.update(locked: true) } before do
runner.update(locked: true)
end
   
context 'should not give owned runner' do context 'should not give owned runner' do
subject { Ci::Runner.specific_for(project) } subject { Ci::Runner.specific_for(project) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment