[refs #2249] Fix collaborators controller. Fix projects specs.

This commit is contained in:
konstantin.grabar 2011-12-07 13:46:48 +04:00
parent 6794ca42fb
commit 0f827f2644
3 changed files with 8 additions and 11 deletions

View File

@ -30,10 +30,10 @@ class CollaboratorsController < ApplicationController
def update def update
all_user_ids = [] all_user_ids = []
all_groups_ids = [] all_groups_ids = []
puts params.inspect
Relation::ROLES.each { |r| Relation::ROLES.each { |r|
all_user_ids = all_user_ids | params['user'][r.to_sym].keys if params['user'][r.to_sym] all_user_ids = all_user_ids | params['user'][r.to_sym].keys if params['user'] && params['user'][r.to_sym]
all_groups_ids = all_groups_ids | params['group'][r.to_sym].keys if params['group'][r.to_sym] all_groups_ids = all_groups_ids | params['group'][r.to_sym].keys if params['group'] && params['group'][r.to_sym]
} }
# Remove relations # Remove relations
@ -58,21 +58,17 @@ class CollaboratorsController < ApplicationController
relation.update_attribute(:role, r) relation.update_attribute(:role, r)
else else
relation = @project.relations.build(:object_id => u, :object_type => 'User', :role => r) relation = @project.relations.build(:object_id => u, :object_type => 'User', :role => r)
puts relation.inspect
puts r
relation.save! relation.save!
end end
} if params['user'][r.to_sym] } if params['user'] && params['user'][r.to_sym]
params['group'][r.to_sym].keys.each { |u| params['group'][r.to_sym].keys.each { |u|
if relation = @project.relations.find_by_object_id_and_object_type(u, 'Group') if relation = @project.relations.find_by_object_id_and_object_type(u, 'Group')
relation.update_attribute(:role, r) relation.update_attribute(:role, r)
else else
relation = @project.relations.build(:object_id => u, :object_type => 'Group', :role => r) relation = @project.relations.build(:object_id => u, :object_type => 'Group', :role => r)
puts relation.inspect
puts r
relation.save! relation.save!
end end
} if params['group'][r.to_sym] } if params['group'] && params['group'][r.to_sym]
} }
if @project.save if @project.save

View File

@ -5,7 +5,7 @@ describe CollaboratorsController do
before(:each) do before(:each) do
@project = Factory(:project) @project = Factory(:project)
@another_user = Factory(:user) @another_user = Factory(:user)
@update_params = {:read => {@another_user.id => '1'}} @update_params = {:user => {:read => {@another_user.id => '1'}}}
end end
context 'for guest' do context 'for guest' do

View File

@ -9,7 +9,6 @@ describe ProjectsController do
@update_params = {:project => {:name => 'pro2'}} @update_params = {:project => {:name => 'pro2'}}
platform = Factory(:platform) platform = Factory(:platform)
any_instance_of(Project, :collected_project_versions => ['v1.0', 'v2.0'])
@process_build_params = {:build => { @process_build_params = {:build => {
:arches => {Factory(:arch).id => '1'}, :arches => {Factory(:arch).id => '1'},
:project_version => 'v1.0', :project_version => 'v1.0',
@ -17,6 +16,8 @@ describe ProjectsController do
:pl => platform.id, :pl => platform.id,
:update_type => 'security' :update_type => 'security'
}} }}
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
end end
context 'for guest' do context 'for guest' do