summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/commit.rb6
-rw-r--r--app/views/builds/_build.html.haml3
-rw-r--r--app/views/commits/show.html.haml9
-rw-r--r--app/views/projects/_form.html.haml4
-rw-r--r--db/migrate/20141104130024_migrate_jobs.rb8
-rw-r--r--db/migrate/20141104153744_add_name_to_job.rb5
-rw-r--r--db/schema.rb3
7 files changed, 30 insertions, 8 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 859522c..60d7c3d 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -161,4 +161,10 @@ class Commit < ActiveRecord::Base
def finished_at
end
+
+ def coverage
+ if builds.size == 1
+ builds.first.coverage
+ end
+ end
end
diff --git a/app/views/builds/_build.html.haml b/app/views/builds/_build.html.haml
index d204d9a..853556c 100644
--- a/app/views/builds/_build.html.haml
+++ b/app/views/builds/_build.html.haml
@@ -7,7 +7,8 @@
%strong Build ##{build.id}
%td
- = truncate build.commands.lines.last, length: 30
+ - if build.job
+ = build.job.name
%td.build-branch
- unless @ref
diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml
index a1988dc..d7c907b 100644
--- a/app/views/commits/show.html.haml
+++ b/app/views/commits/show.html.haml
@@ -28,9 +28,10 @@
%p
%span.attr-name Author:
#{@commit.git_author_name}
- %p
- %span.attr-name Created at:
- #{@commit.created_at.to_s(:short)}
+ - if @commit.created_at
+ %p
+ %span.attr-name Created at:
+ #{@commit.created_at.to_s(:short)}
%h3 Status
@@ -46,7 +47,7 @@
%tr
%th Status
%th Build ID
- %th Command
+ %th Job
%th Branch
%th Duration
%th Finished at
diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml
index 07281fc..da63494 100644
--- a/app/views/projects/_form.html.haml
+++ b/app/views/projects/_form.html.haml
@@ -11,6 +11,10 @@
%legend Build scripts
= f.fields_for :jobs do |job_form|
.form-group
+ = f.label :name, 'Job name', class: 'control-label'
+ .col-sm-10
+ = job_form.text_field :name, class: 'form-control', placeholder: "Ex. cucumber"
+ .form-group
= f.label :commands, 'Build steps', class: 'control-label'
.col-sm-10
= job_form.text_area :commands, class: 'form-control', rows: 14, placeholder: "bundle exec rake spec"
diff --git a/db/migrate/20141104130024_migrate_jobs.rb b/db/migrate/20141104130024_migrate_jobs.rb
index c7b20fa..1d80fb8 100644
--- a/db/migrate/20141104130024_migrate_jobs.rb
+++ b/db/migrate/20141104130024_migrate_jobs.rb
@@ -1,8 +1,12 @@
class MigrateJobs < ActiveRecord::Migration
- def change
+ def up
Project.find_each(batch_size: 100) do |project|
job = project.jobs.create(commands: project.scripts)
- project.builds.update_all(job_id: job.id)
+ project.builds.order('id DESC').limit(10).update_all(job_id: job.id)
end
end
+
+ def down
+ Job.destroy_all
+ end
end
diff --git a/db/migrate/20141104153744_add_name_to_job.rb b/db/migrate/20141104153744_add_name_to_job.rb
new file mode 100644
index 0000000..ef4dd17
--- /dev/null
+++ b/db/migrate/20141104153744_add_name_to_job.rb
@@ -0,0 +1,5 @@
+class AddNameToJob < ActiveRecord::Migration
+ def change
+ add_column :jobs, :name, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 973cbae..73830b6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20141104130024) do
+ActiveRecord::Schema.define(version: 20141104153744) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -63,6 +63,7 @@ ActiveRecord::Schema.define(version: 20141104130024) do
t.boolean "active", default: true, null: false
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "name"
end
add_index "jobs", ["project_id"], name: "index_jobs_on_project_id", using: :btree