diff --git a/app/models/profile.rb b/app/models/profile.rb index 573dcb6f3..82413ccd2 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -40,6 +40,10 @@ class Profile < ActiveRecord::Base Person.joins(:contacts).where(contacts: {user_id: person.owner_id}) end + def public? + public_details? + end + def diaspora_handle #get the parent diaspora handle, unless we want to access a profile without a person (self.person) ? self.person.diaspora_handle : self[:diaspora_handle] diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 85c630bfe..4d245f7fd 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -185,6 +185,18 @@ describe Profile, :type => :model do end end + describe "public?" do + it "is public if public_details is true" do + profile = FactoryGirl.build(:profile, public_details: true) + expect(profile.public?).to be_truthy + end + + it "is not public if public_details is false" do + profile = FactoryGirl.build(:profile, public_details: false) + expect(profile.public?).to be_falsey + end + end + describe 'date=' do let(:profile) { FactoryGirl.build(:profile) }