show new profile pages for those who have it activated

This commit is contained in:
danielgrippi 2012-04-28 16:06:36 -07:00
parent bbd4ee5738
commit c3b0bbd425
5 changed files with 39 additions and 14 deletions

View file

@ -24,10 +24,13 @@ app.pages.Profile = app.views.Base.extend({
presenter : function(){ presenter : function(){
var bio = this.model.get("bio") || '' var bio = this.model.get("bio") || ''
console.log(this.defaultPresenter().current_user)
return _.extend(this.defaultPresenter(), return _.extend(this.defaultPresenter(),
{text : this.model && app.helpers.textFormatter(bio, this.model), {text : this.model && app.helpers.textFormatter(bio, this.model),
isOwnProfile : this.isOwnProfile(), isOwnProfile : this.isOwnProfile(),
showFollowButton : this.showFollowButton() }) showFollowButton : this.showFollowButton()
})
}, },
initialize : function(options) { initialize : function(options) {
@ -55,7 +58,8 @@ app.pages.Profile = app.views.Base.extend({
}, },
followingEnabled : function() { followingEnabled : function() {
return app.currentUser.get("following_count") != 0 var user = app.currentUser
return user.get("following_count") != 0 && user.get("diaspora_id") !== undefined
}, },
showFollowButton : function() { showFollowButton : function() {

View file

@ -10,14 +10,24 @@
</a> </a>
{{/if}} {{/if}}
<a href="/" id="home-button"> {{#if current_user.guid}}
<span class="label label-inverse"> <a href="/" id="home-button">
<i class="icon-home icon-white"></i> <span class="label label-inverse">
<span> <i class="icon-home icon-white"></i>
HOME <span>
HOME
</span>
</span> </span>
</span> </a>
</a> {{else}}
<a href="/" id="home-button">
<span class="label label-inverse">
<span>
DIASPORA
</span>
</span>
</a>
{{/if}}
{{#if isOwnProfile}} {{#if isOwnProfile}}
<a href="/users/sign_out" title="Log out" id="logout-button"> <a href="/users/sign_out" title="Log out" id="logout-button">

View file

@ -81,7 +81,7 @@ class PeopleController < ApplicationController
def show def show
@person = Person.find_from_guid_or_username(params) @person = Person.find_from_guid_or_username(params)
flag = FeatureFlagger.new(current_user) flag = FeatureFlagger.new(current_user, @person)
logger.info(request.format) logger.info(request.format)
raise(ActiveRecord::RecordNotFound) if remote_profile_with_no_user_session? raise(ActiveRecord::RecordNotFound) if remote_profile_with_no_user_session?

View file

@ -1,6 +1,7 @@
class FeatureFlagger class FeatureFlagger
def initialize(current_user) def initialize(current_user, person=nil)
@current_user = current_user @current_user = current_user
@person = person
end end
def new_publisher? def new_publisher?
@ -8,7 +9,7 @@ class FeatureFlagger
end end
def new_profile? def new_profile?
admin? person_is_beta?
end end
def new_hotness? def new_hotness?
@ -25,4 +26,9 @@ class FeatureFlagger
@current_user.try(:admin?) @current_user.try(:admin?)
end end
def person_is_beta?
return unless @person.present?
Role.is_beta?(@person) || Role.is_admin?(@person)
end
end end

View file

@ -127,12 +127,17 @@ describe("app.pages.Profile", function(){
describe("followingEnabled", function(){ describe("followingEnabled", function(){
/* for legacy beta testers */ /* for legacy beta testers */
it("returns false if following_count is zero", function(){ it("returns false if following_count is zero", function(){
app.currentUser.set({following_count : 0}) loginAs({following_count : 0})
expect(this.page.followingEnabled()).toBeFalsy()
})
it("returns false if the user is not signed in", function(){
logout()
expect(this.page.followingEnabled()).toBeFalsy() expect(this.page.followingEnabled()).toBeFalsy()
}) })
it("returns false if following_count is zero", function(){ it("returns false if following_count is zero", function(){
app.currentUser.set({following_count : 1}) loginAs({following_count : 1})
expect(this.page.followingEnabled()).toBeTruthy() expect(this.page.followingEnabled()).toBeTruthy()
}) })
}) })