diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 0fe8bc0..a3e893f 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -51,6 +51,7 @@ class AccountController < ApplicationController @user.terms_of_use = environment.terms_of_use @user.environment = environment @terms_of_use = environment.terms_of_use + @user.person_data = params[:profile_data] @person = Person.new(params[:profile_data]) @person.name = @user.login @person.environment = @user.environment diff --git a/app/models/user.rb b/app/models/user.rb index 22b5177..0bf1999 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -29,10 +29,16 @@ class User < ActiveRecord::Base after_create do |user| user.person ||= Person.new + user.person.attributes = user.person_data user.person.name ||= user.login user.person.update_attributes(:identifier => user.login, :user_id => user.id, :environment_id => user.environment_id) end + attr_writer :person_data + def person_data + @person_data || {} + end + before_update do |user| if !User.find(user.id).enable_email and user.enable_email and !user.environment.nil? User::Mailer.deliver_activation_email_notify(user) diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 31af9f9..9f62216 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -635,6 +635,14 @@ class AccountControllerTest < Test::Unit::TestCase end end + should 'signup filling in mandatory person fields' do + Person.any_instance.stubs(:required_fields).returns(['organization_website']) + assert_difference User, :count do + post :signup, :user => { :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' }, :profile_data => { :organization_website => 'example.com' } + assert_redirected_to :controller => 'profile_editor', :profile => 'testuser' + end + end + protected def new_user(options = {}, extra_options ={}) data = {:profile_data => person_data} -- libgit2 0.21.2