summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/project.rb8
-rw-r--r--app/views/projects/show.html.haml5
-rw-r--r--spec/models/project_spec.rb25
3 files changed, 38 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index f648833..9b015d2 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -126,6 +126,14 @@ ls -la
end
end
+ def any_runners?
+ if runners.active.any?
+ return true
+ end
+
+ shared_runners_enabled && Runner.shared.active.any?
+ end
+
def set_default_values
self.token = SecureRandom.hex(15) if self.token.blank?
end
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 95858d1..6076f6f 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -1,5 +1,10 @@
= render 'shared/guide' unless @project.setup_finished?
+- unless @project.any_runners?
+ .alert.alert-danger
+ There are no runners available.
+ = link_to "Add a runner", project_runners_path(@project)
+
%ul.nav.nav-tabs.append-bottom-20
%li{class: ref_tab_class}
= link_to 'All commits', project_path(@project)
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 0b334d3..9358db5 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -174,4 +174,29 @@ describe Project do
it { Project.search('fo').should include(project) }
it { Project.search('bar').should be_empty }
end
+
+ describe :any_runners do
+ it "there are no runners available" do
+ project = FactoryGirl.create(:project)
+ project.any_runners?.should be_false
+ end
+
+ it "there is a specific runner" do
+ project = FactoryGirl.create(:project)
+ project.runners << FactoryGirl.create(:specific_runner)
+ project.any_runners?.should be_true
+ end
+
+ it "there is a shared runner" do
+ project = FactoryGirl.create(:project, shared_runners_enabled: true)
+ FactoryGirl.create(:shared_runner)
+ project.any_runners?.should be_true
+ end
+
+ it "there is a shared runner, but they are prohibited to use" do
+ project = FactoryGirl.create(:project)
+ FactoryGirl.create(:shared_runner)
+ project.any_runners?.should be_false
+ end
+ end
end