Person delegates first_name and last_name to profile.
This commit is contained in:
parent
15d6cff837
commit
dc97c852f4
2 changed files with 15 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ class Person
|
|||
|
||||
one :profile, :class_name => 'Profile'
|
||||
validates_associated :profile
|
||||
delegate :first_name, :last_name, :to => :profile
|
||||
before_save :downcase_diaspora_handle
|
||||
|
||||
def downcase_diaspora_handle
|
||||
|
|
|
|||
|
|
@ -13,6 +13,19 @@ describe Person do
|
|||
@aspect2 = @user2.aspects.create(:name => "Abscence of Babes")
|
||||
end
|
||||
|
||||
describe "delegating" do
|
||||
it "delegates first_name to the profile" do
|
||||
@person.first_name.should == @person.profile.first_name
|
||||
@person.profile.update_attributes(:first_name => "Jane")
|
||||
@person.reload.first_name.should == "Jane"
|
||||
end
|
||||
it "delegates last_name to the profile" do
|
||||
@person.last_name.should == @person.profile.last_name
|
||||
@person.profile.update_attributes(:last_name => "Heathers")
|
||||
@person.reload.last_name.should == "Heathers"
|
||||
end
|
||||
end
|
||||
|
||||
describe "vaild url" do
|
||||
it 'should allow for https urls' do
|
||||
person = Factory.create(:person, :url => "https://example.com")
|
||||
|
|
|
|||
Loading…
Reference in a new issue