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:
authorMaxwell Salzberg <maxwell@joindiaspora.com>2011-05-26 06:01:17 +0400
committerRaphael Sofaer <raphael@joindiaspora.com>2011-07-22 05:22:17 +0400
commitfa9269541fa89b4ed4061cd19a99b4bc89b0a184 (patch)
treea85263df20bc3c417632b7d64f5b2b77adb1396e /spec
parent06f886ad770d95b7396a068ad15c153c624632d9 (diff)
wip removed some generated specs
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/aspects_controller_spec.rb6
-rw-r--r--spec/controllers/people_controller_spec.rb6
-rw-r--r--spec/controllers/reshares_controller_spec.rb38
-rw-r--r--spec/helpers/reshares_helper_spec.rb15
-rw-r--r--spec/models/reshare_spec.rb20
5 files changed, 82 insertions, 3 deletions
diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb
index 792ac7a9e..f0a2794a6 100644
--- a/spec/controllers/aspects_controller_spec.rb
+++ b/spec/controllers/aspects_controller_spec.rb
@@ -179,6 +179,12 @@ describe AspectsController do
assigns(:posts).models.length.should == 2
end
+ it "posts include reshares" do
+ reshare = alice.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id, :to => alice.aspects)
+ get :index
+ assigns[:posts].post_fakes.map{|x| x.id}.should include(reshare.id)
+ end
+
it "can filter to a single aspect" do
get :index, :a_ids => [@alices_aspect_2.id.to_s]
assigns(:posts).models.length.should == 1
diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb
index f6aea6246..7feb2b478 100644
--- a/spec/controllers/people_controller_spec.rb
+++ b/spec/controllers/people_controller_spec.rb
@@ -206,7 +206,7 @@ describe PeopleController do
end
it "posts include reshares" do
- reshare = @user.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id)
+ reshare = @user.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id, :to => alice.aspects)
get :show, :id => @user.person.id
assigns[:posts].post_fakes.map{|x| x.id}.should include(reshare.id)
end
@@ -259,7 +259,7 @@ describe PeopleController do
end
it "posts include reshares" do
- reshare = @user.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id)
+ reshare = @user.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id, :to => alice.aspects)
get :show, :id => @user.person.id
assigns[:posts].post_fakes.map{|x| x.id}.should include(reshare.id)
end
@@ -297,7 +297,7 @@ describe PeopleController do
end
it "posts include reshares" do
- reshare = @user.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id)
+ reshare = @user.post(:reshare, :public => true, :root_id => Factory(:status_message, :public => true).id, :to => alice.aspects)
get :show, :id => @user.person.id
assigns[:posts].post_fakes.map{|x| x.id}.should include(reshare.id)
end
diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb
new file mode 100644
index 000000000..9a780a905
--- /dev/null
+++ b/spec/controllers/reshares_controller_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+describe ResharesController do
+
+ describe '#create' do
+
+ it 'requires authentication' do
+ post :create, :format => :js
+ response.should_not be_success
+ end
+
+ context 'with an authenticated user' do
+
+ before do
+
+ sign_in :user, bob
+ @post_id = Factory(:status_message, :public => true).id
+ @controller.stub(:current_user).and_return(bob)
+ end
+
+ it 'succeeds' do
+ post :create, :format => :js, :root_id => @post_id
+ puts response.code
+ response.should be_success
+ end
+
+ it 'creates a reshare' do
+ expect{
+ post :create, :format => :js, :root_id => @post_id
+ }.should change(Reshare, :count).by(1)
+ end
+
+ it 'after save, calls add to streams' do
+ bob.should_receive(:add_to_streams)
+ post :create, :format => :js, :root_id => @post_id
+ end
+ end
+ end
+end
diff --git a/spec/helpers/reshares_helper_spec.rb b/spec/helpers/reshares_helper_spec.rb
new file mode 100644
index 000000000..524a2bd0c
--- /dev/null
+++ b/spec/helpers/reshares_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ResharesHelper. For example:
+#
+# describe ResharesHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe ResharesHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb
new file mode 100644
index 000000000..7fcd620ae
--- /dev/null
+++ b/spec/models/reshare_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe Reshare do
+ it 'has a valid Factory' do
+ Factory(:reshare).should be_valid
+ end
+
+ it 'requires root' do
+ reshare = Factory.build(:reshare, :root => nil)
+ reshare.should_not be_valid
+ end
+
+ it 'require public root' do
+ Factory.build(:reshare, :root => Factory.build(:status_message, :public => false)).should_not be_valid
+ end
+
+ it 'forces public' do
+ Factory(:reshare, :public => false).public.should be_true
+ end
+end