Merge pull request #82 from warpc/65-build_repo
Fix broken tests after #65 (choose repos for builds)
This commit is contained in:
commit
0f055b8410
|
@ -36,7 +36,7 @@ class BuildListsController < ApplicationController
|
|||
|
||||
def create
|
||||
notices, errors = [], []
|
||||
Arch.where(:id => params[:archs]).each do |arch|
|
||||
Arch.where(:id => params[:arches]).each do |arch|
|
||||
Platform.main.where(:id => params[:bpls]).each do |bpl|
|
||||
@build_list = @project.build_lists.build(params[:build_list])
|
||||
@build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
.group
|
||||
= f.label :arches, t("activerecord.attributes.build_list.arch"), :class => :label
|
||||
- Arch.recent.each do |arch|
|
||||
= check_box_tag "archs[]", arch.id, (params[:archs]||[]).include?(arch.id.to_s), :id => "archs_#{arch.id}"
|
||||
= label_tag "archs_#{arch.id}", arch.name
|
||||
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
|
||||
= label_tag "arches_#{arch.id}", arch.name
|
||||
%br
|
||||
|
||||
.group
|
||||
|
|
11
db/schema.rb
11
db/schema.rb
|
@ -245,7 +245,6 @@ ActiveRecord::Schema.define(:version => 20111221194422) do
|
|||
t.string "object_type"
|
||||
t.integer "target_id"
|
||||
t.string "target_type"
|
||||
t.integer "role_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "role"
|
||||
|
@ -274,16 +273,16 @@ ActiveRecord::Schema.define(:version => 20111221194422) do
|
|||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
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 "reset_password_sent_at"
|
||||
t.string "remember_token"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "uname"
|
||||
t.text "ssh_key"
|
||||
t.integer "role_id"
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
=== Basic bootstrap
|
||||
|
||||
* rake db:drop db:setup
|
||||
|
||||
==
|
||||
|
||||
=== Setup autostart
|
||||
Add to /etc/rc.d/rc.local following /srv/rosa_build/current/bin/autostart.sh
|
||||
==
|
||||
|
||||
Add to /etc/rc.d/rc.local
|
||||
|
||||
/srv/rosa_build/current/bin/autostart.sh
|
||||
|
||||
Add to /etc/rc.d/rc.sysinit
|
||||
|
||||
# force run rc.local
|
||||
if [ -f /etc/rc.local ]; then
|
||||
. /etc/rc.local
|
||||
fi
|
||||
|
||||
==
|
||||
|
|
|
@ -25,8 +25,49 @@ describe BuildListsController do
|
|||
response.should redirect_to(forbidden_url)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'create build list' do
|
||||
it 'should be able to perform new action' do
|
||||
get :new, :project_id => @project.id
|
||||
response.should render_template(:new)
|
||||
end
|
||||
|
||||
it 'should be able to perform create action' do
|
||||
post :create, {:project_id => @project.id}.merge(@create_params)
|
||||
response.should redirect_to(@project)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'not create build list' do
|
||||
it 'should not be able to perform new action' do
|
||||
get :new, :project_id => @project.id
|
||||
response.should redirect_to(forbidden_url)
|
||||
end
|
||||
|
||||
it 'should not be able to perform create action' do
|
||||
post :create, {:project_id => @project.id}.merge(@create_params)
|
||||
response.should redirect_to(forbidden_url)
|
||||
end
|
||||
end
|
||||
|
||||
context 'crud' do
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
|
||||
platform = Factory(:platform_with_repos)
|
||||
@create_params = {
|
||||
:build_list => {
|
||||
:project_version => 'v1.0',
|
||||
:pl_id => platform.id,
|
||||
:update_type => 'security',
|
||||
:include_repos => [platform.repositories.first.id]
|
||||
},
|
||||
:arches => [Factory(:arch).id],
|
||||
:bpls => [platform.id]
|
||||
}
|
||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||
end
|
||||
|
||||
context 'for guest' do
|
||||
it 'should not be able to perform index action' do
|
||||
get :index
|
||||
|
@ -36,7 +77,6 @@ describe BuildListsController do
|
|||
|
||||
context 'for user' do
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
@build_list = Factory(:build_list_core)
|
||||
@project = @build_list.project
|
||||
@owner_user = @project.owner
|
||||
|
@ -47,7 +87,6 @@ describe BuildListsController do
|
|||
@user = Factory(:user)
|
||||
set_session_for(@user)
|
||||
@show_params = {:project_id => @project.id, :id => @build_list.id}
|
||||
|
||||
end
|
||||
|
||||
context 'for all build lists' do
|
||||
|
@ -76,15 +115,18 @@ describe BuildListsController do
|
|||
|
||||
context 'for open project' do
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
|
||||
context 'if user is project owner' do
|
||||
before(:each) {set_session_for(@owner_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'create build list'
|
||||
end
|
||||
|
||||
context 'if user is project member' do
|
||||
context 'if user is project read member' do
|
||||
before(:each) {set_session_for(@member_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -95,23 +137,24 @@ describe BuildListsController do
|
|||
end
|
||||
|
||||
it_should_behave_like 'not show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
|
||||
context 'if user is project owner' do
|
||||
before(:each) {set_session_for(@owner_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'create build list'
|
||||
end
|
||||
|
||||
context 'if user is project member' do
|
||||
context 'if user is project read member' do
|
||||
before(:each) {set_session_for(@member_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'for group' do
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
@owner_group = Factory(:group)
|
||||
@owner_user = Factory(:user)
|
||||
@owner_group.objects.create :role => 'reader', :object_id => @owner_user.id, :object_type => 'User'
|
||||
|
@ -158,15 +201,18 @@ describe BuildListsController do
|
|||
|
||||
context 'for open project' do
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
|
||||
context 'if user is group owner' do
|
||||
before(:each) {set_session_for(@owner_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'create build list'
|
||||
end
|
||||
|
||||
context 'if user is group member' do
|
||||
context 'if user is group read member' do
|
||||
before(:each) {set_session_for(@member_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -177,15 +223,18 @@ describe BuildListsController do
|
|||
end
|
||||
|
||||
it_should_behave_like 'not show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
|
||||
context 'if user is group owner' do
|
||||
before(:each) {set_session_for(@owner_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'create build list'
|
||||
end
|
||||
|
||||
context 'if user is group member' do
|
||||
context 'if user is group read member' do
|
||||
before(:each) {set_session_for(@member_user)}
|
||||
it_should_behave_like 'show build list'
|
||||
it_should_behave_like 'not create build list'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,17 +8,6 @@ describe ProjectsController do
|
|||
@another_user = Factory(:user)
|
||||
@create_params = {:project => {:name => 'pro'}}
|
||||
@update_params = {:project => {:name => 'pro2'}}
|
||||
|
||||
platform = Factory(:platform)
|
||||
@process_build_params = {:build => {
|
||||
:arches => {Factory(:arch).id => '1'},
|
||||
:project_version => 'v1.0',
|
||||
:bpl => {platform.id => '1'},
|
||||
:pl => platform.id,
|
||||
:update_type => 'security'
|
||||
}}
|
||||
|
||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||
end
|
||||
|
||||
context 'for guest' do
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
Factory.define(:build_list) do |p|
|
||||
p.association :project, :factory => :project
|
||||
p.association :pl, :factory => :platform
|
||||
p.association :arch, :factory => :arch
|
||||
p.bpl { |bl| bl.pl }
|
||||
p.association :user
|
||||
p.association :project
|
||||
p.association :pl, :factory => :platform_with_repos
|
||||
p.association :arch
|
||||
p.bpl {|bl| bl.pl}
|
||||
p.project_version "1.0"
|
||||
p.build_requires true
|
||||
p.update_type 'security'
|
||||
p.include_repos {|bl| bl.pl.repositories.map(&:id)}
|
||||
end
|
||||
|
||||
Factory.define(:build_list_core, :parent => :build_list) do |p|
|
||||
|
|
|
@ -5,3 +5,7 @@ Factory.define(:platform) do |p|
|
|||
p.distrib_type APP_CONFIG['distr_types'].first
|
||||
p.association :owner, :factory => :user
|
||||
end
|
||||
|
||||
Factory.define(:platform_with_repos, :parent => :platform) do |p|
|
||||
p.repositories {|r| [r.association(:repository)]}
|
||||
end
|
|
@ -144,15 +144,16 @@ describe CanCan do
|
|||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'writer')
|
||||
end
|
||||
|
||||
[:read, :update, :process_build, :build].each do |action|
|
||||
[:read, :create, :new].each do |action|
|
||||
it "should be able to #{ action } project" do
|
||||
@ability.should be_able_to(action, @project)
|
||||
end
|
||||
end
|
||||
|
||||
[:read, :create, :new].each do |action|
|
||||
it "should be able to #{ action } project" do
|
||||
@ability.should be_able_to(action, @project)
|
||||
[:new, :create].each do |action|
|
||||
it "should be able to #{action} build_list" do
|
||||
@build_list = Factory(:build_list, :project => @project)
|
||||
@ability.should be_able_to(action, @build_list)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -162,12 +163,19 @@ describe CanCan do
|
|||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'admin')
|
||||
end
|
||||
|
||||
[:read, :update, :process_build, :build].each do |action|
|
||||
[:read, :update].each do |action|
|
||||
it "should be able to #{ action } project" do
|
||||
@ability.should be_able_to(action, @project)
|
||||
end
|
||||
end
|
||||
|
||||
[:new, :create].each do |action|
|
||||
it "should be able to #{action} build_list" do
|
||||
@build_list = Factory(:build_list, :project => @project)
|
||||
@ability.should be_able_to(action, @build_list)
|
||||
end
|
||||
end
|
||||
|
||||
it "should be able to manage collaborators of project" do
|
||||
@ability.should be_able_to(:manage_collaborators, @project)
|
||||
end
|
||||
|
@ -185,12 +193,19 @@ describe CanCan do
|
|||
@issue.project.reload
|
||||
end
|
||||
|
||||
[:read, :update, :process_build, :build, :destroy].each do |action|
|
||||
[:read, :update, :destroy].each do |action|
|
||||
it "should be able to #{ action } project" do
|
||||
@ability.should be_able_to(action, @project)
|
||||
end
|
||||
end
|
||||
|
||||
[:new, :create].each do |action|
|
||||
it "should be able to #{action} build_list" do
|
||||
@build_list = Factory(:build_list, :project => @project)
|
||||
@ability.should be_able_to(action, @build_list)
|
||||
end
|
||||
end
|
||||
|
||||
[:read, :update, :edit].each do |action|
|
||||
it "should be able to #{ action } issue" do
|
||||
@ability.should be_able_to(action, @issue)
|
||||
|
|
|
@ -12,16 +12,6 @@ shared_examples_for 'projects user with writer rights' do
|
|||
put :update, {:id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(project_path(@project))
|
||||
end
|
||||
|
||||
it 'should be able to perform build action' do
|
||||
get :build, :id => @project.id
|
||||
response.should render_template(:build)
|
||||
end
|
||||
|
||||
it 'should be able to perform process_build action' do
|
||||
post :process_build, {:id => @project.id}.merge(@process_build_params)
|
||||
response.should redirect_to(project_path(@project))
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'user with rights to view projects' do
|
||||
|
|
Loading…
Reference in New Issue