diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 97cf7a97f..dc9fe0bbb 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -52,10 +52,11 @@ class PlatformsController < ApplicationController def create @platform = Platform.new params[:platform] - @platform.owner = get_owner + @platform.owner = (params[:admin_uname]) ? User.find_by_uname(params[:admin_uname]) : nil + @platform.owner ||= get_owner if @platform.save! - @platform.make_admin_relation(params[:admin_id]) +# @platform.make_admin_relation(@platform.owner.id) flash[:notice] = I18n.t("flash.platform.saved") redirect_to @platform else diff --git a/app/views/platforms/_form.html.haml b/app/views/platforms/_form.html.haml index d1684ee25..00b9e65a1 100644 --- a/app/views/platforms/_form.html.haml +++ b/app/views/platforms/_form.html.haml @@ -21,8 +21,8 @@ = f.check_box :released, :class => 'check_box' .group - = label_tag "", t("layout.platforms.admin_id"), :class => :label - = autocomplete_field_tag 'admin_id', params[:admin_id], autocomplete_user_uname_platforms_path + = label_tag "admin_uname", t("layout.platforms.admin_uname"), :class => :label + = autocomplete_field_tag 'admin_uname', params[:admin_uname], autocomplete_user_uname_platforms_path =# text_field_tag 'admin_id', '', :id => 'admin_id_field' .group.navform.wat-cf diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 943cfb82a..41e02c199 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -94,7 +94,7 @@ ru: confirm_delete: Вы уверены, что хотите удалить эту категорию? platforms: - admin_id: Владелец + admin_uname: Владелец build_all: Собрать все list: Список new: Создать diff --git a/spec/controllers/platforms_controller_spec.rb b/spec/controllers/platforms_controller_spec.rb index 935f0298a..c0ac1fb15 100644 --- a/spec/controllers/platforms_controller_spec.rb +++ b/spec/controllers/platforms_controller_spec.rb @@ -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_uname => @user.uname}) + Platform.last.owner.id.should eql(@user.id) + end + + end + end context 'for owner user' do