Merge pull request #70 from abf/rosa-build:55-open-MassBuild-from-platform-menu-to-guests
#55: Open MassBuild from platform menu to guests
This commit is contained in:
commit
e262491271
|
@ -1,6 +1,7 @@
|
||||||
#class MassBuildsController < ApplicationController
|
#class MassBuildsController < ApplicationController
|
||||||
class Platforms::MassBuildsController < Platforms::BaseController
|
class Platforms::MassBuildsController < Platforms::BaseController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
skip_before_filter :authenticate_user!, :only => [:index, :get_list] if APP_CONFIG['anonymous_access']
|
||||||
|
|
||||||
load_and_authorize_resource :platform
|
load_and_authorize_resource :platform
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
@ -37,8 +38,6 @@ class Platforms::MassBuildsController < Platforms::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize! :local_admin_manage, @platform
|
|
||||||
|
|
||||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||||
@auto_publish_selected = true
|
@auto_publish_selected = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Ability
|
||||||
# Platforms block
|
# Platforms block
|
||||||
can [:show, :members, :advisories], Platform, :visibility => 'open'
|
can [:show, :members, :advisories], Platform, :visibility => 'open'
|
||||||
can :platforms_for_build, Platform, :visibility => 'open', :platform_type => 'main'
|
can :platforms_for_build, Platform, :visibility => 'open', :platform_type => 'main'
|
||||||
|
can(:get_list, MassBuild) {|mass_build| mass_build.platform.main? && can?(:show, mass_build.platform) }
|
||||||
can [:read, :projects_list, :projects], Repository, :platform => {:visibility => 'open'}
|
can [:read, :projects_list, :projects], Repository, :platform => {:visibility => 'open'}
|
||||||
can :read, Product, :platform => {:visibility => 'open'}
|
can :read, Product, :platform => {:visibility => 'open'}
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ class Ability
|
||||||
can([:update, :destroy], Platform) {|platform| owner?(platform) }
|
can([:update, :destroy], Platform) {|platform| owner?(platform) }
|
||||||
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
||||||
|
|
||||||
can([:get_list, :create, :publish], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
|
can([:create, :publish], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
|
||||||
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && mass_build.platform.main?}
|
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && mass_build.platform.main?}
|
||||||
|
|
||||||
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
|
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
- if can? :show, @platform
|
- if can? :show, @platform
|
||||||
%li{:class => (act == :index && contr == :maintainers) ? 'active' : nil}
|
%li{:class => (act == :index && contr == :maintainers) ? 'active' : nil}
|
||||||
= link_to t("layout.platforms.maintainers"), platform_maintainers_path(@platform)
|
= link_to t("layout.platforms.maintainers"), platform_maintainers_path(@platform)
|
||||||
- if can? :edit, @platform
|
- if can? :show, @platform
|
||||||
%li{:class => (contr == :mass_builds && [:index, :create].include?(act)) ? 'active' : ''}
|
%li{:class => (contr == :mass_builds && [:index, :create].include?(act)) ? 'active' : ''}
|
||||||
= link_to t("layout.platforms.mass_build"), platform_mass_builds_path(@platform)
|
= link_to t("layout.platforms.mass_build"), platform_mass_builds_path(@platform)
|
||||||
- if can? :read, @platform.products.build
|
- if can? :read, @platform.products.build
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
= form_for :build, :url => platform_mass_builds_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
|
||||||
|
%section.left
|
||||||
|
=render 'repos_or_list_choice'
|
||||||
|
%br
|
||||||
|
= f.submit t("layout.projects.build_button")
|
||||||
|
%section.right
|
||||||
|
%h3= t("activerecord.attributes.build_list.arch")
|
||||||
|
- Arch.recent.each do |arch|
|
||||||
|
.lefter
|
||||||
|
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
|
||||||
|
= label_tag "arches_#{arch.id}", arch.name
|
||||||
|
.both
|
||||||
|
%h3= t("activerecord.attributes.build_list.preferences")
|
||||||
|
.both.bottom_20
|
||||||
|
= check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish'
|
||||||
|
= label_tag :auto_publish, t('activerecord.attributes.build_list.auto_publish')
|
||||||
|
.both
|
|
@ -1,24 +1,7 @@
|
||||||
= render 'platforms/base/submenu'
|
= render 'platforms/base/submenu'
|
||||||
= render 'platforms/base/sidebar'
|
= render 'platforms/base/sidebar'
|
||||||
|
|
||||||
= form_for :build, :url => platform_mass_builds_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
|
= render 'form' if can? :edit, @platform
|
||||||
%section.left
|
|
||||||
=render 'repos_or_list_choice'
|
|
||||||
%br
|
|
||||||
= f.submit t("layout.projects.build_button")
|
|
||||||
%section.right
|
|
||||||
%h3= t("activerecord.attributes.build_list.arch")
|
|
||||||
- Arch.recent.each do |arch|
|
|
||||||
.lefter
|
|
||||||
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
|
|
||||||
= label_tag "arches_#{arch.id}", arch.name
|
|
||||||
.both
|
|
||||||
%h3= t("activerecord.attributes.build_list.preferences")
|
|
||||||
.both.bottom_20
|
|
||||||
= check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish'
|
|
||||||
= label_tag :auto_publish, t('activerecord.attributes.build_list.auto_publish')
|
|
||||||
%br
|
|
||||||
%br
|
|
||||||
|
|
||||||
%table.tablesorter.unbordered{:cellpadding => "0", :cellspacing => "0"}
|
%table.tablesorter.unbordered{:cellpadding => "0", :cellspacing => "0"}
|
||||||
%thead
|
%thead
|
||||||
|
|
|
@ -42,6 +42,11 @@ shared_examples_for 'mass_build platform owner' do
|
||||||
lambda { post :create, @create_params }.should change{ MassBuild.count }.by(1)
|
lambda { post :create, @create_params }.should change{ MassBuild.count }.by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should be able to perform get_list action' do
|
||||||
|
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
context 'for personal platform' do
|
context 'for personal platform' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Platform.update_all(:platform_type => 'personal')
|
Platform.update_all(:platform_type => 'personal')
|
||||||
|
@ -57,14 +62,22 @@ shared_examples_for 'mass_build platform owner' do
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'mass_build platform reader' do
|
shared_examples_for 'mass_build platform reader' do
|
||||||
[:index, :create].each do |action|
|
it 'should be able to perform index action' do
|
||||||
it "should not be able to perform #{ action } action" do
|
get :index, :platform_id => @platform
|
||||||
get action, :platform_id => @platform
|
response.should render_template(:index)
|
||||||
response.should redirect_to(forbidden_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
[:cancel, :get_list, :publish].each do |action|
|
it 'should be able to perform get_list action' do
|
||||||
|
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be able to perform create action" do
|
||||||
|
get :create, :platform_id => @platform
|
||||||
|
response.should redirect_to(forbidden_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
[:cancel, :publish].each do |action|
|
||||||
it "should not be able to perform #{ action } action" do
|
it "should not be able to perform #{ action } action" do
|
||||||
get action, :platform_id => @platform, :id => @mass_build.id
|
get action, :platform_id => @platform, :id => @mass_build.id
|
||||||
response.should redirect_to(forbidden_path)
|
response.should redirect_to(forbidden_path)
|
||||||
|
@ -111,15 +124,29 @@ describe Platforms::MassBuildsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for guest' do
|
context 'for guest' do
|
||||||
[:index, :create].each do |action|
|
|
||||||
it "should not be able to perform #{ action } action" do
|
it 'should be able to perform index action', :anonymous_access => true do
|
||||||
get action, :platform_id => @platform
|
get :index, :platform_id => @platform
|
||||||
response.should redirect_to(new_user_session_path)
|
response.should render_template(:index)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not be able to get failed builds list" do
|
it 'should not be able to perform index action', :anonymous_access => false do
|
||||||
|
get :index, :platform_id => @platform
|
||||||
|
response.should redirect_to(new_user_session_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be able to perform get_list action', :anonymous_access => true do
|
||||||
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
|
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be able to get failed builds list", :anonymous_access => false do
|
||||||
|
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
|
||||||
|
response.should redirect_to(new_user_session_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be able to perform create action" do
|
||||||
|
get :create, :platform_id => @platform
|
||||||
response.should redirect_to(new_user_session_path)
|
response.should redirect_to(new_user_session_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue