diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-08 20:06:25 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-08 20:06:25 +0200 |
commit | 42b0763f454490e024a8fd16b922025aa337b80b (patch) | |
tree | 65c9225b30faeecf8fcd2790cb9c84d73f634e49 | |
parent | 78787ded9c37911152b4a619cd048dd85a5390f9 (diff) | |
download | gitlab-ci-42b0763f454490e024a8fd16b922025aa337b80b.tar.gz |
Added validations to builds
-rw-r--r-- | app/models/build.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | lib/runner.rb | 5 | ||||
-rw-r--r-- | spec/models/build_spec.rb | 3 |
4 files changed, 12 insertions, 2 deletions
diff --git a/app/models/build.rb b/app/models/build.rb index 80031b6..e40d03c 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -4,6 +4,10 @@ class Build < ActiveRecord::Base attr_accessible :project_id, :ref, :sha, :status, :finished_at, :trace, :started_at + validates :sha, presence: true + validates :ref, presence: true + validates :status, presence: true + def failed? status == 'fail' end diff --git a/app/models/project.rb b/app/models/project.rb index d5082af..b959b3c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -20,7 +20,7 @@ class Project < ActiveRecord::Base data = { project_id: self.id, - status: 'running', + status: 'waiting', ref: ref, sha: sha } diff --git a/lib/runner.rb b/lib/runner.rb index 110e75f..dfea63f 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -24,7 +24,10 @@ class Runner path = project.path commands = project.scripts - build.update_attributes(started_at: Time.now) + build.update_attributes( + started_at: Time.now, + status: 'running' + ) Dir.chdir(path) do commands.each_line do |line| diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index bd565d9..3748441 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -4,6 +4,9 @@ describe Build do subject { Build.new } it { should belong_to(:project) } + it { should validate_presence_of :sha } + it { should validate_presence_of :ref } + it { should validate_presence_of :status } end |