Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielgrippi <danielgrippi@gmail.com>2011-10-25 01:11:01 +0400
committerdanielgrippi <danielgrippi@gmail.com>2011-10-25 01:41:15 +0400
commite63e8299b9d98d0cc013c719313458c58d511db8 (patch)
treeee43eead41d331bd95d7ec7e6f6f39936cd4700d /spec
parent59e495572784b8fce1c8a3b6d427915133213327 (diff)
fixed up stream/publisher logic; fixed cukes
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/getting_started_helper_spec.rb31
-rw-r--r--spec/lib/stream/aspect_spec.rb63
-rw-r--r--spec/lib/stream/multi_spec.rb50
-rw-r--r--spec/lib/stream/tag_spec.rb3
-rw-r--r--spec/models/person_spec.rb12
-rw-r--r--spec/shared_behaviors/stream.rb4
6 files changed, 67 insertions, 96 deletions
diff --git a/spec/helpers/getting_started_helper_spec.rb b/spec/helpers/getting_started_helper_spec.rb
index 914e7bd8e..64dcd829f 100644
--- a/spec/helpers/getting_started_helper_spec.rb
+++ b/spec/helpers/getting_started_helper_spec.rb
@@ -12,22 +12,6 @@ describe GettingStartedHelper do
@current_user
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
before do
AppConfig[:configured_services] = ['fake_service']
@@ -102,19 +86,4 @@ describe GettingStartedHelper do
has_completed_getting_started?.should be_false
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
diff --git a/spec/lib/stream/aspect_spec.rb b/spec/lib/stream/aspect_spec.rb
index ef2dedfc8..b7e96e52c 100644
--- a/spec/lib/stream/aspect_spec.rb
+++ b/spec/lib/stream/aspect_spec.rb
@@ -172,67 +172,4 @@ describe Stream::Aspect do
end
it_should_behave_like 'it is a stream'
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
diff --git a/spec/lib/stream/multi_spec.rb b/spec/lib/stream/multi_spec.rb
index 21a81d4eb..7e5f08c12 100644
--- a/spec/lib/stream/multi_spec.rb
+++ b/spec/lib/stream/multi_spec.rb
@@ -18,4 +18,54 @@ describe Stream::Multi do
@stream.send(:is_in?, :aspects, p).should be_true
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
diff --git a/spec/lib/stream/tag_spec.rb b/spec/lib/stream/tag_spec.rb
index 4d9cbd08f..158372d33 100644
--- a/spec/lib/stream/tag_spec.rb
+++ b/spec/lib/stream/tag_spec.rb
@@ -94,9 +94,8 @@ describe Stream::Tag do
describe "#publisher" 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.publisher
end
end
end
diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb
index 47b3cbc94..2c59f9690 100644
--- a/spec/models/person_spec.rb
+++ b/spec/models/person_spec.rb
@@ -271,6 +271,18 @@ describe Person do
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
before do
Person.delete_all
diff --git a/spec/shared_behaviors/stream.rb b/spec/shared_behaviors/stream.rb
index 3d063b88f..327d1c47d 100644
--- a/spec/shared_behaviors/stream.rb
+++ b/spec/shared_behaviors/stream.rb
@@ -15,6 +15,10 @@ describe 'Streams' do
@stream.people.should_not be_nil
end
+ it '#publisher_opts' do
+ @stream.send(:publisher_opts).should_not be_nil
+ end
+
it 'has a #contacts title' do
@stream.contacts_title.should_not be_nil
end