#408: added success list, refactoring

This commit is contained in:
Vokhmin Alexey V 2014-06-26 21:20:26 +04:00
parent 198aad37dd
commit 2c326e809e
9 changed files with 96 additions and 53 deletions

View File

@ -10,6 +10,9 @@ class Platforms::MassBuildsController < Platforms::BaseController
def new
end
def show
end
def create
@mass_build.user, @mass_build.arches = current_user, params[:arches]
@ -42,9 +45,12 @@ class Platforms::MassBuildsController < Platforms::BaseController
end
def get_list
text = if %w(failed_builds_list tests_failed_builds_list).include? params[:kind]
text =
case params[:kind]
when 'failed_builds_list', 'tests_failed_builds_list', 'success_builds_list'
@mass_build.send "generate_#{params[:kind]}"
elsif %w(projects_list missed_projects_list).include? params[:kind]
when 'projects_list', 'missed_projects_list'
@mass_build.send params[:kind]
end
render text: text

View File

@ -4,4 +4,8 @@ module MassBuildHelper
get_list_platform_mass_build_path(@platform, mass_build, kind: which, format: :txt),
target: "_blank" if can?(:get_list, mass_build)
end
def link_to_mass_build(mass_build)
link_to mass_build.name, build_lists_path+"#?#{{filter: {mass_build_id: mass_build.id, ownership: 'everything'}}.to_param}"
end
end

View File

@ -83,6 +83,10 @@ class MassBuild < ActiveRecord::Base
generate_list BuildList::TESTS_FAILED
end
def generate_success_builds_list
generate_list BuildList::SUCCESS
end
def cancel_all
update_column(:stop_build, true)
build_lists.find_each(batch_size: 100) do |bl|

View File

@ -8,54 +8,13 @@
%tr
%th.lpadding16= t('activerecord.attributes.mass_build.id')
%th.lpadding16= t('activerecord.attributes.mass_build.name')
%th.lpadding16= t("layout.mass_builds.statuses")
%th.lpadding16= t("layout.mass_builds.lists")
%th.lpadding16= t("layout.mass_builds.actions")
%th.lpadding16= t("layout.mass_builds.extended_data")
%th.lpadding16= t('activerecord.attributes.mass_build.created_at')
%th.lpadding16
- @mass_builds.each do |mass_build|
%tr
%td= mass_build.id
%td= link_to mass_build.name, build_lists_path+"#?#{{filter: {mass_build_id: mass_build.id, ownership: 'everything'}}.to_param}"
%td.min_width_120
- MassBuild::COUNT_STATUSES.each do |status|
- path = build_lists_path+"#?#{{filter: {mass_build_id: mass_build.id, ownership: 'everything'}.merge(status != :build_lists ? {status: BuildList.status_by_human(status)} : {})}.to_param}"
= link_to t("layout.build_lists.statuses.#{status}") + ": ", path
= mass_build.send "#{status}_count"
.both
-if mass_build.projects_list.present?
=link_to_list @platform, mass_build, 'missed_projects_list'
= mass_build.send 'missed_projects_count'
%td
- if mass_build.projects_list.present?
= link_to_list @platform, mass_build, 'projects_list'
.both
%br
= link_to_list @platform, mass_build, 'failed_builds_list'
.both
%br
= link_to_list @platform, mass_build, 'tests_failed_builds_list'
%td= link_to_mass_build(mass_build)
%td= mass_build.created_at
%td.right.mass-build-actions
- if can?(:publish, mass_build)
- unless mass_build.auto_publish?
= link_to t('layout.mass_builds.publish_success'),
publish_platform_mass_build_path(@platform, mass_build.id),
method: :post, data: { confirm: t("layout.confirm") }, class: 'button'
= link_to t('layout.mass_builds.publish_test_failed'),
publish_platform_mass_build_path(@platform, mass_build.id, status: 'test_failed'),
method: :post, data: { confirm: t("layout.confirm") }, class: 'button'
- if can?(:cancel, mass_build)
= link_to t('layout.cancel'),
cancel_platform_mass_build_path(@platform, mass_build.id),
method: :post, class: 'button',
data: { confirm: t('layout.mass_builds.cancel_confirm') }
%td
%a.toggle_btn{href: "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
.toggle{id: "toggle_#{ mass_build.id }"}
= t('activerecord.attributes.mass_build.user') + ": "
= link_to mass_build.user.fullname, mass_build.user
- %i(arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at).each do |field|
.both
= t("activerecord.attributes.mass_build.#{field}") + ": "
= mass_build.send field
= link_to t('layout.show'), platform_mass_build_path(@platform, mass_build.id)
= will_paginate @mass_builds

View File

@ -0,0 +1,63 @@
-set_meta_tags title: title_object(@mass_build)
= render 'submenu'
= render 'sidebar'
%h3.fix
= t 'activerecord.models.mass_build'
%table.tablesorter.unbordered
%tr
%td
%b= t('activerecord.attributes.mass_build.name')
%td= link_to_mass_build(@mass_build)
- %i(id arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at).each do |field|
%tr
%td
%b= t("activerecord.attributes.mass_build.#{field}")
%td= @mass_build.send field
%tr
%td
%td
%tr
%td
%b= t('layout.mass_builds.statuses')
%td
- MassBuild::COUNT_STATUSES.each do |status|
- path = build_lists_path+"#?#{{filter: {mass_build_id: @mass_build.id, ownership: 'everything'}.merge(status != :build_lists ? {status: BuildList.status_by_human(status)} : {})}.to_param}"
%tr
%td
= link_to t("layout.build_lists.statuses.#{status}") + ": ", path
%td= @mass_build.send "#{status}_count"
%tr
%td
%td
%tr
%td
%b= t('layout.mass_builds.lists')
%td
- if @mass_build.projects_list.present?
= link_to_list @platform, @mass_build, 'projects_list'
.both
= link_to_list @platform, @mass_build, 'failed_builds_list'
.both
= link_to_list @platform, @mass_build, 'tests_failed_builds_list'
.both
= link_to_list @platform, @mass_build, 'success_builds_list'
.buttons_block
- if can?(:publish, @mass_build)
- unless @mass_build.auto_publish?
= link_to t('layout.mass_builds.publish_success'),
publish_platform_mass_build_path(@platform, @mass_build.id),
method: :post, data: { confirm: t("layout.confirm") }, class: 'button'
= link_to t('layout.mass_builds.publish_test_failed'),
publish_platform_mass_build_path(@platform, @mass_build.id, status: 'test_failed'),
method: :post, data: { confirm: t("layout.confirm") }, class: 'button'
- if can?(:cancel, @mass_build)
= link_to t('layout.cancel'),
cancel_platform_mass_build_path(@platform, @mass_build.id),
method: :post, class: 'button',
data: { confirm: t('layout.mass_builds.cancel_confirm') }

View File

@ -8,6 +8,7 @@ en:
extended_data: Extended data
lists: Lists
failed_builds_list: Failed Builds List
success_builds_list: Completed Build Lists
tests_failed_builds_list: Tests failed Builds List
statuses: Statuses
actions: Actions

View File

@ -8,6 +8,7 @@ ru:
extended_data: Параметры задания
lists: Списки
failed_builds_list: Сборки с ошибками
success_builds_list: Успешные сборки
tests_failed_builds_list: Сборки с ошибками в тестах
statuses: Статусы
actions: Действия

View File

@ -182,11 +182,11 @@ Rosa::Application.routes.draw do
end
end
resources :mass_builds, only: [:create, :new, :index] do
resources :mass_builds, only: [:create, :new, :index, :show] do
member do
post :cancel
post :publish
get '/:kind' => "mass_builds#get_list", as: :get_list, kind: /failed_builds_list|missed_projects_list|projects_list|tests_failed_builds_list/
get '/:kind' => "mass_builds#get_list", as: :get_list, kind: /failed_builds_list|missed_projects_list|projects_list|tests_failed_builds_list|success_builds_list/
end
end

View File

@ -6,6 +6,11 @@ shared_examples_for 'mass_build platform owner' do
response.should render_template(:index)
end
it 'should be able to perform show action' do
get :show, platform_id: @platform, id: @mass_build
response.should render_template(:show)
end
it 'should be able to perform new action' do
get :new, platform_id: @platform
response.should render_template(:new)