Commit 35954572 authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent 1c302d56
...@@ -40,7 +40,9 @@ describe Ci::Runner, models: true do ...@@ -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]) }
...@@ -64,19 +66,25 @@ describe Ci::Runner, models: true do ...@@ -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
...@@ -88,25 +96,33 @@ describe Ci::Runner, models: true do ...@@ -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
...@@ -117,10 +133,14 @@ describe Ci::Runner, models: true do ...@@ -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) }
...@@ -150,7 +170,9 @@ describe Ci::Runner, models: true do ...@@ -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) }
......
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