Fix and redo specs after great build_lists refactoring and improvement. Fix minor bugs. Code cleanup. Refs #65
This commit is contained in:
parent
96d458875e
commit
8c3291d237
|
@ -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
|
||||
|
|
|
@ -26,7 +26,48 @@ describe BuildListsController do
|
|||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
|
@ -139,11 +139,18 @@ 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, :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
|
||||
end
|
||||
|
||||
context 'with admin rights' do
|
||||
|
@ -151,12 +158,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
|
||||
|
@ -167,11 +181,18 @@ describe CanCan do
|
|||
@project.update_attribute(:owner, @user)
|
||||
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
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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