diff --git a/app/controllers/collaborators_controller.rb b/app/controllers/collaborators_controller.rb index e7a42e304..ba9ecf53f 100644 --- a/app/controllers/collaborators_controller.rb +++ b/app/controllers/collaborators_controller.rb @@ -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 diff --git a/spec/controllers/collaborators_controller_spec.rb b/spec/controllers/collaborators_controller_spec.rb index 2e2b80ffc..f8a2d8819 100644 --- a/spec/controllers/collaborators_controller_spec.rb +++ b/spec/controllers/collaborators_controller_spec.rb @@ -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 diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index dba60a9ca..4567822d2 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -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