Skip to content

Commit

Permalink
make sure a new registered account is member of the current site
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Sep 16, 2008
1 parent de09fbf commit 7368e5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions spec/controllers/account_controller_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 7368e5e

Please sign in to comment.