[fixed #16] Changed owner fetching in PlatformsController#create

This commit is contained in:
George Vinogradov 2011-12-11 20:00:50 +04:00
parent 5e3711505c
commit b9c0f1e3d9
2 changed files with 18 additions and 1 deletions

View File

@ -52,7 +52,8 @@ class PlatformsController < ApplicationController
def create
@platform = Platform.new params[:platform]
@platform.owner = get_owner
@platform.owner = (params[:admin_id]) ? User.find_by_uname(params[:admin_id]) : nil
@platform.owner ||= get_owner
if @platform.save!
@platform.make_admin_relation(params[:admin_id])

View File

@ -38,7 +38,13 @@ describe PlatformsController do
context 'for global admin' do
before(:each) do
@admin = Factory(:admin)
@user = Factory(:user)
set_session_for(@admin)
any_instance_of(Platform) do |plat|
stub(plat).mount_directory_for_rsync {|args| true}
stub(plat).umount_directory_for_rsync {|args| true}
end
# any_instance_of(Platform).umount_directory_for_rsync{true}
end
it_should_behave_like 'able_to_perform_index#platforms'
@ -60,6 +66,16 @@ describe PlatformsController do
it_should_behave_like 'be_able_to_perform_destroy#platforms'
it_should_behave_like 'change_objects_count_on_destroy_success'
it_should_behave_like 'not_be_able_to_destroy_personal_platform'
context 'when owner uname present' do
it 'should create platform with mentioned owner' do
post :create, @create_params.merge({:admin_id => @user.uname})
Platform.last.owner.id.should eql(@user.id)
end
end
end
context 'for owner user' do