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

View File

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

View File

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