From 7368e5ed5f050ef1646a9db6853fedd684ade5d8 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 16 Sep 2008 10:35:31 +0200 Subject: [PATCH] make sure a new registered account is member of the current site --- spec/controllers/account_controller_spec.rb | 15 ++++++++------- .../app/controllers/account_controller.rb | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb index 327f3fba4..56dd9aadb 100644 --- a/spec/controllers/account_controller_spec.rb +++ b/spec/controllers/account_controller_spec.rb @@ -10,11 +10,11 @@ @account_path = '/account' @new_account_path = '/account/new' - @params = { :user => { :name => 'name', - :email => 'email@email.org', - :login => 'login', - :password => 'password', - :password_confirmation => 'password' } } + @params = { :user => { 'name' => 'name', + 'email' => 'email@email.org', + 'login' => 'login', + 'password' => 'password', + 'password_confirmation' => 'password' } } end describe "GET to :new" do @@ -27,6 +27,7 @@ before :each do @user.stub!(:new_record?).and_return true @user.stub!(:save).and_return true + @site.stub!(:save).and_return true AccountMailer.stub!(:deliver_signup_verification) end @@ -38,8 +39,8 @@ it_renders_template :verification_sent it "adds the new account to the site's accounts collection" do + @site.users.should_receive(:build).with(@params[:user]).and_return(@user) act! - assigns[:site].users.should include(assigns[:user]) end it "sends a validation email to the user" do @@ -50,7 +51,7 @@ describe "given invalid account params" do before :each do - @user.stub!(:save).and_return false + @site.stub!(:save).and_return false end it_renders_template :new diff --git a/vendor/engines/adva_user/app/controllers/account_controller.rb b/vendor/engines/adva_user/app/controllers/account_controller.rb index 1b0211997..e8d216258 100644 --- a/vendor/engines/adva_user/app/controllers/account_controller.rb +++ b/vendor/engines/adva_user/app/controllers/account_controller.rb @@ -15,7 +15,7 @@ def create @user = @site.users.build params[:user] if @user.deleted_at restore - elsif @user.new_record? and @user.save + elsif @user.new_record? and @site.save AccountMailer.deliver_signup_verification @user, verification_url(@user) render :action => 'verification_sent' else