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:
authorIlyaaaaaaaaaaaaa Zhitomirskiy <ilya@joindiaspora.com>2011-07-20 05:17:08 +0400
committerRaphael Sofaer <raphael@joindiaspora.com>2011-07-22 05:23:33 +0400
commit537766d0d70ee26b5fce3a770062f15f66e0f790 (patch)
tree3b72724e78881d94e39d08322d350c7a4445c6cb /spec
parent70be713b158b181b548ce1b35abca65cad7d4f2a (diff)
Started working on repost integration test
Diffstat (limited to 'spec')
-rw-r--r--spec/multi_server/repost_spec.rb52
-rw-r--r--spec/multi_server/server_spec.rb2
-rw-r--r--spec/support/server.rb22
3 files changed, 72 insertions, 4 deletions
diff --git a/spec/multi_server/repost_spec.rb b/spec/multi_server/repost_spec.rb
new file mode 100644
index 000000000..4e4bde01d
--- /dev/null
+++ b/spec/multi_server/repost_spec.rb
@@ -0,0 +1,52 @@
+
+require 'spec_helper'
+
+
+unless Server.all.empty?
+ describe "reposting" do
+ before(:all) do
+ WebMock::Config.instance.allow_localhost = true
+ #Server.all.each{|s| s.kill if s.running?}
+ #Server.all.each{|s| s.run}
+ end
+
+ after(:all) do
+ #Server.all.each{|s| s.kill if s.running?}
+ #sleep(1)
+ #Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
+ WebMock::Config.instance.allow_localhost = false
+ end
+
+ it 'fetches the original post from the root server' do
+ Server.all[0].in_scope do
+ original_poster = Factory.create(:user_with_aspect, :username => "original_poster")
+ resharer = Factory.create(:user_with_aspect, :username => "resharer")
+
+ connect_users_with_aspects(original_poster, resharer)
+
+ original_post = original_poster.post(:status_message,
+ :public => true,
+ :text => "Awesome Sauce!",
+ :to => 'all')
+ resharer.post(:reshare, :root_id => original_post.id, :to => 'all')
+ end
+
+ Server.all[1].in_scope do
+ recipient = Factory.create(:user_with_aspect, :username => "resharer")
+ end
+
+ Server.all[0].in_scope do
+ r = User.find_by_username("resharer")
+ person = Webfinger.new("recipient@localhost:#{Server.all[1].port}").fetch
+ r.share_with(person, r.aspects.first)
+ end
+ Server.all[1].in_scope do
+ r = User.find_by_username("recipient")
+ person = Webfinger.new("resharer@localhost:#{Server.all[0].port}").fetch
+ r.share_with(person, r.aspects.first)
+ end
+
+
+ end
+ end
+end
diff --git a/spec/multi_server/server_spec.rb b/spec/multi_server/server_spec.rb
index a600bce2e..e8e01fea3 100644
--- a/spec/multi_server/server_spec.rb
+++ b/spec/multi_server/server_spec.rb
@@ -1,7 +1,6 @@
#This is a spec for the class that runs the servers used in the other multi-server specs
require 'spec_helper'
-WebMock::Config.instance.allow_localhost = true
unless Server.all.empty?
describe Server do
before(:all) do
@@ -57,4 +56,3 @@ unless Server.all.empty?
end
end
end
-WebMock::Config.instance.allow_localhost = false
diff --git a/spec/support/server.rb b/spec/support/server.rb
index 0a848955a..eb31db5e6 100644
--- a/spec/support/server.rb
+++ b/spec/support/server.rb
@@ -62,8 +62,11 @@ class Server
def db
former_env = Rails.env
ActiveRecord::Base.establish_connection(env)
- result = yield
- ActiveRecord::Base.establish_connection(former_env)
+ begin
+ result = yield
+ ensure
+ ActiveRecord::Base.establish_connection(former_env)
+ end
result
end
@@ -72,4 +75,19 @@ class Server
DatabaseCleaner.clean_with(:truncation)
end
end
+
+ def in_scope
+ pod_url = "http://localhost:#{@port}/"
+ AppConfig.stub!(:pod_url).and_return(pod_url)
+ AppConfig.stub!(:pod_uri).and_return(URI.parse(pod_url))
+ begin
+ result = db do
+ yield
+ end
+ ensure
+ AppConfig.unstub!(:pod_url)
+ AppConfig.unstub!(:pod_uri)
+ end
+ result
+ end
end