Skip to content

Commit

Permalink
A couple specs for create overwriting users
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael committed Oct 28, 2010
1 parent 314b5d1 commit 4aaa921
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/models/user_spec.rb
Expand Up @@ -14,6 +14,30 @@
user.encryption_key.should_not be nil
end

describe 'overwriting people' do
it 'does not overwrite old users with factory' do
new_user = Factory.create(:user, :id => user.id)
new_user.persisted?.should be_true
new_user.id.should_not == user.id
end
it 'does not overwrite old users with create' do
params = {:username => "ohai",
:email => "ohai@example.com",
:password => "password",
:password_confirmation => "password",
:person =>
{:profile =>
{:first_name => "O",
:last_name => "Hai"}
}
}
params[:id] = user.id
new_user = User.build(params)
new_user.save
new_user.persisted?.should be_true
new_user.id.should_not == user.id
end
end
describe "validation" do
describe "of associated person" do
it "fails if person is not valid" do
Expand Down

0 comments on commit 4aaa921

Please sign in to comment.