Improve CreateContext call. Fixed test

This commit is contained in:
Dmitriy Zaporozhets 2013-01-18 20:21:13 +02:00
parent 232d61d598
commit 6f05ea4f6e
5 changed files with 47 additions and 35 deletions

View file

@ -1,10 +1,14 @@
module Projects
class CreateContext < BaseContext
def initialize(user, params)
@current_user, @params = user, params.dup
end
def execute
# get namespace id
namespace_id = params[:project].delete(:namespace_id)
namespace_id = params.delete(:namespace_id)
@project = Project.new(params[:project])
@project = Project.new(params)
# Parametrize path for project
#
@ -25,7 +29,7 @@ module Projects
end
else
# Set current user namespace if namespace_id is nil
@project.namespace_id = current_user.id
@project.namespace_id = current_user.namespace_id
end
Project.transaction do

View file

@ -19,7 +19,7 @@ class ProjectsController < ProjectResourceController
end
def create
@project = Projects::CreateContext.new(nil, current_user, params).execute
@project = Projects::CreateContext.new(current_user, params).execute
respond_to do |format|
flash[:notice] = 'Project was successfully created.' if @project.saved?