[fixed #16] Changed owner fetching in PlatformsController#create
This commit is contained in:
parent
5e3711505c
commit
b9c0f1e3d9
|
@ -52,7 +52,8 @@ class PlatformsController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@platform = Platform.new params[:platform]
|
@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!
|
if @platform.save!
|
||||||
@platform.make_admin_relation(params[:admin_id])
|
@platform.make_admin_relation(params[:admin_id])
|
||||||
|
|
|
@ -38,7 +38,13 @@ describe PlatformsController do
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = Factory(:admin)
|
||||||
|
@user = Factory(:user)
|
||||||
set_session_for(@admin)
|
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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'able_to_perform_index#platforms'
|
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 'be_able_to_perform_destroy#platforms'
|
||||||
it_should_behave_like 'change_objects_count_on_destroy_success'
|
it_should_behave_like 'change_objects_count_on_destroy_success'
|
||||||
it_should_behave_like 'not_be_able_to_destroy_personal_platform'
|
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
|
end
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
|
|
Loading…
Reference in New Issue