fixed up stream/publisher logic; fixed cukes
This commit is contained in:
parent
59e4955727
commit
e63e8299b9
22 changed files with 117 additions and 157 deletions
|
|
@ -3,18 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
module GettingStartedHelper
|
module GettingStartedHelper
|
||||||
# @return [Boolean] The user has filled out all profile fields
|
|
||||||
def has_completed_profile?
|
|
||||||
profile = current_user.person.profile
|
|
||||||
[:full_name, :image_url,
|
|
||||||
:birthday, :gender,
|
|
||||||
:bio, :location,
|
|
||||||
:tag_string].map! do |attr|
|
|
||||||
return false if profile.send(attr).blank?
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
# @return [Boolean] The user has connected at least one service
|
# @return [Boolean] The user has connected at least one service
|
||||||
def has_connected_services?
|
def has_connected_services?
|
||||||
AppConfig[:configured_services].blank? || current_user.services.size > 0
|
AppConfig[:configured_services].blank? || current_user.services.size > 0
|
||||||
|
|
@ -29,7 +17,7 @@ module GettingStartedHelper
|
||||||
def has_few_followed_tags?
|
def has_few_followed_tags?
|
||||||
current_user.followed_tags.size > 2
|
current_user.followed_tags.size > 2
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Boolean] The user has connected to cubbi.es
|
# @return [Boolean] The user has connected to cubbi.es
|
||||||
def has_connected_cubbies?
|
def has_connected_cubbies?
|
||||||
current_user.authorizations.size > 0
|
current_user.authorizations.size > 0
|
||||||
|
|
@ -40,15 +28,6 @@ module GettingStartedHelper
|
||||||
current_user.getting_started == false
|
current_user.getting_started == false
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [String] Welcome text with or without the current_user's first_name
|
|
||||||
def welcome_text
|
|
||||||
if current_user.person.profile.first_name.present?
|
|
||||||
t('users.getting_started.welcome_with_name', :name => current_user.first_name)
|
|
||||||
else
|
|
||||||
t('users.getting_started.welcome')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def tag_link(tag_name)
|
def tag_link(tag_name)
|
||||||
if tag_followed?(tag_name)
|
if tag_followed?(tag_name)
|
||||||
link_to "##{tag_name}", tag_followings_path(tag_name), :method => :delete, :class => "featured_tag followed"
|
link_to "##{tag_name}", tag_followings_path(tag_name), :method => :delete, :class => "featured_tag followed"
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ class Person < ActiveRecord::Base
|
||||||
@first_name ||= if profile.nil? || profile.first_name.nil? || profile.first_name.blank?
|
@first_name ||= if profile.nil? || profile.first_name.nil? || profile.first_name.blank?
|
||||||
self.diaspora_handle.split('@').first
|
self.diaspora_handle.split('@').first
|
||||||
else
|
else
|
||||||
profile.first_name.to_s
|
profile.first_name.to_s.split(/\s/).first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@
|
||||||
#welcome-to-diaspora
|
#welcome-to-diaspora
|
||||||
.container
|
.container
|
||||||
%h1
|
%h1
|
||||||
Welcome to Diaspora, #{current_user.first_name}!
|
= t('.welcome_to_diaspora', :name => current_user.first_name)
|
||||||
|
%h3
|
||||||
|
= t('.time_to_introduce_yourself')
|
||||||
|
%br
|
||||||
|
%br
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
- conv_opts[:title] = t('.many_people_are_you_sure', :suggested_limit => suggested_limit) if @contacts.size > suggested_limit
|
- conv_opts[:title] = t('.many_people_are_you_sure', :suggested_limit => suggested_limit) if @contacts.size > suggested_limit
|
||||||
|
|
||||||
= link_to t('.start_a_conversation'), new_conversation_path(:aspect_id => @aspect.id, :name => @aspect.name), conv_opts
|
= link_to t('.start_a_conversation'), new_conversation_path(:aspect_id => @aspect.id, :name => @aspect.name), conv_opts
|
||||||
- if @contacts.size > suggested_limit
|
- if @contacts.size
|
||||||
= link_to t('.add_to_aspect', :name => @aspect.name), edit_aspect_path(@aspect), :rel => "facebox"
|
= link_to t('.add_to_aspect', :name => @aspect.name), edit_aspect_path(@aspect), :rel => "facebox"
|
||||||
|
|
||||||
- if @contacts.size > 0
|
- if @contacts.size > 0
|
||||||
- for contact in @contacts
|
- for contact in @contacts
|
||||||
|
|
@ -62,6 +62,6 @@
|
||||||
= link_to t('contacts.spotlight.community_spotlight'), community_spotlight_path
|
= link_to t('contacts.spotlight.community_spotlight'), community_spotlight_path
|
||||||
- if @aspect
|
- if @aspect
|
||||||
or
|
or
|
||||||
= link_to t('.add_to_aspect', :name => @aspect.name).downcase, edit_aspect_path(@aspect), :rel => "facebox"
|
= link_to t('.add_to_aspect', :name => @aspect.name), edit_aspect_path(@aspect), :rel => "facebox"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
%ul.left_nav
|
%ul.left_nav
|
||||||
- if AppConfig[:community_spotlight]
|
- if AppConfig[:community_spotlight]
|
||||||
%li{:class => ("active" if @spotlight)}
|
%li{:class => ("active" if @spotlight)}
|
||||||
= link_to t('users.getting_started.community_spotlight'), community_spotlight_path, :class => "element_selector"
|
= link_to t('contacts.spotlight.community_spotlight'), community_spotlight_path, :class => "element_selector"
|
||||||
%li{:class => ("active" if @finder)}
|
%li{:class => ("active" if @finder)}
|
||||||
= link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector"
|
= link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
$("#publisher .button.creation").bind("click", function(){
|
$("#publisher .button.creation").bind("click", function(){
|
||||||
$("#publisher .dropdown").popover("hide");
|
$("#publisher .dropdown").popover("hide");
|
||||||
$("#publisher #status_message_fake_text").popover("hide");
|
$("#publisher #status_message_fake_text").popover("hide");
|
||||||
|
$("#gs-shim").popover("hide");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.span6
|
.span6
|
||||||
= form_tag profile_path, :method => :put, :remote => true, :id => 'edit_profile' do |profile|
|
= form_tag profile_path, :method => :put, :remote => true, :id => 'edit_profile' do
|
||||||
%fieldset
|
%fieldset
|
||||||
.clearfix
|
.clearfix
|
||||||
= label_tag 'profile[first_name]', "Your name", :class => "bootstrapped"
|
= label_tag 'profile[first_name]', "Your name", :class => "bootstrapped"
|
||||||
|
|
@ -47,7 +47,6 @@
|
||||||
.clearfix
|
.clearfix
|
||||||
= label_tag :your_photo, "Your photo", :class => "bootstrapped"
|
= label_tag :your_photo, "Your photo", :class => "bootstrapped"
|
||||||
.input{:style => "position:relative;"}
|
.input{:style => "position:relative;"}
|
||||||
|
|
||||||
= render 'photos/new_profile_photo', :aspect => :getting_started, :person => current_user.person
|
= render 'photos/new_profile_photo', :aspect => :getting_started, :person => current_user.person
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
@ -60,6 +59,8 @@
|
||||||
.row
|
.row
|
||||||
%p
|
%p
|
||||||
= t('.hashtag_explanation')
|
= t('.hashtag_explanation')
|
||||||
|
%i
|
||||||
|
= t('.hashtag_suggestions')
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.span13
|
.span13
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,10 @@ en:
|
||||||
no_contacts: "No contacts"
|
no_contacts: "No contacts"
|
||||||
post_a_message: "post a message >>"
|
post_a_message: "post a message >>"
|
||||||
people_sharing_with_you: "People sharing with you"
|
people_sharing_with_you: "People sharing with you"
|
||||||
|
|
||||||
|
welcome_to_diaspora: "Welcome to Diaspora, %{name}!"
|
||||||
|
time_to_introduce_yourself: "Time to introduce yourself."
|
||||||
|
|
||||||
help:
|
help:
|
||||||
need_help: "Need Help?"
|
need_help: "Need Help?"
|
||||||
here_to_help: "The Diaspora community is here!"
|
here_to_help: "The Diaspora community is here!"
|
||||||
|
|
@ -237,7 +241,7 @@ en:
|
||||||
sharing:
|
sharing:
|
||||||
people_sharing: "People sharing with you:"
|
people_sharing: "People sharing with you:"
|
||||||
index:
|
index:
|
||||||
add_to_aspect: "Add contacts to %{name}"
|
add_to_aspect: "add contacts to %{name}"
|
||||||
start_a_conversation: "Start a conversation"
|
start_a_conversation: "Start a conversation"
|
||||||
add_a_new_aspect: "Add a new aspect"
|
add_a_new_aspect: "Add a new aspect"
|
||||||
title: "Contacts"
|
title: "Contacts"
|
||||||
|
|
@ -613,7 +617,9 @@ en:
|
||||||
your_gender: "Your gender"
|
your_gender: "Your gender"
|
||||||
your_birthday: "Your birthday"
|
your_birthday: "Your birthday"
|
||||||
your_tags: "Describe yourself in 5 words"
|
your_tags: "Describe yourself in 5 words"
|
||||||
|
|
||||||
your_tags_placeholder: "like #movies #kittens #travel #teacher #newyork"
|
your_tags_placeholder: "like #movies #kittens #travel #teacher #newyork"
|
||||||
|
|
||||||
your_bio: "Your bio"
|
your_bio: "Your bio"
|
||||||
your_location: "Your location"
|
your_location: "Your location"
|
||||||
your_photo: "Your photo"
|
your_photo: "Your photo"
|
||||||
|
|
@ -916,6 +922,7 @@ en:
|
||||||
|
|
||||||
what_are_you_in_to: "What are you into?"
|
what_are_you_in_to: "What are you into?"
|
||||||
hashtag_explanation: "Hashtags allow you to talk about and follow your interests. They're also a great way to find new people on Diaspora."
|
hashtag_explanation: "Hashtags allow you to talk about and follow your interests. They're also a great way to find new people on Diaspora."
|
||||||
|
hashtag_suggestions: "Try following tags like #art, #movies, #gif, etc."
|
||||||
|
|
||||||
saved: "Saved!"
|
saved: "Saved!"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ Feature: invitation acceptance
|
||||||
| user_password_confirmation | secret |
|
| user_password_confirmation | secret |
|
||||||
And I press "Create my account"
|
And I press "Create my account"
|
||||||
Then I should be on the getting started page
|
Then I should be on the getting started page
|
||||||
And I should see "Welcome"
|
And I should see "Well, hello there!"
|
||||||
And I fill in the following:
|
And I fill in the following:
|
||||||
| profile_first_name | O |
|
| profile_first_name | O |
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ Feature: invitation acceptance
|
||||||
| user_password_confirmation | secret |
|
| user_password_confirmation | secret |
|
||||||
And I press "Create my account"
|
And I press "Create my account"
|
||||||
Then I should be on the getting started page
|
Then I should be on the getting started page
|
||||||
And I should see "Welcome"
|
And I should see "Well, hello there!"
|
||||||
And I fill in the following:
|
And I fill in the following:
|
||||||
| profile_first_name | O |
|
| profile_first_name | O |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ Feature: User manages contacts
|
||||||
And I have an aspect called "People"
|
And I have an aspect called "People"
|
||||||
When I am on the contacts page
|
When I am on the contacts page
|
||||||
And I follow "People"
|
And I follow "People"
|
||||||
And I follow "Add contacts to People"
|
And I follow "add contacts to People"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I preemptively confirm the alert
|
And I preemptively confirm the alert
|
||||||
And I press "Delete" in the modal window
|
And I press "Delete" in the modal window
|
||||||
|
|
@ -48,7 +48,7 @@ Feature: User manages contacts
|
||||||
And I have an aspect called "Cat People"
|
And I have an aspect called "Cat People"
|
||||||
When I am on the contacts page
|
When I am on the contacts page
|
||||||
And I follow "Cat People"
|
And I follow "Cat People"
|
||||||
And I follow "Add contacts to Cat People"
|
And I follow "add contacts to Cat People"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I press the first ".contact_list .button"
|
And I press the first ".contact_list .button"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Feature: new user registration
|
||||||
And I fill in "user_password_confirmation" with "secret"
|
And I fill in "user_password_confirmation" with "secret"
|
||||||
And I press "Create my account"
|
And I press "Create my account"
|
||||||
Then I should be on the getting started page
|
Then I should be on the getting started page
|
||||||
And I should see "Welcome"
|
And I should see "Well, hello there!"
|
||||||
And I should see "Who are you?"
|
And I should see "Who are you?"
|
||||||
And I should see "What are you into?"
|
And I should see "What are you into?"
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ Feature: new user registration
|
||||||
| profile_first_name | O |
|
| profile_first_name | O |
|
||||||
And I follow "awesome_button"
|
And I follow "awesome_button"
|
||||||
|
|
||||||
Then I should be on the aspects page
|
Then I should be on the multi page
|
||||||
And I should not see "awesome_button"
|
And I should not see "awesome_button"
|
||||||
|
|
||||||
Scenario: new user skips the setup wizard
|
Scenario: new user skips the setup wizard
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ Feature: Unfollowing
|
||||||
And I click on my name in the header
|
And I click on my name in the header
|
||||||
And I follow "Contacts"
|
And I follow "Contacts"
|
||||||
And I follow "Besties"
|
And I follow "Besties"
|
||||||
And I follow "Add contacts to Besties"
|
And I follow "add contacts to Besties"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
And I preemptively confirm the alert
|
And I preemptively confirm the alert
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
require File.join(Rails.root, "lib", "publisher")
|
require File.join(Rails.root, "lib", "publisher")
|
||||||
class Stream::Base
|
class Stream::Base
|
||||||
TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']
|
TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']
|
||||||
attr_accessor :max_time, :order, :user
|
|
||||||
|
attr_accessor :max_time, :order, :user, :publisher
|
||||||
|
|
||||||
def initialize(user, opts={})
|
def initialize(user, opts={})
|
||||||
self.user = user
|
self.user = user
|
||||||
self.max_time = opts[:max_time]
|
self.max_time = opts[:max_time]
|
||||||
self.order = opts[:order]
|
self.order = opts[:order]
|
||||||
|
self.publisher = Publisher.new(self.user, publisher_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Person]
|
# @return [Person]
|
||||||
|
|
@ -76,7 +78,6 @@ class Stream::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#NOTE: MBS bad bad methods the fact we need these means our views are foobared. please kill them and make them
|
#NOTE: MBS bad bad methods the fact we need these means our views are foobared. please kill them and make them
|
||||||
#private methods on the streams that need them
|
#private methods on the streams that need them
|
||||||
def aspects
|
def aspects
|
||||||
|
|
@ -87,7 +88,7 @@ class Stream::Base
|
||||||
def aspect
|
def aspect
|
||||||
aspects.first
|
aspects.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspect_ids
|
def aspect_ids
|
||||||
aspects.map{|x| x.id}
|
aspects.map{|x| x.id}
|
||||||
end
|
end
|
||||||
|
|
@ -102,12 +103,11 @@ class Stream::Base
|
||||||
@order ||= 'created_at'
|
@order ||= 'created_at'
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Publisher]
|
|
||||||
def publisher
|
|
||||||
@publisher ||= Publisher.new(self.user)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
# @return [Hash]
|
||||||
|
def publisher_opts
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
|
||||||
# Memoizes all Contacts present in the Stream
|
# Memoizes all Contacts present in the Stream
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,15 @@ class Stream::Multi < Stream::Base
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Publisher]
|
private
|
||||||
def publisher
|
def publisher_opts
|
||||||
if welcome?
|
if welcome?
|
||||||
@publisher ||= Publisher.new(self.user, :open => true, :prefill => publisher_prefill,
|
{:open => true, :prefill => publisher_prefill, :public => true}
|
||||||
:public => true)
|
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
# Generates the prefill for the publisher
|
# Generates the prefill for the publisher
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
class Stream::Tag < Stream::Base
|
class Stream::Tag < Stream::Base
|
||||||
attr_accessor :tag_name, :people_page
|
attr_accessor :tag_name, :people_page
|
||||||
|
|
||||||
def initialize(user, tag_name, opts={})
|
def initialize(user, tag_name, opts={})
|
||||||
super(user, opts)
|
|
||||||
self.tag_name = tag_name
|
self.tag_name = tag_name
|
||||||
@people_page = opts[:page] || 1
|
self.people_page = opts[:page] || 1
|
||||||
|
super(user, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag
|
def tag
|
||||||
|
|
@ -39,11 +39,11 @@ class Stream::Tag < Stream::Base
|
||||||
@tag_name = tag_name.downcase.gsub('#', '')
|
@tag_name = tag_name.downcase.gsub('#', '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def publisher
|
|
||||||
@publisher ||= Publisher.new(self.user, :prefill => "#{display_tag_name} ")
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
# @return [Hash]
|
||||||
|
def publisher_opts
|
||||||
|
{:prefill => "#{display_tag_name} "}
|
||||||
|
end
|
||||||
|
|
||||||
def construct_post_query
|
def construct_post_query
|
||||||
posts = StatusMessage
|
posts = StatusMessage
|
||||||
|
|
|
||||||
|
|
@ -3394,8 +3394,7 @@ a.toggle_selector
|
||||||
|
|
||||||
#welcome-to-diaspora
|
#welcome-to-diaspora
|
||||||
:-webkit-box-shadow inset 0 -2px 10px rgba(0,0,0,0.35)
|
:-webkit-box-shadow inset 0 -2px 10px rgba(0,0,0,0.35)
|
||||||
|
:-moz-box-shadow inset 0 -2px 10px rgba(0,0,0,0.35)
|
||||||
|
|
||||||
|
|
||||||
:position absolute
|
:position absolute
|
||||||
:width 100%
|
:width 100%
|
||||||
|
|
@ -3410,4 +3409,4 @@ a.toggle_selector
|
||||||
|
|
||||||
#gs-shim
|
#gs-shim
|
||||||
:position absolute
|
:position absolute
|
||||||
:top 340px
|
:top 380px
|
||||||
|
|
|
||||||
|
|
@ -12,22 +12,6 @@ describe GettingStartedHelper do
|
||||||
@current_user
|
@current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#has_completed_profile?" do
|
|
||||||
it 'returns true if the current user has filled out all 7 suggested fields (from getting started)' do
|
|
||||||
profile = @current_user.person.profile
|
|
||||||
profile.update_attributes!(
|
|
||||||
{:first_name => "alice", :last_name => "smith", :image_url => "abcd.jpg", :birthday => Time.now,
|
|
||||||
:gender => "cow", :location => "san fran", :tag_string => "#sup", :bio => "holler" })
|
|
||||||
has_completed_profile?.should be_true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns false if the current user has not filled out all 7 suggested fields (from getting started)' do
|
|
||||||
@current_user.update_attributes(:person => {:profile =>
|
|
||||||
{:first_name => nil, :last_name => nil, :birthday => nil, :gender => nil }})
|
|
||||||
has_completed_profile?.should be_false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#has_connected_services?" do
|
describe "#has_connected_services?" do
|
||||||
before do
|
before do
|
||||||
AppConfig[:configured_services] = ['fake_service']
|
AppConfig[:configured_services] = ['fake_service']
|
||||||
|
|
@ -102,19 +86,4 @@ describe GettingStartedHelper do
|
||||||
has_completed_getting_started?.should be_false
|
has_completed_getting_started?.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#welcome_text" do
|
|
||||||
it 'returns "Welcome" without a name if first_name is not set' do
|
|
||||||
profile = @current_user.person.profile
|
|
||||||
profile.first_name = ""
|
|
||||||
profile.save
|
|
||||||
@current_user.person.instance_variable_set(:@first_name, nil)
|
|
||||||
|
|
||||||
welcome_text.should == "Welcome!"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns "Welcome, {first_name}" if first_name is set' do
|
|
||||||
welcome_text.should == "Welcome, #{current_user.first_name}!"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -172,67 +172,4 @@ describe Stream::Aspect do
|
||||||
end
|
end
|
||||||
it_should_behave_like 'it is a stream'
|
it_should_behave_like 'it is a stream'
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#publisher" do
|
|
||||||
before do
|
|
||||||
@stream = Stream::Aspect.new(alice, alice.aspects.map(&:id))
|
|
||||||
@stream.stub(:welcome?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not use prefill text by default' do
|
|
||||||
@stream.should_not_receive(:publisher_prefill)
|
|
||||||
|
|
||||||
@stream.publisher
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'checks welcome?' do
|
|
||||||
@stream.should_receive(:welcome?).and_return(true)
|
|
||||||
|
|
||||||
@stream.publisher
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a welcome publisher for new user' do
|
|
||||||
@stream.stub(:welcome?).and_return(true)
|
|
||||||
@stream.should_receive(:publisher_prefill).and_return("abc")
|
|
||||||
|
|
||||||
Publisher.should_receive(:new).with(alice, hash_including(:open => true, :prefill => "abc", :public => true))
|
|
||||||
@stream.publisher
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a default publisher for returning users' do
|
|
||||||
Publisher.should_receive(:new).with(alice)
|
|
||||||
@stream.publisher
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#publisher_prefill" do
|
|
||||||
before do
|
|
||||||
@tag = ActsAsTaggableOn::Tag.find_or_create_by_name("cats")
|
|
||||||
@tag_following = alice.tag_followings.create(:tag_id => @tag.id)
|
|
||||||
|
|
||||||
@stream = Stream::Aspect.new(alice, alice.aspects.map(&:id))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns includes new user hashtag' do
|
|
||||||
@stream.send(:publisher_prefill).include?("#newhere").should be_true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'includes followed hashtags' do
|
|
||||||
@stream.send(:publisher_prefill).include?("#cats").should be_true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#welcome?" do
|
|
||||||
it 'returns true if user is getting started' do
|
|
||||||
alice.getting_started = true
|
|
||||||
|
|
||||||
Stream::Aspect.new(alice, alice.aspects.map(&:id)).send(:welcome?).should be_true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns false if user is getting started' do
|
|
||||||
alice.getting_started = false
|
|
||||||
|
|
||||||
Stream::Aspect.new(alice, alice.aspects.map(&:id)).send(:welcome?).should be_false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,54 @@ describe Stream::Multi do
|
||||||
@stream.send(:is_in?, :aspects, p).should be_true
|
@stream.send(:is_in?, :aspects, p).should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#publisher_opts' do
|
||||||
|
it 'prefills, sets public, and autoexpands if welcome? is set' do
|
||||||
|
prefill_text = "sup?"
|
||||||
|
@stream.stub(:welcome?).and_return(true)
|
||||||
|
@stream.stub(:publisher_prefill).and_return(prefill_text)
|
||||||
|
@stream.send(:publisher_opts).should == {:open => true,
|
||||||
|
:prefill => prefill_text,
|
||||||
|
:public => true}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'provides no opts if welcome? is not set' do
|
||||||
|
prefill_text = "sup?"
|
||||||
|
@stream.stub(:welcome?).and_return(false)
|
||||||
|
@stream.send(:publisher_opts).should == {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#publisher_prefill" do
|
||||||
|
before do
|
||||||
|
@tag = ActsAsTaggableOn::Tag.find_or_create_by_name("cats")
|
||||||
|
@tag_following = alice.tag_followings.create(:tag_id => @tag.id)
|
||||||
|
|
||||||
|
@stream = Stream::Multi.new(alice)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns includes new user hashtag' do
|
||||||
|
@stream.send(:publisher_prefill).include?("#newhere").should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes followed hashtags' do
|
||||||
|
@stream.send(:publisher_prefill).include?("#cats").should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#welcome?" do
|
||||||
|
before do
|
||||||
|
@stream = Stream::Multi.new(alice)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true if user is getting started' do
|
||||||
|
alice.getting_started = true
|
||||||
|
@stream.send(:welcome?).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false if user is getting started' do
|
||||||
|
alice.getting_started = false
|
||||||
|
@stream.send(:welcome?).should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,8 @@ describe Stream::Tag do
|
||||||
|
|
||||||
describe "#publisher" do
|
describe "#publisher" do
|
||||||
it 'creates a publisher with the tag prefill' do
|
it 'creates a publisher with the tag prefill' do
|
||||||
Publisher.should_receive(:new).with(anything(), hash_including(:prefill => "#what "))
|
Publisher.should_receive(:new).with(anything(), {:prefill => "#what "})
|
||||||
@stream = Stream::Tag.new(alice, "what")
|
@stream = Stream::Tag.new(alice, "what")
|
||||||
@stream.publisher
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,18 @@ describe Person do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#first_name" do
|
||||||
|
it 'returns username if first_name is not present in profile' do
|
||||||
|
alice.person.profile.update_attributes(:first_name => "")
|
||||||
|
alice.person.first_name.should == alice.username
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns first word in first_name if first_name is present' do
|
||||||
|
alice.person.profile.update_attributes(:first_name => "Alice Smith")
|
||||||
|
alice.person.first_name.should == "Alice"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '.search' do
|
describe '.search' do
|
||||||
before do
|
before do
|
||||||
Person.delete_all
|
Person.delete_all
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ describe 'Streams' do
|
||||||
@stream.people.should_not be_nil
|
@stream.people.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it '#publisher_opts' do
|
||||||
|
@stream.send(:publisher_opts).should_not be_nil
|
||||||
|
end
|
||||||
|
|
||||||
it 'has a #contacts title' do
|
it 'has a #contacts title' do
|
||||||
@stream.contacts_title.should_not be_nil
|
@stream.contacts_title.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue