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'
|
one :profile, :class_name => 'Profile'
|
||||||
validates_associated :profile
|
validates_associated :profile
|
||||||
|
delegate :first_name, :last_name, :to => :profile
|
||||||
before_save :downcase_diaspora_handle
|
before_save :downcase_diaspora_handle
|
||||||
|
|
||||||
def downcase_diaspora_handle
|
def downcase_diaspora_handle
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,20 @@ describe Person do
|
||||||
@aspect2 = @user2.aspects.create(:name => "Abscence of Babes")
|
@aspect2 = @user2.aspects.create(:name => "Abscence of Babes")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "vaild url" do
|
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
|
it 'should allow for https urls' do
|
||||||
person = Factory.create(:person, :url => "https://example.com")
|
person = Factory.create(:person, :url => "https://example.com")
|
||||||
person.valid?.should == true
|
person.valid?.should == true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue