2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-12-02 01:30:25 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2012-05-02 10:18:07 +01:00
|
|
|
describe Projects::BuildListsController do
|
2011-12-14 22:04:05 +00:00
|
|
|
|
|
|
|
shared_examples_for 'show build list' do
|
|
|
|
it 'should be able to perform show action' do
|
|
|
|
get :show, @show_params
|
|
|
|
response.should be_success
|
|
|
|
end
|
2011-12-21 01:30:34 +00:00
|
|
|
|
|
|
|
it 'should be able to perform index action in project scope' do
|
2012-04-23 21:55:42 +01:00
|
|
|
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
2011-12-21 01:30:34 +00:00
|
|
|
response.should be_success
|
|
|
|
end
|
2011-12-14 22:04:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for 'not show build list' do
|
|
|
|
it 'should not be able to perform show action' do
|
|
|
|
get :show, @show_params
|
|
|
|
response.should redirect_to(forbidden_url)
|
|
|
|
end
|
2011-12-21 01:30:34 +00:00
|
|
|
|
|
|
|
it 'should not be able to perform index action in project scope' do
|
2012-04-23 21:55:42 +01:00
|
|
|
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
2011-12-21 01:30:34 +00:00
|
|
|
response.should redirect_to(forbidden_url)
|
|
|
|
end
|
2011-12-14 22:04:05 +00:00
|
|
|
end
|
2012-06-19 11:23:03 +01:00
|
|
|
|
2011-12-23 02:14:28 +00:00
|
|
|
shared_examples_for 'create build list' do
|
2012-08-09 15:38:41 +01:00
|
|
|
before {
|
|
|
|
@project.update_attribute(:repositories, @platform.repositories)
|
|
|
|
}
|
2012-01-16 21:51:20 +00:00
|
|
|
|
2011-12-23 02:14:28 +00:00
|
|
|
it 'should be able to perform new action' do
|
2012-04-23 21:55:42 +01:00
|
|
|
get :new, :owner_name => @project.owner.uname, :project_name => @project.name
|
2011-12-23 02:14:28 +00:00
|
|
|
response.should render_template(:new)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be able to perform create action' do
|
2012-04-23 21:55:42 +01:00
|
|
|
post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params)
|
2012-04-03 13:21:39 +01:00
|
|
|
response.should redirect_to project_build_lists_path(@project)
|
2011-12-23 02:14:28 +00:00
|
|
|
end
|
2012-01-17 12:25:54 +00:00
|
|
|
|
|
|
|
it 'should save correct commit_hash for branch based build' do
|
2012-04-23 21:55:42 +01:00
|
|
|
post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params).deep_merge(:build_list => {:project_version => "latest_master"})
|
2012-12-18 18:53:41 +00:00
|
|
|
@project.build_lists.last.commit_hash.should == @project.repo.commits('master').first.id
|
2012-01-17 12:25:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should save correct commit_hash for tag based build' do
|
2012-07-17 09:02:56 +01:00
|
|
|
system("cd #{@project.repo.path} && git tag 4.7.5.3") # TODO REDO through grit
|
2012-04-23 21:55:42 +01:00
|
|
|
post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params).deep_merge(:build_list => {:project_version => "4.7.5.3"})
|
2012-12-18 18:53:41 +00:00
|
|
|
@project.build_lists.last.commit_hash.should == @project.repo.commits('4.7.5.3').first.id
|
2012-01-17 12:25:54 +00:00
|
|
|
end
|
2012-10-11 11:55:06 +01:00
|
|
|
|
|
|
|
it 'should not be able to create with wrong project version' do
|
|
|
|
lambda{ post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params).deep_merge(:build_list => {:project_version => "latest_wrong", :commit_hash => nil})}.should change{@project.build_lists.count}.by(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not be able to create with wrong git hash' do
|
|
|
|
lambda{ post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params).deep_merge(:build_list => {:commit_hash => 'wrong'})}.should change{@project.build_lists.count}.by(0)
|
|
|
|
end
|
2011-12-23 02:14:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for 'not create build list' do
|
2012-08-09 15:38:41 +01:00
|
|
|
before {
|
|
|
|
@project.update_attribute(:repositories, @platform.repositories)
|
|
|
|
}
|
|
|
|
|
2011-12-23 02:14:28 +00:00
|
|
|
it 'should not be able to perform new action' do
|
2012-04-23 21:55:42 +01:00
|
|
|
get :new, :owner_name => @project.owner.uname, :project_name => @project.name
|
2011-12-23 02:14:28 +00:00
|
|
|
response.should redirect_to(forbidden_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not be able to perform create action' do
|
2012-04-23 21:55:42 +01:00
|
|
|
post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params)
|
2011-12-23 02:14:28 +00:00
|
|
|
response.should redirect_to(forbidden_url)
|
|
|
|
end
|
|
|
|
end
|
2011-12-14 22:04:05 +00:00
|
|
|
|
2012-05-16 16:29:28 +01:00
|
|
|
before { stub_symlink_methods }
|
2011-12-29 02:37:34 +00:00
|
|
|
|
2011-12-02 01:30:25 +00:00
|
|
|
context 'crud' do
|
2011-12-23 02:14:28 +00:00
|
|
|
before(:each) do
|
2012-08-09 15:38:41 +01:00
|
|
|
@platform = FactoryGirl.create(:platform_with_repos)
|
2011-12-23 02:14:28 +00:00
|
|
|
@create_params = {
|
2012-10-11 11:55:06 +01:00
|
|
|
:build_list => {
|
2012-01-30 20:36:58 +00:00
|
|
|
:project_version => 'latest_master',
|
2012-09-27 00:54:56 +01:00
|
|
|
:save_to_repository_id => @platform.repositories.first.id,
|
2011-12-23 02:14:28 +00:00
|
|
|
:update_type => 'security',
|
2012-08-09 15:38:41 +01:00
|
|
|
:include_repos => [@platform.repositories.first.id]
|
2011-12-23 02:14:28 +00:00
|
|
|
},
|
2012-03-29 21:34:22 +01:00
|
|
|
:arches => [FactoryGirl.create(:arch).id],
|
2012-08-09 15:38:41 +01:00
|
|
|
:build_for_platforms => [@platform.id]
|
2011-12-23 02:14:28 +00:00
|
|
|
}
|
|
|
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
|
|
|
end
|
|
|
|
|
2011-12-02 01:30:25 +00:00
|
|
|
context 'for guest' do
|
2012-09-27 00:54:56 +01:00
|
|
|
it 'should be able to perform index action', :anonymous_access => true do
|
|
|
|
get :index
|
|
|
|
response.should be_success
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not be able to perform index action', :anonymous_access => false do
|
|
|
|
get :index
|
|
|
|
response.should redirect_to(new_user_session_path)
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for user' do
|
2011-12-14 21:04:39 +00:00
|
|
|
before(:each) do
|
2012-03-29 21:34:22 +01:00
|
|
|
@build_list = FactoryGirl.create(:build_list_core)
|
2011-12-14 21:04:39 +00:00
|
|
|
@project = @build_list.project
|
|
|
|
@owner_user = @project.owner
|
2012-03-29 21:34:22 +01:00
|
|
|
@member_user = FactoryGirl.create(:user)
|
2011-12-14 21:04:39 +00:00
|
|
|
rel = @project.relations.build(:role => 'reader')
|
2012-04-26 02:38:33 +01:00
|
|
|
rel.actor = @member_user
|
2011-12-14 21:04:39 +00:00
|
|
|
rel.save
|
2012-03-29 21:34:22 +01:00
|
|
|
@user = FactoryGirl.create(:user)
|
2011-12-14 21:04:39 +00:00
|
|
|
set_session_for(@user)
|
2012-04-23 21:55:42 +01:00
|
|
|
@show_params = {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @build_list.id}
|
2011-12-14 21:04:39 +00:00
|
|
|
end
|
2012-08-31 23:00:39 +01:00
|
|
|
|
2011-12-20 08:44:58 +00:00
|
|
|
context 'for all build lists' do
|
|
|
|
before(:each) do
|
2012-03-29 21:34:22 +01:00
|
|
|
@build_list1 = FactoryGirl.create(:build_list_core)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2012-08-09 15:38:41 +01:00
|
|
|
@build_list2 = FactoryGirl.create(:build_list_core)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list2.project.update_column(:visibility, 'hidden')
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2012-12-18 18:53:41 +00:00
|
|
|
project = FactoryGirl.create(:project_with_commit, :visibility => 'hidden', :owner => @user)
|
2012-12-26 14:02:56 +00:00
|
|
|
@build_list3 = create_build_list_with_project(:build_list_core, nil, project)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2012-08-09 15:38:41 +01:00
|
|
|
@build_list4 = FactoryGirl.create(:build_list_core)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list4.project.update_column(:visibility, 'hidden')
|
|
|
|
@build_list4.project.relations.create! :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
2011-12-15 21:58:20 +00:00
|
|
|
end
|
2011-12-20 08:44:58 +00:00
|
|
|
|
2011-12-21 01:30:34 +00:00
|
|
|
it 'should be able to perform index action' do
|
|
|
|
get :index
|
2011-12-20 08:44:58 +00:00
|
|
|
response.should be_success
|
2011-12-15 21:58:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should show only accessible build_lists' do
|
2012-07-18 15:13:37 +01:00
|
|
|
get :index, :filter => {:ownership => 'everything'}
|
2011-12-20 08:44:58 +00:00
|
|
|
assigns(:build_lists).should include(@build_list1)
|
|
|
|
assigns(:build_lists).should_not include(@build_list2)
|
|
|
|
assigns(:build_lists).should include(@build_list3)
|
|
|
|
assigns(:build_lists).should include(@build_list4)
|
2011-12-15 21:58:20 +00:00
|
|
|
end
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
2011-12-14 21:04:39 +00:00
|
|
|
|
2011-12-14 21:30:15 +00:00
|
|
|
context 'for open project' do
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-14 21:04:39 +00:00
|
|
|
|
2011-12-14 21:30:15 +00:00
|
|
|
context 'if user is project owner' do
|
|
|
|
before(:each) {set_session_for(@owner_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'create build list'
|
2011-12-14 21:04:39 +00:00
|
|
|
end
|
|
|
|
|
2011-12-23 18:47:13 +00:00
|
|
|
context 'if user is project read member' do
|
2011-12-14 21:30:15 +00:00
|
|
|
before(:each) {set_session_for(@member_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-14 21:04:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-14 21:30:15 +00:00
|
|
|
context 'for hidden project' do
|
|
|
|
before(:each) do
|
|
|
|
@project.visibility = 'hidden'
|
|
|
|
@project.save
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'not show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-14 21:30:15 +00:00
|
|
|
|
|
|
|
context 'if user is project owner' do
|
|
|
|
before(:each) {set_session_for(@owner_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'create build list'
|
2011-12-14 21:04:39 +00:00
|
|
|
end
|
|
|
|
|
2011-12-23 18:47:13 +00:00
|
|
|
context 'if user is project read member' do
|
2011-12-14 21:30:15 +00:00
|
|
|
before(:each) {set_session_for(@member_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-14 21:04:39 +00:00
|
|
|
end
|
|
|
|
end
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
|
|
|
|
2011-12-20 12:59:09 +00:00
|
|
|
context 'for group' do
|
|
|
|
before(:each) do
|
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@user = FactoryGirl.create(:user)
|
2012-09-27 00:54:56 +01:00
|
|
|
set_session_for(@user)
|
2011-12-20 12:59:09 +00:00
|
|
|
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list = FactoryGirl.create(:build_list_by_group_project)
|
2012-08-09 15:38:41 +01:00
|
|
|
@project = @build_list.project
|
2012-09-27 00:54:56 +01:00
|
|
|
@owner_group = @build_list.project.owner
|
|
|
|
@owner_user = @owner_group.owner
|
|
|
|
|
|
|
|
@member_group = FactoryGirl.create(:group)
|
|
|
|
@member_user = FactoryGirl.create(:user)
|
|
|
|
@member_group.actors.create :role => 'reader', :actor_id => @member_user.id, :actor_type => 'User'
|
2012-08-09 15:38:41 +01:00
|
|
|
@project.relations.create :role => 'reader', :actor_id => @member_group.id, :actor_type => 'Group'
|
2011-12-20 12:59:09 +00:00
|
|
|
|
2012-04-23 21:55:42 +01:00
|
|
|
@show_params = {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @build_list.id}
|
2011-12-20 12:59:09 +00:00
|
|
|
end
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2011-12-20 12:59:09 +00:00
|
|
|
context 'for all build lists' do
|
|
|
|
before(:each) do
|
2012-03-29 21:34:22 +01:00
|
|
|
@build_list1 = FactoryGirl.create(:build_list_core)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2012-08-09 15:38:41 +01:00
|
|
|
@build_list2 = FactoryGirl.create(:build_list_core)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list2.project.update_column(:visibility, 'hidden')
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2012-12-18 18:53:41 +00:00
|
|
|
project = FactoryGirl.create(:project_with_commit, :visibility => 'hidden', :owner => @user)
|
2012-12-26 14:02:56 +00:00
|
|
|
@build_list3 = create_build_list_with_project(:build_list_core, nil, project)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2012-08-09 15:38:41 +01:00
|
|
|
@build_list4 = FactoryGirl.create(:build_list_core)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list4.project.update_column(:visibility, 'hidden')
|
|
|
|
@build_list4.project.relations.create! :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
2011-12-20 12:59:09 +00:00
|
|
|
end
|
|
|
|
|
2011-12-21 01:30:34 +00:00
|
|
|
it 'should be able to perform index action' do
|
|
|
|
get :index
|
2011-12-20 12:59:09 +00:00
|
|
|
response.should be_success
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should show only accessible build_lists' do
|
2012-07-18 15:13:37 +01:00
|
|
|
get :index, :filter => {:ownership => 'everything'}
|
2011-12-20 12:59:09 +00:00
|
|
|
assigns(:build_lists).should include(@build_list1)
|
|
|
|
assigns(:build_lists).should_not include(@build_list2)
|
|
|
|
assigns(:build_lists).should include(@build_list3)
|
|
|
|
assigns(:build_lists).should include(@build_list4)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for open project' do
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-20 12:59:09 +00:00
|
|
|
|
|
|
|
context 'if user is group owner' do
|
|
|
|
before(:each) {set_session_for(@owner_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'create build list'
|
2011-12-20 12:59:09 +00:00
|
|
|
end
|
|
|
|
|
2011-12-23 18:47:13 +00:00
|
|
|
context 'if user is group read member' do
|
2011-12-20 12:59:09 +00:00
|
|
|
before(:each) {set_session_for(@member_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-20 12:59:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for hidden project' do
|
|
|
|
before(:each) do
|
|
|
|
@project.visibility = 'hidden'
|
|
|
|
@project.save
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'not show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-20 12:59:09 +00:00
|
|
|
|
|
|
|
context 'if user is group owner' do
|
|
|
|
before(:each) {set_session_for(@owner_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'create build list'
|
2011-12-20 12:59:09 +00:00
|
|
|
end
|
|
|
|
|
2011-12-23 18:47:13 +00:00
|
|
|
context 'if user is group read member' do
|
2011-12-20 12:59:09 +00:00
|
|
|
before(:each) {set_session_for(@member_user)}
|
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'not create build list'
|
2011-12-20 12:59:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-12-02 01:30:25 +00:00
|
|
|
context 'for admin' do
|
2012-03-29 21:34:22 +01:00
|
|
|
before(:each) { set_session_for FactoryGirl.create(:admin) }
|
2011-12-02 01:30:25 +00:00
|
|
|
|
2011-12-21 01:30:34 +00:00
|
|
|
it "should be able to perform index action without exception" do
|
2011-12-08 18:51:25 +00:00
|
|
|
any_instance_of(XMLRPC::Client) do |xml_rpc|
|
|
|
|
stub(xml_rpc).call do |args|
|
|
|
|
raise Timeout::Error
|
|
|
|
end
|
|
|
|
end
|
2011-12-21 01:30:34 +00:00
|
|
|
get :index
|
2011-12-08 18:51:25 +00:00
|
|
|
assigns[:build_server_status].should == {}
|
2011-12-02 01:30:25 +00:00
|
|
|
response.should be_success
|
2012-10-11 11:55:06 +01:00
|
|
|
end
|
2011-12-08 18:51:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'filter' do
|
2012-10-11 11:55:06 +01:00
|
|
|
|
|
|
|
before(:each) do
|
2012-03-29 21:34:22 +01:00
|
|
|
set_session_for FactoryGirl.create(:admin)
|
2011-12-20 12:59:09 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@build_list1 = FactoryGirl.create(:build_list_core)
|
|
|
|
@build_list2 = FactoryGirl.create(:build_list_core)
|
|
|
|
@build_list3 = FactoryGirl.create(:build_list_core)
|
2012-07-17 09:02:56 +01:00
|
|
|
@build_list4 = FactoryGirl.create(:build_list_core, :updated_at => (Time.now - 1.day),
|
2012-05-04 18:12:51 +01:00
|
|
|
:project => @build_list3.project, :save_to_platform => @build_list3.save_to_platform,
|
2011-12-20 12:59:09 +00:00
|
|
|
:arch => @build_list3.arch)
|
2011-12-13 16:37:57 +00:00
|
|
|
end
|
2011-12-08 18:51:25 +00:00
|
|
|
|
|
|
|
it 'should filter by bs_id' do
|
2011-12-21 01:30:34 +00:00
|
|
|
get :index, :filter => {:bs_id => @build_list1.bs_id, :project_name => 'fdsfdf', :any_other_field => 'do not matter'}
|
2011-12-20 12:59:09 +00:00
|
|
|
assigns[:build_lists].should include(@build_list1)
|
|
|
|
assigns[:build_lists].should_not include(@build_list2)
|
|
|
|
assigns[:build_lists].should_not include(@build_list3)
|
2011-12-08 18:51:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should filter by project_name' do
|
|
|
|
# Project.where(:id => build_list2.project.id).update_all(:name => 'project_name')
|
2012-07-18 15:13:37 +01:00
|
|
|
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'everything'}
|
2011-12-20 12:59:09 +00:00
|
|
|
assigns[:build_lists].should_not include(@build_list1)
|
|
|
|
assigns[:build_lists].should include(@build_list2)
|
|
|
|
assigns[:build_lists].should_not include(@build_list3)
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
2011-12-13 13:35:16 +00:00
|
|
|
|
2012-07-31 18:32:49 +01:00
|
|
|
it 'should filter by project_name and update_date' do
|
2012-07-18 15:13:37 +01:00
|
|
|
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'everything',
|
2012-07-31 18:32:49 +01:00
|
|
|
"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}
|
2011-12-20 12:59:09 +00:00
|
|
|
assigns[:build_lists].should_not include(@build_list1)
|
|
|
|
assigns[:build_lists].should_not include(@build_list2)
|
|
|
|
assigns[:build_lists].should include(@build_list3)
|
|
|
|
assigns[:build_lists].should_not include(@build_list4)
|
2011-12-13 13:35:16 +00:00
|
|
|
end
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'callbacks' do
|
2012-03-29 21:34:22 +01:00
|
|
|
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
2012-09-27 00:54:56 +01:00
|
|
|
let(:build_list_package) { FactoryGirl.create(:build_list_package, :build_list_id => build_list.id, :platform_id => build_list.save_to_platform_id, :project_id => build_list.project_id, :version => "4.7.5.3", :release => 1) }
|
2011-12-29 02:37:34 +00:00
|
|
|
|
2012-04-05 14:17:02 +01:00
|
|
|
before(:each) do
|
|
|
|
mock(controller).authenticate_build_service! {true}
|
|
|
|
end
|
|
|
|
|
2011-12-29 02:37:34 +00:00
|
|
|
describe 'publish_build' do
|
2012-06-18 17:19:09 +01:00
|
|
|
before {
|
2012-09-06 11:53:03 +01:00
|
|
|
build_list.update_column(:commit_hash, build_list.project.repo.commits('master').last.id)
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column(:status, BuildList::BUILD_PUBLISH)
|
2012-06-18 17:19:09 +01:00
|
|
|
build_list_package
|
|
|
|
}
|
2012-01-16 21:51:20 +00:00
|
|
|
|
2011-12-29 02:37:34 +00:00
|
|
|
def do_get(status)
|
2012-01-13 16:45:13 +00:00
|
|
|
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
2011-12-29 02:37:34 +00:00
|
|
|
build_list.reload
|
|
|
|
end
|
|
|
|
|
2012-06-15 17:05:55 +01:00
|
|
|
it(:passes) {
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
2012-06-15 11:14:32 +01:00
|
|
|
do_get(BuildServer::SUCCESS)
|
|
|
|
response.should be_ok
|
2012-06-15 17:05:55 +01:00
|
|
|
}
|
2012-06-18 17:19:09 +01:00
|
|
|
it 'should create correct git tag for correct commit' do
|
2012-01-17 17:37:41 +00:00
|
|
|
do_get(BuildServer::SUCCESS)
|
2012-07-17 09:02:56 +01:00
|
|
|
build_list.project.repo.tags.last.name.should == build_list.package_version
|
|
|
|
build_list.project.repo.commits(build_list.package_version).last.id.should == build_list.commit_hash
|
2012-01-17 17:37:41 +00:00
|
|
|
end
|
2012-06-18 17:19:09 +01:00
|
|
|
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
|
|
|
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to("#{ build_list_package.platform.name }-4.7.5.3-1") }
|
2011-12-29 02:37:34 +00:00
|
|
|
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
2012-01-13 16:45:13 +00:00
|
|
|
it { lambda{ do_get(BuildServer::ERROR) }.should_not change(build_list, :package_version) }
|
2012-04-13 21:49:29 +01:00
|
|
|
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) }
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'status_build' do
|
2012-05-14 20:08:31 +01:00
|
|
|
before do
|
|
|
|
@item = build_list.items.create(:name => build_list.project.name, :version => build_list.project_version, :level => 0)
|
|
|
|
repo = build_list.save_to_platform.repositories.first
|
|
|
|
@project2 = FactoryGirl.create(:project)
|
|
|
|
repo.projects << @project2
|
|
|
|
end
|
2011-12-29 02:37:34 +00:00
|
|
|
|
|
|
|
def do_get
|
2012-05-14 20:08:31 +01:00
|
|
|
get :status_build, :id => build_list.bs_id, :package_name => build_list.project.name, :status => BuildServer::SUCCESS, :container_path => '/path/to',
|
|
|
|
:pkg_info => ActiveSupport::JSON.encode({'srpm' => {'fullname' => 'srpm_filename.srpm',
|
|
|
|
'name' => build_list.project.name,
|
|
|
|
'version' => 'version1',
|
|
|
|
'release' => 'release1'},
|
|
|
|
'rpm' => [{'fullname' => 'filename1.rpm',
|
|
|
|
'name' => build_list.project.name,
|
|
|
|
'version' => 'version2',
|
|
|
|
'release' => 'release2'},
|
|
|
|
{'fullname' => 'filename2.rpm',
|
|
|
|
'name' => @project2.name,
|
|
|
|
'version' => 'version2',
|
|
|
|
'release' => 'release2'}]})
|
2011-12-29 02:37:34 +00:00
|
|
|
build_list.reload
|
|
|
|
@item.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { do_get; response.should be_ok }
|
|
|
|
it { lambda{ do_get }.should change(@item, :status) }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :container_path) }
|
2012-04-13 21:49:29 +01:00
|
|
|
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
2012-05-14 20:08:31 +01:00
|
|
|
it('should create packages for build list') { lambda{ do_get }.should change(build_list.packages, :count).to(3) }
|
2012-05-14 21:00:04 +01:00
|
|
|
it 'should create correct packages for build list' do
|
|
|
|
do_get
|
|
|
|
package = build_list.packages.order('created_at ASC').first
|
|
|
|
package.fullname.should == 'srpm_filename.srpm'
|
|
|
|
package.name.should == build_list.project.name
|
|
|
|
package.version.should == 'version1'
|
|
|
|
package.release.should == 'release1'
|
|
|
|
package.package_type == 'source'
|
|
|
|
package.build_list.should == build_list
|
|
|
|
package.platform.should == build_list.save_to_platform
|
|
|
|
package.project.should == build_list.project
|
|
|
|
end
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pre_build' do
|
2012-06-15 11:14:32 +01:00
|
|
|
before do
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column :status, BuildList::BUILD_PENDING
|
2012-06-15 11:14:32 +01:00
|
|
|
end
|
|
|
|
|
2011-12-29 02:37:34 +00:00
|
|
|
def do_get
|
|
|
|
get :pre_build, :id => build_list.bs_id
|
|
|
|
build_list.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { do_get; response.should be_ok }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :status).to(BuildServer::BUILD_STARTED) }
|
2012-04-13 21:49:29 +01:00
|
|
|
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'post_build' do
|
|
|
|
def do_get(status)
|
2012-04-13 21:49:29 +01:00
|
|
|
build_list.started_at = Time.now
|
|
|
|
build_list.save
|
2011-12-29 02:37:34 +00:00
|
|
|
get :post_build, :id => build_list.bs_id, :status => status, :container_path => '/path/to'
|
|
|
|
build_list.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
|
|
|
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :container_path) }
|
2012-04-13 21:49:29 +01:00
|
|
|
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :updated_at) }
|
2011-12-29 02:37:34 +00:00
|
|
|
|
|
|
|
context 'with auto_publish' do
|
2012-06-15 17:05:55 +01:00
|
|
|
it(:passes) {
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
|
|
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
2012-06-19 11:23:03 +01:00
|
|
|
build_list.reload
|
|
|
|
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH)
|
2012-06-15 17:05:55 +01:00
|
|
|
}
|
|
|
|
it(:passes) {
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
|
|
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
2012-06-15 17:05:55 +01:00
|
|
|
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
|
|
|
}
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'without auto_publish' do
|
2012-08-15 14:52:32 +01:00
|
|
|
before { build_list.update_column(:auto_publish, false) }
|
2011-12-29 02:37:34 +00:00
|
|
|
|
2012-06-15 17:05:55 +01:00
|
|
|
it(:passes) {
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
|
|
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
2012-06-15 17:05:55 +01:00
|
|
|
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS)
|
|
|
|
}
|
|
|
|
it(:passes) {
|
2012-08-15 14:52:32 +01:00
|
|
|
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
|
|
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
2012-06-15 17:05:55 +01:00
|
|
|
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
|
|
|
}
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'circle_build' do
|
|
|
|
def do_get
|
|
|
|
get :circle_build, :id => build_list.bs_id, :container_path => '/path/to'
|
|
|
|
build_list.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { do_get; response.should be_ok }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :is_circle).to(true) }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :container_path) }
|
2012-04-13 21:49:29 +01:00
|
|
|
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'new_bbdt' do
|
|
|
|
before { @items = build_list.items }
|
|
|
|
|
|
|
|
def do_get
|
|
|
|
get :new_bbdt, :id => 123, :web_id => build_list.id, :name => build_list.project.name, :is_circular => 1,
|
|
|
|
:additional_repos => ActiveSupport::JSON.encode([{:name => 'build_repos'}, {:name => 'main'}]),
|
|
|
|
:items => ActiveSupport::JSON.encode(0 => [{:name => build_list.project.name, :version => build_list.project_version}])
|
|
|
|
build_list.reload
|
|
|
|
@items.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { do_get; response.should be_ok }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :name).to(build_list.project.name) }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :additional_repos) }
|
|
|
|
it { lambda{ do_get }.should change(@items, :first) }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :is_circle).to(true) }
|
|
|
|
it { lambda{ do_get }.should change(build_list, :bs_id).to(123) }
|
2012-04-13 21:49:29 +01:00
|
|
|
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
2011-12-29 02:37:34 +00:00
|
|
|
end
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
2012-12-18 17:53:00 +00:00
|
|
|
after(:all) {clean_projects_dir}
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|