Merge pull request #574 from warpc/570-mass_builds_status_counters_bug
[refs #570] Fix mass builds counters update. Fix mass build and failed_build_list links.
This commit is contained in:
commit
a265feeb27
|
@ -17,7 +17,7 @@ class Ability
|
|||
can :archive, Project, :visibility => 'open'
|
||||
can :read, Issue, :project => {:visibility => 'open'}
|
||||
can :search, BuildList
|
||||
can :read, BuildList, :project => {:visibility => 'open'}
|
||||
can [:read, :everything], BuildList, :project => {:visibility => 'open'}
|
||||
can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
|
||||
can :read, Advisory
|
||||
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
|
||||
|
@ -62,10 +62,10 @@ class Ability
|
|||
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')}
|
||||
can :remove_user, Project
|
||||
|
||||
can [:read, :owned], BuildList, :user_id => user.id
|
||||
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :related], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
|
||||
can [:read, :owned, :everything], BuildList, :user_id => user.id
|
||||
can [:read, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can([:read, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
|
||||
can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)}
|
||||
|
||||
can(:publish, BuildList) do |build_list|
|
||||
|
|
|
@ -106,14 +106,16 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
# WTF? around_transition -> infinite loop
|
||||
before_transition do |build_list, transition|
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
|
||||
MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
|
||||
status = BuildList::HUMAN_STATUSES[build_list.status]
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
end
|
||||
|
||||
after_transition do |build_list, transition|
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
|
||||
MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
|
||||
status = BuildList::HUMAN_STATUSES[build_list.status]
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,8 +52,10 @@ class BuildList::Filter
|
|||
:mass_build_id => nil
|
||||
}))
|
||||
|
||||
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'index' : 'owned')
|
||||
@options[:status] = @options[:status].try(:to_i)
|
||||
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned')
|
||||
@options[:status] = @options[:status].present? ? @options[:status].to_i : nil
|
||||
@options[:created_at_start] = build_date_from_params(:created_at_start, @options)
|
||||
@options[:created_at_end] = build_date_from_params(:created_at_end, @options)
|
||||
@options[:updated_at_start] = build_date_from_params(:updated_at_start, @options)
|
||||
@options[:updated_at_end] = build_date_from_params(:updated_at_end, @options)
|
||||
@options[:project_version] = @options[:project_version].presence
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
- @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})
|
||||
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'})
|
||||
%td.min_width_120
|
||||
- MassBuild::COUNT_STATUSES.each do |status|
|
||||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
|
||||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
|
||||
= mass_build.read_attribute "#{status}_count"
|
||||
.both
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build)
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build)
|
||||
%td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build)
|
||||
%td
|
||||
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
.lefter= t("layout.build_lists.ownership.related")
|
||||
.both
|
||||
.table
|
||||
.lefter= f.radio_button :ownership, 'index', :class => 'niceRadio', :id => 'myradio3'
|
||||
.lefter= t("layout.build_lists.ownership.index")
|
||||
.lefter= f.radio_button :ownership, 'everything', :class => 'niceRadio', :id => 'myradio3'
|
||||
.lefter= t("layout.build_lists.ownership.everything")
|
||||
.both
|
||||
%br
|
||||
= f.submit t("layout.search.header")
|
||||
|
|
|
@ -80,7 +80,7 @@ en:
|
|||
header: Build list ownership
|
||||
owned: My
|
||||
related: Related
|
||||
index: All
|
||||
everything: All
|
||||
|
||||
build_server_status:
|
||||
header: Build server status
|
||||
|
|
|
@ -79,7 +79,7 @@ ru:
|
|||
header: Принадлежность заданий
|
||||
owned: Мне
|
||||
related: Связанные со мной
|
||||
index: Все
|
||||
everything: Все
|
||||
|
||||
build_server_status:
|
||||
header: Статус сборочного сервера
|
||||
|
|
38
db/schema.rb
38
db/schema.rb
|
@ -160,12 +160,12 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
|
|||
end
|
||||
|
||||
create_table "flash_notifies", :force => true do |t|
|
||||
t.text "body_ru", :null => false
|
||||
t.text "body_en", :null => false
|
||||
t.string "status", :null => false
|
||||
t.boolean "published", :default => true, :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "body_ru"
|
||||
t.text "body_en"
|
||||
t.string "status"
|
||||
t.boolean "published", :default => true
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "groups", :force => true do |t|
|
||||
|
@ -193,6 +193,15 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
|
|||
|
||||
add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true
|
||||
|
||||
create_table "key_pairs", :force => true do |t|
|
||||
t.integer "repository_id"
|
||||
t.integer "user_id"
|
||||
t.integer "key_id"
|
||||
t.string "public"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "labelings", :force => true do |t|
|
||||
t.integer "label_id", :null => false
|
||||
t.integer "issue_id"
|
||||
|
@ -311,27 +320,25 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
|
|||
t.text "description"
|
||||
t.string "ancestry"
|
||||
t.boolean "has_issues", :default => true
|
||||
t.boolean "has_wiki", :default => false
|
||||
t.string "srpm_file_name"
|
||||
t.string "srpm_content_type"
|
||||
t.integer "srpm_file_size"
|
||||
t.datetime "srpm_updated_at"
|
||||
t.boolean "has_wiki", :default => false
|
||||
t.string "default_branch", :default => "master"
|
||||
t.boolean "is_package", :default => true, :null => false
|
||||
t.integer "average_build_time", :default => 0, :null => false
|
||||
t.integer "build_count", :default => 0, :null => false
|
||||
end
|
||||
|
||||
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
|
||||
|
||||
create_table "register_requests", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
t.string "token"
|
||||
t.boolean "approved", :default => false
|
||||
t.boolean "rejected", :default => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "interest"
|
||||
t.text "more"
|
||||
end
|
||||
|
@ -385,6 +392,7 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
|
|||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
|
@ -392,8 +400,11 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
|
|||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.text "professional_experience"
|
||||
t.string "site"
|
||||
t.string "company"
|
||||
|
@ -405,9 +416,6 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
|
|||
t.integer "failed_attempts", :default => 0
|
||||
t.string "unlock_token"
|
||||
t.datetime "locked_at"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "authentication_token"
|
||||
t.integer "build_priority", :default => 50
|
||||
end
|
||||
|
|
|
@ -125,7 +125,7 @@ describe Projects::BuildListsController do
|
|||
end
|
||||
|
||||
it 'should show only accessible build_lists' do
|
||||
get :index, :filter => {:ownership => 'index'}
|
||||
get :index, :filter => {:ownership => 'everything'}
|
||||
assigns(:build_lists).should include(@build_list1)
|
||||
assigns(:build_lists).should_not include(@build_list2)
|
||||
assigns(:build_lists).should include(@build_list3)
|
||||
|
@ -210,7 +210,7 @@ describe Projects::BuildListsController do
|
|||
end
|
||||
|
||||
it 'should show only accessible build_lists' do
|
||||
get :index, :filter => {:ownership => 'index'}
|
||||
get :index, :filter => {:ownership => 'everything'}
|
||||
assigns(:build_lists).should include(@build_list1)
|
||||
assigns(:build_lists).should_not include(@build_list2)
|
||||
assigns(:build_lists).should include(@build_list3)
|
||||
|
@ -297,17 +297,17 @@ describe Projects::BuildListsController do
|
|||
|
||||
it 'should filter by project_name' do
|
||||
# Project.where(:id => build_list2.project.id).update_all(:name => 'project_name')
|
||||
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'index'}
|
||||
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'everything'}
|
||||
assigns[:build_lists].should_not include(@build_list1)
|
||||
assigns[:build_lists].should include(@build_list2)
|
||||
assigns[:build_lists].should_not include(@build_list3)
|
||||
end
|
||||
|
||||
it 'should filter by project_name and start_date' do
|
||||
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'index',
|
||||
:"updated_at_start(1i)" => @build_list3.updated_at.year.to_s,
|
||||
:"updated_at_start(2i)" => @build_list3.updated_at.month.to_s,
|
||||
:"updated_at_start(3i)" => @build_list3.updated_at.day.to_s}
|
||||
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'everything',
|
||||
"created_at_start(1i)" => @build_list3.created_at.year.to_s,
|
||||
"created_at_start(2i)" => @build_list3.created_at.month.to_s,
|
||||
"created_at_start(3i)" => @build_list3.created_at.day.to_s}
|
||||
assigns[:build_lists].should_not include(@build_list1)
|
||||
assigns[:build_lists].should_not include(@build_list2)
|
||||
assigns[:build_lists].should include(@build_list3)
|
||||
|
|
Loading…
Reference in New Issue