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
|
2014-03-19 07:19:03 +00:00
|
|
|
get :index, name_with_owner: @project.name_with_owner
|
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
|
2014-03-19 07:19:03 +00:00
|
|
|
get :index, name_with_owner: @project.name_with_owner
|
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
|
2014-03-19 07:19:03 +00:00
|
|
|
get :new, name_with_owner: @project.name_with_owner
|
2011-12-23 02:14:28 +00:00
|
|
|
response.should render_template(:new)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be able to perform create action' do
|
2014-03-19 07:19:03 +00:00
|
|
|
post :create, { name_with_owner: @project.name_with_owner }.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
|
2014-03-19 07:19:03 +00:00
|
|
|
post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "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
|
2014-03-19 07:19:03 +00:00
|
|
|
post :create, { name_with_owner: @project.name_with_owner }.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
|
2014-03-19 07:19:03 +00:00
|
|
|
lambda{ post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "wrong", commit_hash: nil })}.should change{ @project.build_lists.count }.by(0)
|
2012-10-11 11:55:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not be able to create with wrong git hash' do
|
2014-03-19 07:19:03 +00:00
|
|
|
lambda{ post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { commit_hash: 'wrong' }) }.should change{ @project.build_lists.count }.by(0)
|
2012-10-11 11:55:06 +01:00
|
|
|
end
|
2011-12-23 02:14:28 +00:00
|
|
|
end
|
|
|
|
|
2013-07-04 20:55:56 +01:00
|
|
|
shared_examples_for 'not create build list' do |skip_new = false|
|
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
|
2014-03-19 07:19:03 +00:00
|
|
|
get :new, name_with_owner: @project.name_with_owner
|
2011-12-23 02:14:28 +00:00
|
|
|
response.should redirect_to(forbidden_url)
|
2013-07-04 20:55:56 +01:00
|
|
|
end unless skip_new
|
2011-12-23 02:14:28 +00:00
|
|
|
|
|
|
|
it 'should not be able to perform create action' do
|
2014-03-19 07:19:03 +00:00
|
|
|
post :create, { name_with_owner: @project.name_with_owner }.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
|
|
|
|
2014-05-28 22:53:50 +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
|
2014-05-22 19:08:43 +01:00
|
|
|
before 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 = {
|
2014-01-21 04:51:49 +00:00
|
|
|
build_list: {
|
|
|
|
project_version: 'master',
|
|
|
|
save_to_repository_id: @platform.repositories.first.id,
|
|
|
|
update_type: 'security',
|
|
|
|
include_repos: [@platform.repositories.first.id]
|
2011-12-23 02:14:28 +00:00
|
|
|
},
|
2014-01-21 04:51:49 +00:00
|
|
|
arches: [FactoryGirl.create(:arch).id],
|
|
|
|
build_for_platforms: [@platform.id]
|
2011-12-23 02:14:28 +00:00
|
|
|
}
|
2014-01-21 04:51:49 +00:00
|
|
|
any_instance_of(Project, versions: ['v1.0', 'v2.0'])
|
2011-12-23 02:14:28 +00:00
|
|
|
end
|
|
|
|
|
2011-12-02 01:30:25 +00:00
|
|
|
context 'for guest' do
|
2014-01-21 04:51:49 +00:00
|
|
|
it 'should be able to perform index action', anonymous_access: true do
|
2012-09-27 00:54:56 +01:00
|
|
|
get :index
|
|
|
|
response.should be_success
|
|
|
|
end
|
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
it 'should not be able to perform index action', anonymous_access: false do
|
2012-09-27 00:54:56 +01:00
|
|
|
get :index
|
|
|
|
response.should redirect_to(new_user_session_path)
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
2013-02-25 18:34:45 +00:00
|
|
|
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'for user' do
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2014-01-21 04:51:49 +00:00
|
|
|
any_instance_of(BuildList, current_duration: 100)
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list = FactoryGirl.create(:build_list)
|
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)
|
2014-03-18 09:31:01 +00:00
|
|
|
create_relation(@project, @member_user, 'reader')
|
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@user = FactoryGirl.create(:user)
|
2011-12-14 21:04:39 +00:00
|
|
|
set_session_for(@user)
|
2014-03-19 07:19:03 +00:00
|
|
|
@show_params = { name_with_owner: @project.name_with_owner, id: @build_list.id }
|
2013-06-09 12:44:10 +01:00
|
|
|
@build_list.save_to_repository.update_column(:publish_without_qa, false)
|
|
|
|
@request.env['HTTP_REFERER'] = build_list_path(@build_list)
|
|
|
|
end
|
|
|
|
|
2014-05-22 19:08:43 +01:00
|
|
|
context 'do rerun_tests' do
|
|
|
|
def do_rerun_tests
|
|
|
|
put :rerun_tests, id: @build_list
|
|
|
|
end
|
|
|
|
|
2014-05-28 22:53:50 +01:00
|
|
|
before do
|
|
|
|
allow_any_instance_of(BuildList).to receive(:can_rerun_tests?).and_return(true)
|
|
|
|
end
|
|
|
|
|
2014-05-22 19:08:43 +01:00
|
|
|
context 'if user is project owner' do
|
|
|
|
before { set_session_for(@owner_user) }
|
|
|
|
|
|
|
|
it 'reruns tests' do
|
|
|
|
expect_any_instance_of(BuildList).to receive(:rerun_tests).and_return(true)
|
|
|
|
do_rerun_tests
|
|
|
|
|
|
|
|
expect(response).to redirect_to(build_list_path(@build_list))
|
|
|
|
expect(flash[:notice]).to match I18n.t('layout.build_lists.rerun_tests_success')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns an error if the can not rerun_tests' do
|
|
|
|
allow_any_instance_of(BuildList).to receive(:rerun_tests).and_return(false)
|
|
|
|
do_rerun_tests
|
|
|
|
|
|
|
|
expect(response).to redirect_to(build_list_path(@build_list))
|
|
|
|
expect(flash[:error]).to match I18n.t('layout.build_lists.rerun_tests_fail')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns an error if user is not project owner' do
|
|
|
|
expect_any_instance_of(BuildList).to_not receive(:rerun_tests)
|
|
|
|
do_rerun_tests
|
|
|
|
expect(response).to redirect_to(forbidden_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns an error if user is project reader' do
|
|
|
|
@another_user = FactoryGirl.create(:user)
|
|
|
|
@build_list.project.collaborators.create(actor_type: 'User', actor_id: @another_user.id, role: 'reader')
|
|
|
|
set_session_for(@another_user)
|
|
|
|
|
|
|
|
expect_any_instance_of(BuildList).to_not receive(:rerun_tests)
|
|
|
|
do_rerun_tests
|
|
|
|
expect(response).to redirect_to(forbidden_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reruns tests if user is project writer' do
|
|
|
|
@writer_user = FactoryGirl.create(:user)
|
|
|
|
create_relation(@build_list.project, @writer_user, 'writer')
|
|
|
|
set_session_for(@writer_user)
|
|
|
|
|
|
|
|
expect_any_instance_of(BuildList).to receive(:rerun_tests).and_return(true)
|
|
|
|
do_rerun_tests
|
|
|
|
expect(response).to redirect_to(build_list_path(@build_list))
|
|
|
|
expect(flash[:notice]).to match I18n.t('layout.build_lists.rerun_tests_success')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-06-09 12:44:10 +01:00
|
|
|
context "do reject_publish" do
|
2014-05-22 19:08:43 +01:00
|
|
|
before {@build_list.save_to_repository.update_column(:publish_without_qa, true)}
|
2013-06-09 12:44:10 +01:00
|
|
|
|
|
|
|
def do_reject_publish
|
2014-01-21 04:51:49 +00:00
|
|
|
put :reject_publish, id: @build_list
|
2013-06-09 12:44:10 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'if user is project owner' do
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-06-09 12:44:10 +01:00
|
|
|
set_session_for(@owner_user)
|
|
|
|
@build_list.update_column(:status, BuildList::SUCCESS)
|
|
|
|
@build_list.save_to_platform.update_column(:released, true)
|
|
|
|
do_reject_publish
|
|
|
|
end
|
|
|
|
|
|
|
|
context "if it has :success status" do
|
|
|
|
it 'should return 302 response code' do
|
|
|
|
response.status.should == 302
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should reject publish build list" do
|
|
|
|
@build_list.reload.status.should == BuildList::REJECTED_PUBLISH
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "if it has another status" do
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-06-09 12:44:10 +01:00
|
|
|
@build_list.update_column(:status, BuildList::BUILD_ERROR)
|
|
|
|
do_reject_publish
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not change status of build list" do
|
|
|
|
@build_list.reload.status.should == BuildList::BUILD_ERROR
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'if user is not project owner' do
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-06-09 12:44:10 +01:00
|
|
|
@build_list.update_column(:status, BuildList::SUCCESS)
|
|
|
|
@build_list.save_to_platform.update_column(:released, true)
|
|
|
|
do_reject_publish
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should redirect to forbidden page" do
|
|
|
|
response.should redirect_to(forbidden_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not change status of build list" do
|
|
|
|
do_reject_publish
|
|
|
|
@build_list.reload.status.should == BuildList::SUCCESS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'if user is project reader' do
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-06-09 12:44:10 +01:00
|
|
|
@another_user = FactoryGirl.create(:user)
|
|
|
|
@build_list.update_column(:status, BuildList::SUCCESS)
|
|
|
|
@build_list.save_to_repository.update_column(:publish_without_qa, true)
|
2014-01-21 04:51:49 +00:00
|
|
|
@build_list.project.collaborators.create(actor_type: 'User', actor_id: @another_user.id, role: 'reader')
|
2013-06-09 12:44:10 +01:00
|
|
|
set_session_for(@another_user)
|
|
|
|
do_reject_publish
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should redirect to forbidden page" do
|
|
|
|
response.should redirect_to(forbidden_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not change status of build list" do
|
|
|
|
do_reject_publish
|
|
|
|
@build_list.reload.status.should == BuildList::SUCCESS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'if user is project writer' do
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-06-09 12:44:10 +01:00
|
|
|
@writer_user = FactoryGirl.create(:user)
|
|
|
|
@build_list.update_column(:status, BuildList::SUCCESS)
|
|
|
|
@build_list.save_to_repository.update_column(:publish_without_qa, true)
|
2014-03-18 09:31:01 +00:00
|
|
|
create_relation(@build_list.project, @writer_user, 'writer')
|
2013-06-09 12:44:10 +01:00
|
|
|
set_session_for(@writer_user)
|
|
|
|
do_reject_publish
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return 302 response code' do
|
|
|
|
response.status.should == 302
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should reject publish build list" do
|
|
|
|
@build_list.reload.status.should == BuildList::REJECTED_PUBLISH
|
|
|
|
end
|
|
|
|
end
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list1 = FactoryGirl.create(:build_list)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list2 = FactoryGirl.create(:build_list)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list2.project.update_column(:visibility, 'hidden')
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
project = FactoryGirl.create(:project_with_commit, visibility: 'hidden', owner: @user)
|
|
|
|
@build_list3 = FactoryGirl.create(:build_list_with_attaching_project, project: project)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list4 = FactoryGirl.create(:build_list)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list4.project.update_column(:visibility, 'hidden')
|
2014-03-18 09:31:01 +00:00
|
|
|
create_relation(@build_list4.project, @user, 'reader')
|
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
|
2014-01-21 04:51:49 +00: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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@owner_user)}
|
2011-12-14 21:30:15 +00:00
|
|
|
it_should_behave_like 'show build list'
|
2011-12-23 02:14:28 +00:00
|
|
|
it_should_behave_like 'create build list'
|
2013-02-25 18:34:45 +00:00
|
|
|
|
2013-07-04 20:55:56 +01:00
|
|
|
context 'no ability to read build_for_platform' do
|
|
|
|
before do
|
|
|
|
repository = FactoryGirl.create(:repository)
|
|
|
|
repository.platform.change_visibility
|
2014-01-21 04:51:49 +00:00
|
|
|
Platform.where(id: @platform.id).update_all(platform_type: 'personal')
|
|
|
|
@create_params[:build_list].merge!({include_repos: [repository.id]})
|
2013-07-04 20:55:56 +01:00
|
|
|
@create_params[:build_for_platforms] = [repository.platform_id]
|
|
|
|
end
|
|
|
|
it_should_behave_like 'not create build list', true
|
|
|
|
end
|
|
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@member_user)}
|
2011-12-14 21:30:15 +00:00
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2011-12-14 21:30:15 +00:00
|
|
|
@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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@owner_user)}
|
2011-12-14 21:30:15 +00:00
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@member_user)}
|
2011-12-14 21:30:15 +00:00
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2011-12-20 12:59:09 +00:00
|
|
|
|
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)
|
2014-03-18 09:31:01 +00:00
|
|
|
create_actor_relation(@member_group, @member_user, 'reader')
|
|
|
|
create_relation(@project, @member_group, 'reader')
|
2011-12-20 12:59:09 +00:00
|
|
|
|
2014-03-19 07:19:03 +00:00
|
|
|
@show_params = { name_with_owner: @project.name_with_owner, 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
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list1 = FactoryGirl.create(:build_list)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list2 = FactoryGirl.create(:build_list)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list2.project.update_column(:visibility, 'hidden')
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
project = FactoryGirl.create(:project_with_commit, visibility: 'hidden', owner: @user)
|
|
|
|
@build_list3 = FactoryGirl.create(:build_list_with_attaching_project, project: project)
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list4 = FactoryGirl.create(:build_list)
|
2012-09-27 00:54:56 +01:00
|
|
|
@build_list4.project.update_column(:visibility, 'hidden')
|
2014-03-18 09:31:01 +00:00
|
|
|
create_relation(@build_list4.project, @user, 'reader')
|
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
|
2014-01-21 04:51:49 +00: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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@owner_user)}
|
2011-12-20 12:59:09 +00:00
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@member_user)}
|
2011-12-20 12:59:09 +00:00
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2011-12-20 12:59:09 +00:00
|
|
|
@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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@owner_user)}
|
2011-12-20 12:59:09 +00:00
|
|
|
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
|
2014-05-22 19:08:43 +01:00
|
|
|
before {set_session_for(@member_user)}
|
2011-12-20 12:59:09 +00:00
|
|
|
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
|
2013-01-21 17:16:06 +00:00
|
|
|
end
|
2011-12-20 12:59:09 +00:00
|
|
|
|
2011-12-08 18:51:25 +00:00
|
|
|
context 'filter' do
|
2012-10-11 11:55:06 +01:00
|
|
|
|
2014-05-22 19:08:43 +01:00
|
|
|
before do
|
2012-03-29 21:34:22 +01:00
|
|
|
set_session_for FactoryGirl.create(:admin)
|
2011-12-20 12:59:09 +00:00
|
|
|
|
2013-07-01 13:20:38 +01:00
|
|
|
@build_list1 = FactoryGirl.create(:build_list)
|
|
|
|
@build_list2 = FactoryGirl.create(:build_list)
|
|
|
|
@build_list3 = FactoryGirl.create(:build_list)
|
2014-01-21 04:51:49 +00:00
|
|
|
@build_list4 = FactoryGirl.create(:build_list, updated_at: (Time.now - 1.day),
|
|
|
|
project: @build_list3.project, save_to_platform: @build_list3.save_to_platform,
|
|
|
|
arch: @build_list3.arch)
|
2011-12-13 16:37:57 +00:00
|
|
|
end
|
2011-12-08 18:51:25 +00:00
|
|
|
|
2013-07-01 13:20:38 +01:00
|
|
|
it 'should filter by id' do
|
2014-01-21 04:51:49 +00:00
|
|
|
get :index, filter: {id: @build_list1.id, project_name: 'fdsfdf', any_other_field: 'do not matter'}, format: :json
|
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
|
2014-01-21 04:51:49 +00:00
|
|
|
# Project.where(id: build_list2.project.id).update_all(name: 'project_name')
|
|
|
|
get :index, filter: {project_name: @build_list2.project.name, ownership: 'everything'}, format: :json
|
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
|
2014-01-21 04:51:49 +00:00
|
|
|
get :index, filter: {project_name: @build_list3.project.name, ownership: 'everything',
|
|
|
|
"updated_at_start" => @build_list3.updated_at.strftime('%d/%m/%Y')}, format: :json
|
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
|
|
|
|
|
2012-12-18 17:53:00 +00:00
|
|
|
after(:all) {clean_projects_dir}
|
2011-12-02 01:30:25 +00:00
|
|
|
end
|