Made specs work with fixtures, spec_helper needs work
This commit is contained in:
parent
ac3d037dc4
commit
1353929d44
56 changed files with 393 additions and 440 deletions
|
|
@ -9,7 +9,7 @@ describe HomeController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
sign_in @user
|
sign_in @user
|
||||||
sign_out @user
|
sign_out @user
|
||||||
end
|
end
|
||||||
|
|
@ -37,7 +37,7 @@ describe HomeController do
|
||||||
|
|
||||||
describe "custom logging on redirect" do
|
describe "custom logging on redirect" do
|
||||||
before do
|
before do
|
||||||
sign_in :user, Factory(:user)
|
sign_in :user, bob
|
||||||
@action = :show
|
@action = :show
|
||||||
@action_params = {"lasers" => "green"}
|
@action_params = {"lasers" => "green"}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,20 @@ describe InvitationsController do
|
||||||
|
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let!(:user) { Factory.create(:user) }
|
|
||||||
let!(:aspect) { user.aspects.create(:name => "WIN!!") }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@user = alice
|
||||||
|
@aspect = @user.aspects.first
|
||||||
|
|
||||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#create" do
|
describe "#create" do
|
||||||
before do
|
before do
|
||||||
|
@user.invites = 5
|
||||||
|
|
||||||
user.invites = 5
|
sign_in :user, @user
|
||||||
|
@invite = {:invite_message=>"test", :aspect_id=> @aspect.id.to_s, :email=>"abc@example.com"}
|
||||||
sign_in :user, user
|
@controller.stub!(:current_user).and_return(@user)
|
||||||
@invite = {:invite_message=>"test", :aspect_id=> aspect.id.to_s, :email=>"abc@example.com"}
|
|
||||||
@controller.stub!(:current_user).and_return(user)
|
|
||||||
request.env["HTTP_REFERER"]= 'http://test.host/cats/foo'
|
request.env["HTTP_REFERER"]= 'http://test.host/cats/foo'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -54,8 +52,8 @@ describe InvitationsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't invite anyone if you have 0 invites" do
|
it "doesn't invite anyone if you have 0 invites" do
|
||||||
user.invites = 0
|
@user.invites = 0
|
||||||
user.save!
|
@user.save!
|
||||||
lambda {
|
lambda {
|
||||||
post :create, :user => @invite.merge(:email => "mbs@gmail.com, foo@bar.com, foo.com, lala@foo, cool@bar.com")
|
post :create, :user => @invite.merge(:email => "mbs@gmail.com, foo@bar.com, foo.com, lala@foo, cool@bar.com")
|
||||||
}.should_not change(User, :count)
|
}.should_not change(User, :count)
|
||||||
|
|
@ -69,8 +67,8 @@ describe InvitationsController do
|
||||||
|
|
||||||
describe "#update" do
|
describe "#update" do
|
||||||
before do
|
before do
|
||||||
user.invites = 5
|
@user.invites = 5
|
||||||
@invited_user = user.invite_user("a@a.com", user.aspects.first.id)
|
@invited_user = @user.invite_user("a@a.com", @aspect.id)
|
||||||
@accept_params = {:user=>
|
@accept_params = {:user=>
|
||||||
{:password_confirmation =>"password",
|
{:password_confirmation =>"password",
|
||||||
:username=>"josh",
|
:username=>"josh",
|
||||||
|
|
@ -91,7 +89,6 @@ describe InvitationsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds a pending request' do
|
it 'adds a pending request' do
|
||||||
|
|
||||||
put :update, @accept_params
|
put :update, @accept_params
|
||||||
Request.where(:recipient_id => invited.person.id).count.should == 1
|
Request.where(:recipient_id => invited.person.id).count.should == 1
|
||||||
end
|
end
|
||||||
|
|
@ -100,7 +97,7 @@ describe InvitationsController do
|
||||||
context 'failure' do
|
context 'failure' do
|
||||||
before do
|
before do
|
||||||
@fail_params = @accept_params
|
@fail_params = @accept_params
|
||||||
@fail_params[:user][:username] = user.username
|
@fail_params[:user][:username] = @user.username
|
||||||
end
|
end
|
||||||
it 'stays on the invitation accept form' do
|
it 'stays on the invitation accept form' do
|
||||||
put :update, @fail_params
|
put :update, @fail_params
|
||||||
|
|
@ -115,7 +112,7 @@ describe InvitationsController do
|
||||||
|
|
||||||
describe '#new' do
|
describe '#new' do
|
||||||
it 'renders' do
|
it 'renders' do
|
||||||
sign_in :user, user
|
sign_in :user, @user
|
||||||
get :new
|
get :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,24 +6,24 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe NotificationsController do
|
describe NotificationsController do
|
||||||
|
|
||||||
let!(:user) { Factory.create(:user) }
|
|
||||||
let!(:aspect) { user.aspects.create(:name => "AWESOME!!") }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in :user, user
|
@user = alice
|
||||||
|
@aspect = @user.aspects.first
|
||||||
|
sign_in :user, @user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
it 'marks a notification as read' do
|
it 'marks a notification as read' do
|
||||||
note = Notification.create(:recipient_id => user.id)
|
note = Notification.create(:recipient_id => @user.id)
|
||||||
put :update, :id => note.id
|
put :update, :id => note.id
|
||||||
Notification.first.unread.should == false
|
Notification.first.unread.should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'only lets you read your own notifications' do
|
it 'only lets you read your own notifications' do
|
||||||
user2 = Factory.create(:user)
|
user2 = bob
|
||||||
|
|
||||||
Notification.create(:recipient_id => user.id)
|
Notification.create(:recipient_id => @user.id)
|
||||||
note = Notification.create(:recipient_id => user2.id)
|
note = Notification.create(:recipient_id => user2.id)
|
||||||
|
|
||||||
put :update, :id => note.id
|
put :update, :id => note.id
|
||||||
|
|
@ -35,8 +35,8 @@ describe NotificationsController do
|
||||||
describe "#read_all" do
|
describe "#read_all" do
|
||||||
it 'marks all notifications as read' do
|
it 'marks all notifications as read' do
|
||||||
request.env["HTTP_REFERER"] = "I wish I were spelled right"
|
request.env["HTTP_REFERER"] = "I wish I were spelled right"
|
||||||
Notification.create(:recipient_id => user.id)
|
Notification.create(:recipient_id => @user.id)
|
||||||
Notification.create(:recipient_id => user.id)
|
Notification.create(:recipient_id => @user.id)
|
||||||
|
|
||||||
Notification.where(:unread => true).count.should == 2
|
Notification.where(:unread => true).count.should == 2
|
||||||
get :read_all
|
get :read_all
|
||||||
|
|
@ -47,7 +47,7 @@ describe NotificationsController do
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
it 'paginates the notifications' do
|
it 'paginates the notifications' do
|
||||||
35.times do
|
35.times do
|
||||||
Notification.create(:recipient_id => user.id)
|
Notification.create(:recipient_id => @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
get :index
|
get :index
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,20 @@ require 'spec_helper'
|
||||||
describe PeopleController do
|
describe PeopleController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Factory.create(:user) }
|
|
||||||
let!(:aspect) { user.aspects.create(:name => "lame-os") }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in :user, user
|
@user = alice
|
||||||
|
@aspect = @user.aspects.first
|
||||||
|
sign_in :user, @user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#similar_people' do
|
describe '#similar_people' do
|
||||||
before do
|
before do
|
||||||
@contacts = []
|
@contacts = []
|
||||||
@aspect1 = user.aspects.create(:name => "foos")
|
@aspect1 = @user.aspects.create(:name => "foos")
|
||||||
@aspect2 = user.aspects.create(:name => "bars")
|
@aspect2 = @user.aspects.create(:name => "bars")
|
||||||
|
|
||||||
3.times do
|
3.times do
|
||||||
@contacts << Contact.create(:user => user, :person => Factory.create(:person))
|
@contacts << Contact.create(:user => @user, :person => Factory.create(:person))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -57,7 +56,7 @@ describe PeopleController do
|
||||||
@contacts[0].save
|
@contacts[0].save
|
||||||
|
|
||||||
20.times do
|
20.times do
|
||||||
c = Contact.create(:user => user, :person => Factory.create(:person))
|
c = Contact.create(:user => @user, :person => Factory.create(:person))
|
||||||
c.aspects << @aspect1
|
c.aspects << @aspect1
|
||||||
c.save
|
c.save
|
||||||
@contacts << c
|
@contacts << c
|
||||||
|
|
@ -83,16 +82,16 @@ describe PeopleController do
|
||||||
@everyone << Factory.create(:person)
|
@everyone << Factory.create(:person)
|
||||||
end
|
end
|
||||||
|
|
||||||
user.send_contact_request_to(@everyone[3], aspect)
|
@user.send_contact_request_to(@everyone[3], @aspect)
|
||||||
user.send_contact_request_to(@everyone[2], aspect)
|
@user.send_contact_request_to(@everyone[2], @aspect)
|
||||||
user.activate_contact(@everyone[4], aspect)
|
@user.activate_contact(@everyone[4], @aspect)
|
||||||
user.activate_contact(@everyone[5], aspect)
|
@user.activate_contact(@everyone[5], @aspect)
|
||||||
|
|
||||||
user.reload
|
@user.reload
|
||||||
user.aspects.reload
|
@user.aspects.reload
|
||||||
@people = @everyone
|
@people = @everyone
|
||||||
@people.length.should == 10
|
@people.length.should == 10
|
||||||
@hashes = @controller.hashes_for_people(@people, user.aspects)
|
@hashes = @controller.hashes_for_people(@people, @user.aspects)
|
||||||
end
|
end
|
||||||
it 'has the correct result for no relationship' do
|
it 'has the correct result for no relationship' do
|
||||||
hash = @hashes.first
|
hash = @hashes.first
|
||||||
|
|
@ -100,21 +99,21 @@ describe PeopleController do
|
||||||
hash[:person].should == @people.first
|
hash[:person].should == @people.first
|
||||||
hash[:contact].should be_false
|
hash[:contact].should be_false
|
||||||
hash[:request].should be_false
|
hash[:request].should be_false
|
||||||
hash[:aspects].should == user.aspects
|
hash[:aspects].should == @user.aspects
|
||||||
end
|
end
|
||||||
it 'has the correct result for a connected person' do
|
it 'has the correct result for a connected person' do
|
||||||
hash = @hashes[4]
|
hash = @hashes[4]
|
||||||
hash[:person].should == @people[4]
|
hash[:person].should == @people[4]
|
||||||
hash[:contact].should be_true
|
hash[:contact].should be_true
|
||||||
hash[:contact].should_not be_pending
|
hash[:contact].should_not be_pending
|
||||||
hash[:aspects].should == user.aspects
|
hash[:aspects].should == @user.aspects
|
||||||
end
|
end
|
||||||
it 'has the correct result for a requested person' do
|
it 'has the correct result for a requested person' do
|
||||||
hash = @hashes[2]
|
hash = @hashes[2]
|
||||||
hash[:person].should == @people[2]
|
hash[:person].should == @people[2]
|
||||||
hash[:contact].should be_true
|
hash[:contact].should be_true
|
||||||
hash[:contact].should be_pending
|
hash[:contact].should be_pending
|
||||||
hash[:aspects].should == user.aspects
|
hash[:aspects].should == @user.aspects
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
|
|
@ -144,14 +143,13 @@ describe PeopleController do
|
||||||
assigns[:people].should =~ [@eugene, eugene2]
|
assigns[:people].should =~ [@eugene, eugene2]
|
||||||
end
|
end
|
||||||
it 'shows a contact' do
|
it 'shows a contact' do
|
||||||
user2 = Factory.create(:user)
|
user2 = bob
|
||||||
connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience'))
|
|
||||||
get :index, :q => user2.person.profile.first_name.to_s
|
get :index, :q => user2.person.profile.first_name.to_s
|
||||||
response.should redirect_to user2.person
|
response.should redirect_to user2.person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows a non-contact' do
|
it 'shows a non-contact' do
|
||||||
user2 = Factory.create(:user)
|
user2 = eve
|
||||||
user2.person.profile.searchable = true
|
user2.person.profile.searchable = true
|
||||||
user2.save
|
user2.save
|
||||||
get :index, :q => user2.person.profile.first_name.to_s
|
get :index, :q => user2.person.profile.first_name.to_s
|
||||||
|
|
@ -171,20 +169,20 @@ describe PeopleController do
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
it 'goes to the current_user show page' do
|
it 'goes to the current_user show page' do
|
||||||
get :show, :id => user.person.id
|
get :show, :id => @user.person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders with a post' do
|
it 'renders with a post' do
|
||||||
user.post :status_message, :message => 'test more', :to => aspect.id
|
@user.post :status_message, :message => 'test more', :to => @aspect.id
|
||||||
get :show, :id => user.person.id
|
get :show, :id => @user.person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders with a post' do
|
it 'renders with a post' do
|
||||||
message = user.post :status_message, :message => 'test more', :to => aspect.id
|
message = @user.post :status_message, :message => 'test more', :to => @aspect.id
|
||||||
user.comment 'I mean it', :on => message
|
@user.comment 'I mean it', :on => message
|
||||||
get :show, :id => user.person.id
|
get :show, :id => @user.person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -194,25 +192,24 @@ describe PeopleController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "redirects to #index if no person is found" do
|
it "redirects to #index if no person is found" do
|
||||||
get :show, :id => user.id
|
get :show, :id => 3920397846
|
||||||
response.should redirect_to people_path
|
response.should redirect_to people_path
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the show page of a contact" do
|
it "renders the show page of a contact" do
|
||||||
user2 = Factory.create(:user)
|
user2 = bob
|
||||||
connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience'))
|
|
||||||
get :show, :id => user2.person.id
|
get :show, :id => user2.person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the show page of a non-contact" do
|
it "renders the show page of a non-contact" do
|
||||||
user2 = Factory.create(:user)
|
user2 = eve
|
||||||
get :show, :id => user2.person.id
|
get :show, :id => user2.person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders with public posts of a non-contact" do
|
it "renders with public posts of a non-contact" do
|
||||||
user2 = Factory.create(:user)
|
user2 = eve
|
||||||
status_message = user2.post(:status_message, :message => "hey there", :to => 'all', :public => true)
|
status_message = user2.post(:status_message, :message => "hey there", :to => 'all', :public => true)
|
||||||
|
|
||||||
get :show, :id => user2.person.id
|
get :show, :id => user2.person.id
|
||||||
|
|
@ -223,14 +220,14 @@ describe PeopleController do
|
||||||
|
|
||||||
describe '#webfinger' do
|
describe '#webfinger' do
|
||||||
it 'enqueues a webfinger job' do
|
it 'enqueues a webfinger job' do
|
||||||
Resque.should_receive(:enqueue).with(Jobs::SocketWebfinger, user.id, user.diaspora_handle, anything).once
|
Resque.should_receive(:enqueue).with(Jobs::SocketWebfinger, @user.id, @user.diaspora_handle, anything).once
|
||||||
get :retrieve_remote, :diaspora_handle => user.diaspora_handle
|
get :retrieve_remote, :diaspora_handle => @user.diaspora_handle
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
it "sets the flash" do
|
it "sets the flash" do
|
||||||
put :update, :id => user.person.id,
|
put :update, :id => @user.person.id,
|
||||||
:profile => {
|
:profile => {
|
||||||
:image_url => "",
|
:image_url => "",
|
||||||
:first_name => "Will",
|
:first_name => "Will",
|
||||||
|
|
@ -241,35 +238,35 @@ describe PeopleController do
|
||||||
|
|
||||||
context 'with a profile photo set' do
|
context 'with a profile photo set' do
|
||||||
before do
|
before do
|
||||||
@params = { :id => user.person.id,
|
@params = { :id => @user.person.id,
|
||||||
:profile =>
|
:profile =>
|
||||||
{:image_url => "",
|
{:image_url => "",
|
||||||
:last_name => user.person.profile.last_name,
|
:last_name => @user.person.profile.last_name,
|
||||||
:first_name => user.person.profile.first_name }}
|
:first_name => @user.person.profile.first_name }}
|
||||||
|
|
||||||
user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
@user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||||
user.person.profile.save
|
@user.person.profile.save
|
||||||
end
|
end
|
||||||
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
||||||
image_url = user.person.profile.image_url
|
image_url = @user.person.profile.image_url
|
||||||
put :update, @params
|
put :update, @params
|
||||||
|
|
||||||
Person.find(user.person.id).profile.image_url.should == image_url
|
Person.find(@user.person.id).profile.image_url.should == image_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
it 'does not allow mass assignment' do
|
it 'does not allow mass assignment' do
|
||||||
person = user.person
|
person = @user.person
|
||||||
new_user = Factory.create(:user)
|
new_user = Factory.create(:user)
|
||||||
person.owner_id.should == user.id
|
person.owner_id.should == @user.id
|
||||||
put :update, :id => user.person.id, :owner_id => new_user.id
|
put :update, :id => @user.person.id, :owner_id => new_user.id
|
||||||
Person.find(person.id).owner_id.should == user.id
|
Person.find(person.id).owner_id.should == @user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not overwrite the profile diaspora handle' do
|
it 'does not overwrite the profile diaspora handle' do
|
||||||
handle_params = {:id => user.person.id,
|
handle_params = {:id => @user.person.id,
|
||||||
:profile => {:diaspora_handle => 'abc@a.com'} }
|
:profile => {:diaspora_handle => 'abc@a.com'} }
|
||||||
put :update, handle_params
|
put :update, handle_params
|
||||||
Person.find(user.person.id).profile[:diaspora_handle].should_not == 'abc@a.com'
|
Person.find(@user.person.id).profile[:diaspora_handle].should_not == 'abc@a.com'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,35 +7,31 @@ require 'spec_helper'
|
||||||
describe PhotosController do
|
describe PhotosController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user1) {Factory.create(:user)}
|
|
||||||
let(:user2) {Factory.create(:user)}
|
|
||||||
|
|
||||||
let(:aspect1) { user1.aspects.create(:name => 'winners') }
|
|
||||||
let(:aspect2) { user2.aspects.create(:name => 'winners') }
|
|
||||||
|
|
||||||
let(:filename) { 'button.png' }
|
|
||||||
let(:fixture_name) { File.join(File.dirname(__FILE__), '..', 'fixtures', filename) }
|
|
||||||
let(:photo1) { user1.post(:photo, :user_file => File.open(fixture_name), :to => aspect1.id) }
|
|
||||||
let(:photo2) { user2.post(:photo, :user_file => File.open(fixture_name), :to => aspect2.id) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
connect_users(user1, aspect1, user2, aspect2)
|
@user1 = alice
|
||||||
photo1; photo2
|
@user2 = bob
|
||||||
@controller.stub!(:current_user).and_return(user1)
|
|
||||||
sign_in :user, user1
|
@aspect1 = @user1.aspects.first
|
||||||
|
@aspect2 = @user2.aspects.first
|
||||||
|
|
||||||
|
@photo1 = @user1.post(:photo, :user_file => uploaded_photo, :to => @aspect1.id)
|
||||||
|
@photo2 = @user2.post(:photo, :user_file => uploaded_photo, :to => @aspect2.id)
|
||||||
|
|
||||||
|
@controller.stub!(:current_user).and_return(@user1)
|
||||||
|
sign_in :user, @user1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has working context' do
|
it 'has working context' do
|
||||||
photo1.url.should_not be_nil
|
@photo1.url.should_not be_nil
|
||||||
Photo.find(photo1.id).url.should_not be_nil
|
Photo.find(@photo1.id).url.should_not be_nil
|
||||||
photo2.url.should_not be_nil
|
@photo2.url.should_not be_nil
|
||||||
Photo.find(photo2.id).url.should_not be_nil
|
Photo.find(@photo2.id).url.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
before do
|
before do
|
||||||
@controller.stub!(:file_handler).and_return(File.open(fixture_name))
|
@controller.stub!(:file_handler).and_return(uploaded_photo)
|
||||||
@params = {:photo => {:user_file => File.open(fixture_name), :aspect_ids => "all"} }
|
@params = {:photo => {:user_file => uploaded_photo, :aspect_ids => "all"} }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can make a photo' do
|
it 'can make a photo' do
|
||||||
|
|
@ -44,100 +40,100 @@ describe PhotosController do
|
||||||
}.should change(Photo, :count).by(1)
|
}.should change(Photo, :count).by(1)
|
||||||
end
|
end
|
||||||
it 'can set the photo as the profile photo' do
|
it 'can set the photo as the profile photo' do
|
||||||
old_url = user1.person.profile.image_url
|
old_url = @user1.person.profile.image_url
|
||||||
@params[:photo][:set_profile_photo] = true
|
@params[:photo][:set_profile_photo] = true
|
||||||
post :create, @params
|
post :create, @params
|
||||||
user1.reload.person.profile.image_url.should_not == old_url
|
@user1.reload.person.profile.image_url.should_not == old_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
it "displays the logged in user's pictures" do
|
it "displays the logged in user's pictures" do
|
||||||
get :index, :person_id => user1.person.id.to_s
|
get :index, :person_id => @user1.person.id.to_s
|
||||||
assigns[:person].should == user1.person
|
assigns[:person].should == @user1.person
|
||||||
assigns[:posts].should == [photo1]
|
assigns[:posts].should == [@photo1]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "displays another person's pictures" do
|
it "displays another person's pictures" do
|
||||||
get :index, :person_id => user2.person.id.to_s
|
get :index, :person_id => @user2.person.id.to_s
|
||||||
|
|
||||||
assigns[:person].should == user2.person
|
assigns[:person].should == @user2.person
|
||||||
assigns[:posts].should == [photo2]
|
assigns[:posts].should == [@photo2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
it 'assigns the photo based on the photo id' do
|
it 'assigns the photo based on the photo id' do
|
||||||
get :show, :id => photo1.id
|
get :show, :id => @photo1.id
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
|
|
||||||
assigns[:photo].should == photo1
|
assigns[:photo].should == @photo1
|
||||||
assigns[:ownership].should be_true
|
assigns[:ownership].should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders a show page for another user's photo" do
|
it "renders a show page for another user's photo" do
|
||||||
get :show, :id => photo2.id
|
get :show, :id => @photo2.id
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
|
|
||||||
assigns[:photo].should == photo2
|
assigns[:photo].should == @photo2
|
||||||
assigns[:ownership].should be_false
|
assigns[:ownership].should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#edit' do
|
describe '#edit' do
|
||||||
it 'lets the user edit a photo' do
|
it 'lets the user edit a photo' do
|
||||||
get :edit, :id => photo1.id
|
get :edit, :id => @photo1.id
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not let the user edit a photo that is not his' do
|
it 'does not let the user edit a photo that is not his' do
|
||||||
get :edit, :id => photo2.id
|
get :edit, :id => @photo2.id
|
||||||
response.should redirect_to(:action => :index, :person_id => user1.person.id.to_s)
|
response.should redirect_to(:action => :index, :person_id => @user1.person.id.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
it 'allows the user to delete his photos' do
|
it 'allows the user to delete his photos' do
|
||||||
delete :destroy, :id => photo1.id
|
delete :destroy, :id => @photo1.id
|
||||||
Photo.find_by_id(photo1.id).should be_nil
|
Photo.find_by_id(@photo1.id).should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'will not let you destory posts you do not own' do
|
it 'will not let you destory posts you do not own' do
|
||||||
delete :destroy, :id => photo2.id
|
delete :destroy, :id => @photo2.id
|
||||||
Photo.find_by_id(photo2.id).should be_true
|
Photo.find_by_id(@photo2.id).should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#update" do
|
describe "#update" do
|
||||||
it "updates the caption of a photo" do
|
it "updates the caption of a photo" do
|
||||||
put :update, :id => photo1.id, :photo => { :caption => "now with lasers!" }
|
put :update, :id => @photo1.id, :photo => { :caption => "now with lasers!" }
|
||||||
photo1.reload.caption.should == "now with lasers!"
|
@photo1.reload.caption.should == "now with lasers!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite random attributes" do
|
it "doesn't overwrite random attributes" do
|
||||||
new_user = Factory.create(:user)
|
new_user = Factory.create(:user)
|
||||||
params = { :caption => "now with lasers!", :person_id => new_user.id }
|
params = { :caption => "now with lasers!", :person_id => new_user.id }
|
||||||
put :update, :id => photo1.id, :photo => params
|
put :update, :id => @photo1.id, :photo => params
|
||||||
photo1.reload.person_id.should == user1.person.id
|
@photo1.reload.person_id.should == @user1.person.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects if you do not have access to the post' do
|
it 'redirects if you do not have access to the post' do
|
||||||
params = { :caption => "now with lasers!" }
|
params = { :caption => "now with lasers!" }
|
||||||
put :update, :id => photo2.id, :photo => params
|
put :update, :id => @photo2.id, :photo => params
|
||||||
response.should redirect_to(:action => :index, :person_id => user1.person.id.to_s)
|
response.should redirect_to(:action => :index, :person_id => @user1.person.id.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#make_profile_photo" do
|
describe "#make_profile_photo" do
|
||||||
|
|
||||||
it 'should return a 201 on a js success' do
|
it 'should return a 201 on a js success' do
|
||||||
get :make_profile_photo, :photo_id => photo1.id, :format => 'js'
|
get :make_profile_photo, :photo_id => @photo1.id, :format => 'js'
|
||||||
response.code.should == "201"
|
response.code.should == "201"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return a 406 on failure' do
|
it 'should return a 406 on failure' do
|
||||||
get :make_profile_photo, :photo_id => photo2.id
|
get :make_profile_photo, :photo_id => @photo2.id
|
||||||
response.code.should == "406"
|
response.code.should == "406"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,21 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe PostsController do
|
describe PostsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@controller.stub!(:current_user).and_return(nil)
|
@controller.stub!(:current_user).and_return(nil)
|
||||||
end
|
end
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
it 'shows a public post' do
|
it 'shows a public post' do
|
||||||
status = @user.post(:status_message, :message => "hello", :public => true, :to => 'all')
|
status = @user.post(:status_message, :message => "hello", :public => true, :to => 'all')
|
||||||
|
|
||||||
get :show, :id => status.id
|
get :show, :id => status.id
|
||||||
response.status= 200
|
response.status= 200
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not show a private post' do
|
it 'does not show a private post' do
|
||||||
status = @user.post(:status_message, :message => "hello", :public => false, :to => 'all')
|
status = @user.post(:status_message, :message => "hello", :public => false, :to => 'all')
|
||||||
get :show, :id => status.id
|
get :show, :id => status.id
|
||||||
response.status = 302
|
response.status = 302
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,60 +7,62 @@ require 'spec_helper'
|
||||||
describe PublicsController do
|
describe PublicsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Factory.create(:user) }
|
before do
|
||||||
let(:person) { Factory(:person) }
|
@user = alice
|
||||||
|
@person = Factory(:person)
|
||||||
|
end
|
||||||
|
|
||||||
describe '#receive' do
|
describe '#receive' do
|
||||||
let(:xml) { "<walruses></walruses>" }
|
let(:xml) { "<walruses></walruses>" }
|
||||||
|
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
post :receive, "id" => user.person.id.to_s, "xml" => xml
|
post :receive, "id" => @user.person.id.to_s, "xml" => xml
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enqueues a receive job' do
|
it 'enqueues a receive job' do
|
||||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, xml).once
|
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, @user.id, xml).once
|
||||||
post :receive, "id" => user.person.id.to_s, "xml" => xml
|
post :receive, "id" => @user.person.id.to_s, "xml" => xml
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'unescapes the xml before sending it to receive_salmon' do
|
it 'unescapes the xml before sending it to receive_salmon' do
|
||||||
aspect = user.aspects.create(:name => 'foo')
|
aspect = @user.aspects.create(:name => 'foo')
|
||||||
post1 = user.post(:status_message, :message => 'moms', :to => [aspect.id])
|
post1 = @user.post(:status_message, :message => 'moms', :to => [aspect.id])
|
||||||
xml2 = post1.to_diaspora_xml
|
xml2 = post1.to_diaspora_xml
|
||||||
user2 = Factory(:user)
|
user2 = Factory(:user)
|
||||||
|
|
||||||
salmon_factory = Salmon::SalmonSlap.create(user, xml2)
|
salmon_factory = Salmon::SalmonSlap.create(@user, xml2)
|
||||||
enc_xml = salmon_factory.xml_for(user2.person)
|
enc_xml = salmon_factory.xml_for(user2.person)
|
||||||
|
|
||||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, enc_xml).once
|
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, @user.id, enc_xml).once
|
||||||
|
|
||||||
post :receive, "id" => user.person.id.to_s, "xml" => CGI::escape(enc_xml)
|
post :receive, "id" => @user.person.id.to_s, "xml" => CGI::escape(enc_xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a 422 if no xml is passed' do
|
it 'returns a 422 if no xml is passed' do
|
||||||
post :receive, "id" => person.id.to_s
|
post :receive, "id" => @person.id.to_s
|
||||||
response.code.should == '422'
|
response.code.should == '422'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a 404 if no user is found' do
|
it 'returns a 404 if no user is found' do
|
||||||
post :receive, "id" => person.id.to_s, "xml" => xml
|
post :receive, "id" => @person.id.to_s, "xml" => xml
|
||||||
response.should be_not_found
|
response.should be_not_found
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#hcard' do
|
describe '#hcard' do
|
||||||
it "succeeds" do
|
it "succeeds" do
|
||||||
post :hcard, "id" => user.person.id.to_s
|
post :hcard, "id" => @user.person.id.to_s
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the person' do
|
it 'sets the person' do
|
||||||
post :hcard, "id" => user.person.id.to_s
|
post :hcard, "id" => @user.person.id.to_s
|
||||||
assigns[:person].should == user.person
|
assigns[:person].should == @user.person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not query by user id' do
|
it 'does not query by user id' do
|
||||||
post :hcard, "id" => user.id.to_s
|
post :hcard, "id" => 90348257609247856.to_s
|
||||||
assigns[:person].should be_nil
|
assigns[:person].should be_nil
|
||||||
response.should be_not_found
|
response.should be_not_found
|
||||||
end
|
end
|
||||||
|
|
@ -68,8 +70,7 @@ describe PublicsController do
|
||||||
|
|
||||||
describe '#webfinger' do
|
describe '#webfinger' do
|
||||||
it "succeeds when the person and user exist locally" do
|
it "succeeds when the person and user exist locally" do
|
||||||
user = Factory.create(:user)
|
post :webfinger, 'q' => @user.person.diaspora_handle
|
||||||
post :webfinger, 'q' => user.person.diaspora_handle
|
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -80,8 +81,7 @@ describe PublicsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "404s when the person is local but doesn't have an owner" do
|
it "404s when the person is local but doesn't have an owner" do
|
||||||
person = Factory(:person)
|
post :webfinger, 'q' => @person.diaspora_handle
|
||||||
post :webfinger, 'q' => person.diaspora_handle
|
|
||||||
response.should be_not_found
|
response.should be_not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,12 @@ require 'spec_helper'
|
||||||
describe RequestsController do
|
describe RequestsController do
|
||||||
render_views
|
render_views
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
|
@other_user = eve
|
||||||
|
|
||||||
@controller.stub!(:current_user).and_return(@user)
|
@controller.stub!(:current_user).and_return(@user)
|
||||||
sign_in :user, @user
|
sign_in :user, @user
|
||||||
request.env["HTTP_REFERER"] = "http://test.host"
|
request.env["HTTP_REFERER"] = "http://test.host"
|
||||||
|
|
||||||
@user.aspects.create!(:name => "lame-os")
|
|
||||||
@user.reload
|
|
||||||
|
|
||||||
@other_user = Factory.create(:user)
|
|
||||||
@other_user.aspects.create!(:name => "meh")
|
|
||||||
@other_user.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe ServicesController do
|
describe ServicesController do
|
||||||
render_views
|
render_views
|
||||||
let(:user) { Factory.create(:user) }
|
|
||||||
let!(:aspect) { user.aspects.create(:name => "lame-os") }
|
|
||||||
|
|
||||||
|
|
||||||
let(:mock_access_token) { Object.new }
|
let(:mock_access_token) { Object.new }
|
||||||
|
|
||||||
let(:omniauth_auth) {
|
let(:omniauth_auth) {
|
||||||
|
|
@ -21,20 +17,22 @@ describe ServicesController do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in :user, user
|
@user = alice
|
||||||
@controller.stub!(:current_user).and_return(user)
|
@aspect = @user.aspects.first
|
||||||
|
|
||||||
|
sign_in :user, @user
|
||||||
|
@controller.stub!(:current_user).and_return(@user)
|
||||||
mock_access_token.stub!(:token => "12345", :secret => "56789")
|
mock_access_token.stub!(:token => "12345", :secret => "56789")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
let!(:service1) {a = Factory(:service); user.services << a; a}
|
|
||||||
let!(:service2) {a = Factory(:service); user.services << a; a}
|
|
||||||
let!(:service3) {a = Factory(:service); user.services << a; a}
|
|
||||||
let!(:service4) {a = Factory(:service); user.services << a; a}
|
|
||||||
|
|
||||||
it 'displays all connected serivices for a user' do
|
it 'displays all connected serivices for a user' do
|
||||||
|
4.times do
|
||||||
|
@user.services << Factory(:service)
|
||||||
|
end
|
||||||
|
|
||||||
get :index
|
get :index
|
||||||
assigns[:services].should == user.services
|
assigns[:services].should == @user.services
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -43,18 +41,18 @@ describe ServicesController do
|
||||||
request.env['omniauth.auth'] = omniauth_auth
|
request.env['omniauth.auth'] = omniauth_auth
|
||||||
lambda{
|
lambda{
|
||||||
post :create
|
post :create
|
||||||
}.should change(user.services, :count).by(1)
|
}.should change(@user.services, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to getting started if the user is getting started' do
|
it 'redirects to getting started if the user is getting started' do
|
||||||
user.getting_started = true
|
@user.getting_started = true
|
||||||
request.env['omniauth.auth'] = omniauth_auth
|
request.env['omniauth.auth'] = omniauth_auth
|
||||||
post :create
|
post :create
|
||||||
response.should redirect_to getting_started_path(:step => 3)
|
response.should redirect_to getting_started_path(:step => 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to services url' do
|
it 'redirects to services url' do
|
||||||
user.getting_started = false
|
@user.getting_started = false
|
||||||
request.env['omniauth.auth'] = omniauth_auth
|
request.env['omniauth.auth'] = omniauth_auth
|
||||||
post :create
|
post :create
|
||||||
response.should redirect_to services_url
|
response.should redirect_to services_url
|
||||||
|
|
@ -63,23 +61,22 @@ describe ServicesController do
|
||||||
|
|
||||||
it 'creates a twitter service' do
|
it 'creates a twitter service' do
|
||||||
Service.delete_all
|
Service.delete_all
|
||||||
user.getting_started = false
|
@user.getting_started = false
|
||||||
request.env['omniauth.auth'] = omniauth_auth
|
request.env['omniauth.auth'] = omniauth_auth
|
||||||
post :create
|
post :create
|
||||||
user.reload
|
@user.reload.services.first.class.name.should == "Services::Twitter"
|
||||||
user.services.first.class.name.should == "Services::Twitter"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
before do
|
before do
|
||||||
@service1 = Factory.create(:service)
|
@service1 = Factory.create(:service)
|
||||||
user.services << @service1
|
@user.services << @service1
|
||||||
end
|
end
|
||||||
it 'destroys a service selected by id' do
|
it 'destroys a service selected by id' do
|
||||||
lambda{
|
lambda{
|
||||||
delete :destroy, :id => @service1.id
|
delete :destroy, :id => @service1.id
|
||||||
}.should change(user.services, :count).by(-1)
|
}.should change(@user.services, :count).by(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ EOT
|
||||||
describe SocketsController do
|
describe SocketsController do
|
||||||
render_views
|
render_views
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@controller = SocketsController.new
|
@controller = SocketsController.new
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'actionhash' do
|
describe 'actionhash' do
|
||||||
before do
|
before do
|
||||||
@aspect = @user.aspects.create(:name => "losers")
|
@aspect = @user.aspects.first
|
||||||
@message = @user.post :status_message, :message => "post through user for victory", :to => @aspect.id
|
@message = @user.post :status_message, :message => "post through user for victory", :to => @aspect.id
|
||||||
@fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
|
@fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,25 @@ require 'spec_helper'
|
||||||
describe StatusMessagesController do
|
describe StatusMessagesController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let!(:user1) { Factory.create(:user) }
|
|
||||||
let!(:aspect1) { user1.aspects.create(:name => "AWESOME!!") }
|
|
||||||
|
|
||||||
let!(:user2) { Factory.create(:user) }
|
|
||||||
let!(:aspect2) { user2.aspects.create(:name => "WIN!!") }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
connect_users(user1, aspect1, user2, aspect2)
|
@user1 = alice
|
||||||
|
@user2 = bob
|
||||||
|
|
||||||
|
@aspect1 = @user1.aspects.first
|
||||||
|
@aspect2 = @user2.aspects.first
|
||||||
|
|
||||||
request.env["HTTP_REFERER"] = ""
|
request.env["HTTP_REFERER"] = ""
|
||||||
sign_in :user, user1
|
sign_in :user, @user1
|
||||||
@controller.stub!(:current_user).and_return(user1)
|
@controller.stub!(:current_user).and_return(@user1)
|
||||||
user1.reload
|
@user1.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
message = user1.build_post :status_message, :message => "ohai", :to => aspect1.id
|
message = @user1.build_post :status_message, :message => "ohai", :to => @aspect1.id
|
||||||
message.save!
|
message.save!
|
||||||
user1.add_to_streams(message, [aspect1])
|
@user1.add_to_streams(message, [@aspect1])
|
||||||
user1.dispatch_post message, :to => aspect1.id
|
@user1.dispatch_post message, :to => @aspect1.id
|
||||||
|
|
||||||
get :show, "id" => message.id.to_s
|
get :show, "id" => message.id.to_s
|
||||||
response.should be_success
|
response.should be_success
|
||||||
|
|
@ -39,7 +38,7 @@ describe StatusMessagesController do
|
||||||
:public => "true",
|
:public => "true",
|
||||||
:message => "facebook, is that you?",
|
:message => "facebook, is that you?",
|
||||||
},
|
},
|
||||||
:aspect_ids => [aspect1.id.to_s] }
|
:aspect_ids => [@aspect1.id.to_s] }
|
||||||
}
|
}
|
||||||
it 'responds to js requests' do
|
it 'responds to js requests' do
|
||||||
post :create, status_message_hash.merge(:format => 'js')
|
post :create, status_message_hash.merge(:format => 'js')
|
||||||
|
|
@ -47,14 +46,14 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite person_id" do
|
it "doesn't overwrite person_id" do
|
||||||
status_message_hash[:status_message][:person_id] = user2.person.id
|
status_message_hash[:status_message][:person_id] = @user2.person.id
|
||||||
post :create, status_message_hash
|
post :create, status_message_hash
|
||||||
new_message = StatusMessage.find_by_message(status_message_hash[:status_message][:message])
|
new_message = StatusMessage.find_by_message(status_message_hash[:status_message][:message])
|
||||||
new_message.person_id.should == user1.person.id
|
new_message.person_id.should == @user1.person.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite id" do
|
it "doesn't overwrite id" do
|
||||||
old_status_message = user1.post(:status_message, :message => "hello", :to => aspect1.id)
|
old_status_message = @user1.post(:status_message, :message => "hello", :to => @aspect1.id)
|
||||||
status_message_hash[:status_message][:id] = old_status_message.id
|
status_message_hash[:status_message][:id] = old_status_message.id
|
||||||
post :create, status_message_hash
|
post :create, status_message_hash
|
||||||
old_status_message.reload.message.should == 'hello'
|
old_status_message.reload.message.should == 'hello'
|
||||||
|
|
@ -65,8 +64,8 @@ describe StatusMessagesController do
|
||||||
fixture_filename = 'button.png'
|
fixture_filename = 'button.png'
|
||||||
fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', fixture_filename)
|
fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', fixture_filename)
|
||||||
|
|
||||||
@photo1 = user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => aspect1.id)
|
@photo1 = @user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => @aspect1.id)
|
||||||
@photo2 = user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => aspect1.id)
|
@photo2 = @user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => @aspect1.id)
|
||||||
|
|
||||||
@photo1.save!
|
@photo1.save!
|
||||||
@photo2.save!
|
@photo2.save!
|
||||||
|
|
@ -75,7 +74,7 @@ describe StatusMessagesController do
|
||||||
@hash[:photos] = [@photo1.id.to_s, @photo2.id.to_s]
|
@hash[:photos] = [@photo1.id.to_s, @photo2.id.to_s]
|
||||||
end
|
end
|
||||||
it "dispatches all referenced photos" do
|
it "dispatches all referenced photos" do
|
||||||
user1.should_receive(:dispatch_post).exactly(3).times
|
@user1.should_receive(:dispatch_post).exactly(3).times
|
||||||
post :create, @hash
|
post :create, @hash
|
||||||
end
|
end
|
||||||
it "sets the pending bit of referenced photos" do
|
it "sets the pending bit of referenced photos" do
|
||||||
|
|
@ -87,8 +86,8 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
let!(:message) {user1.post(:status_message, :message => "hey", :to => aspect1.id)}
|
let!(:message) {@user1.post(:status_message, :message => "hey", :to => @aspect1.id)}
|
||||||
let!(:message2) {user2.post(:status_message, :message => "hey", :to => aspect2.id)}
|
let!(:message2) {@user2.post(:status_message, :message => "hey", :to => @aspect2.id)}
|
||||||
|
|
||||||
it 'let a user delete his photos' do
|
it 'let a user delete his photos' do
|
||||||
delete :destroy, :id => message.id
|
delete :destroy, :id => message.id
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ require 'spec_helper'
|
||||||
describe UsersController do
|
describe UsersController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Factory.create(:user) }
|
let(:user) { alice }
|
||||||
let!(:aspect) { user.aspects.create(:name => "lame-os") }
|
let!(:aspect) { user.aspects.first }
|
||||||
|
|
||||||
let!(:old_password) { user.encrypted_password }
|
let!(:old_password) { user.encrypted_password }
|
||||||
let!(:old_language) { user.language }
|
let!(:old_language) { user.language }
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe ApplicationHelper do
|
describe ApplicationHelper do
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@person = Factory.create(:person)
|
@person = Factory.create(:person)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ describe ApplicationHelper do
|
||||||
person_image_link(@person).should include(person_path(@person))
|
person_image_link(@person).should include(person_path(@person))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#person_image_tag" do
|
describe "#person_image_tag" do
|
||||||
it "should not allow basic XSS/HTML" do
|
it "should not allow basic XSS/HTML" do
|
||||||
@person.profile.first_name = "I'm <h1>Evil"
|
@person.profile.first_name = "I'm <h1>Evil"
|
||||||
|
|
@ -176,7 +176,7 @@ describe ApplicationHelper do
|
||||||
message = '[link text](http://someurl.com "some title") [link text](http://someurl.com "some title")'
|
message = '[link text](http://someurl.com "some title") [link text](http://someurl.com "some title")'
|
||||||
markdownify(message).should == '<a target="_blank" href="http://someurl.com" title="some title">link text</a> <a target="_blank" href="http://someurl.com" title="some title">link text</a>'
|
markdownify(message).should == '<a target="_blank" href="http://someurl.com" title="some title">link text</a> <a target="_blank" href="http://someurl.com" title="some title">link text</a>'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have a robust link parsing" do
|
it "should have a robust link parsing" do
|
||||||
message = "This [*text*](http://en.wikipedia.org/wiki/Text_(literary_theory)) with many [links](google.com) tests [_http_](http://google.com/search?q=with_multiple__underscores*and**asterisks), [___FTP___](ftp://ftp.uni-kl.de/CCC/26C3/mp4/26c3-3540-en-a_hackers_utopia.mp4 \"File Transfer Protocol\"), [**any protocol**](foo://bar.example.org/yes_it*makes*no_sense)"
|
message = "This [*text*](http://en.wikipedia.org/wiki/Text_(literary_theory)) with many [links](google.com) tests [_http_](http://google.com/search?q=with_multiple__underscores*and**asterisks), [___FTP___](ftp://ftp.uni-kl.de/CCC/26C3/mp4/26c3-3540-en-a_hackers_utopia.mp4 \"File Transfer Protocol\"), [**any protocol**](foo://bar.example.org/yes_it*makes*no_sense)"
|
||||||
markdownify(message).should == 'This <a target="_blank" href="http://en.wikipedia.org/wiki/Text_(literary_theory)"><em>text</em></a> with many <a target="_blank" href="http://google.com">links</a> tests <a target="_blank" href="http://google.com/search?q=with_multiple__underscores*and**asterisks"><em>http</em></a>, <a target="_blank" href="ftp://ftp.uni-kl.de/CCC/26C3/mp4/26c3-3540-en-a_hackers_utopia.mp4" title="File Transfer Protocol"><em><strong>FTP</strong></em></a>, <a target="_blank" href="foo://bar.example.org/yes_it*makes*no_sense"><strong>any protocol</strong></a>'
|
markdownify(message).should == 'This <a target="_blank" href="http://en.wikipedia.org/wiki/Text_(literary_theory)"><em>text</em></a> with many <a target="_blank" href="http://google.com">links</a> tests <a target="_blank" href="http://google.com/search?q=with_multiple__underscores*and**asterisks"><em>http</em></a>, <a target="_blank" href="ftp://ftp.uni-kl.de/CCC/26C3/mp4/26c3-3540-en-a_hackers_utopia.mp4" title="File Transfer Protocol"><em><strong>FTP</strong></em></a>, <a target="_blank" href="foo://bar.example.org/yes_it*makes*no_sense"><strong>any protocol</strong></a>'
|
||||||
|
|
@ -199,7 +199,7 @@ describe ApplicationHelper do
|
||||||
it 'skips inserting newlines if you pass the newlines option' do
|
it 'skips inserting newlines if you pass the newlines option' do
|
||||||
message = "These\nare\n\some\nnew\lines"
|
message = "These\nare\n\some\nnew\lines"
|
||||||
res = markdownify(message, :newlines => false)
|
res = markdownify(message, :newlines => false)
|
||||||
res.should == message
|
res.should == message
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates breaklines' do
|
it 'generates breaklines' do
|
||||||
|
|
@ -207,7 +207,7 @@ describe ApplicationHelper do
|
||||||
res = markdownify(message)
|
res = markdownify(message)
|
||||||
res.should == "These<br /\>are<br /\>some<br /\>new<br /\>lines"
|
res.should == "These<br /\>are<br /\>some<br /\>new<br /\>lines"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should render newlines and basic http links correctly' do
|
it 'should render newlines and basic http links correctly' do
|
||||||
message = "Some text, then a line break and a link\nhttp://joindiaspora.com\nsome more text"
|
message = "Some text, then a line break and a link\nhttp://joindiaspora.com\nsome more text"
|
||||||
res = markdownify(message)
|
res = markdownify(message)
|
||||||
|
|
@ -229,19 +229,19 @@ describe ApplicationHelper do
|
||||||
|
|
||||||
person_link(@person).should include @person.diaspora_handle
|
person_link(@person).should include @person.diaspora_handle
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'uses diaspora handle if first name and first name are rails#blank?' do
|
it 'uses diaspora handle if first name and first name are rails#blank?' do
|
||||||
@person.profile.first_name = " "
|
@person.profile.first_name = " "
|
||||||
@person.profile.last_name = " "
|
@person.profile.last_name = " "
|
||||||
|
|
||||||
person_link(@person).should include @person.diaspora_handle
|
person_link(@person).should include @person.diaspora_handle
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not allow basic XSS/HTML" do
|
it "should not allow basic XSS/HTML" do
|
||||||
@person.profile.first_name = "I'm <h1>Evil"
|
@person.profile.first_name = "I'm <h1>Evil"
|
||||||
@person.profile.last_name = "I'm <h1>Evil"
|
@person.profile.last_name = "I'm <h1>Evil"
|
||||||
person_link(@person).should_not include("<h1>")
|
person_link(@person).should_not include("<h1>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'performance' do
|
context 'performance' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe RequestsHelper do
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
#
|
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe SocketsHelper do
|
|
||||||
end
|
|
||||||
|
|
@ -2,12 +2,12 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe StreamHelper do
|
describe StreamHelper do
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => 'aspect')
|
@aspect = @user.aspects.first
|
||||||
@post = @user.post(:status_message, :message => "hi", :to => @aspect.id)
|
@post = @user.post(:status_message, :message => "hi", :to => @aspect.id)
|
||||||
end
|
end
|
||||||
it 'renders a new comment form' do
|
it 'renders a new comment form' do
|
||||||
new_comment_form(@post.id).should ==
|
new_comment_form(@post.id).should ==
|
||||||
@controller.render_to_string(:partial => 'comments/new_comment', :locals => {:post_id => @post.id})
|
@controller.render_to_string(:partial => 'comments/new_comment', :locals => {:post_id => @post.id})
|
||||||
end
|
end
|
||||||
it 'renders it fast the second time' do
|
it 'renders it fast the second time' do
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,17 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe UsersHelper do
|
describe UsersHelper do
|
||||||
describe '#first_name_or_username' do
|
describe '#first_name_or_username' do
|
||||||
let(:user){ Factory(:user) }
|
before do
|
||||||
|
@user = alice
|
||||||
|
end
|
||||||
|
|
||||||
it 'should display the first name if it is set' do
|
it 'should display the first name if it is set' do
|
||||||
first_name_or_username(user).should == user.person.profile.first_name
|
first_name_or_username(@user).should == @user.person.profile.first_name
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should display the username if the first name is empty' do
|
it 'should display the username if the first name is empty' do
|
||||||
user.person.profile.first_name = ""
|
@user.person.profile.first_name = ""
|
||||||
first_name_or_username(user).should == user.username
|
first_name_or_username(@user).should == @user.username
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,73 +6,72 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe 'a user receives a post' do
|
describe 'a user receives a post' do
|
||||||
|
|
||||||
let(:user) { Factory.create(:user) }
|
|
||||||
let(:aspect) { user.aspects.create(:name => 'heroes') }
|
|
||||||
|
|
||||||
let(:user2) { Factory.create(:user) }
|
|
||||||
let(:aspect2) { user2.aspects.create(:name => 'losers') }
|
|
||||||
|
|
||||||
let(:user3) { Factory.create(:user) }
|
|
||||||
let(:aspect3) { user3.aspects.create(:name => 'heroes') }
|
|
||||||
|
|
||||||
def receive_with_zord(user, person, xml)
|
def receive_with_zord(user, person, xml)
|
||||||
zord = Postzord::Receiver.new(user, :person => person)
|
zord = Postzord::Receiver.new(user, :person => person)
|
||||||
zord.parse_and_receive(xml)
|
zord.parse_and_receive(xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
connect_users(user, aspect, user2, aspect2)
|
@user1 = alice
|
||||||
|
@aspect = @user1.aspects.first
|
||||||
|
|
||||||
|
@user2 = bob
|
||||||
|
@aspect2 = @user2.aspects.first
|
||||||
|
|
||||||
|
@user3 = eve
|
||||||
|
@aspect3 = @user3.aspects.first
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do
|
it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do
|
||||||
contact = user.contact_for(user2.person)
|
contact = @user1.contact_for(@user2.person)
|
||||||
user.add_contact_to_aspect(contact, user.aspects.create(:name => "villains"))
|
@user1.add_contact_to_aspect(contact, @user1.aspects.create(:name => "villains"))
|
||||||
status = user2.build_post(:status_message, :message => "Users do things", :to => aspect2.id)
|
status = @user2.build_post(:status_message, :message => "Users do things", :to => @aspect2.id)
|
||||||
Diaspora::WebSocket.should_receive(:queue_to_user).exactly(:once)
|
Diaspora::WebSocket.should_receive(:queue_to_user).exactly(:once)
|
||||||
zord = Postzord::Receiver.new(user, :object => status, :person => user2.person)
|
zord = Postzord::Receiver.new(@user1, :object => status, :person => @user2.person)
|
||||||
zord.receive_object
|
zord.receive_object
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to parse and store a status message from xml' do
|
it 'should be able to parse and store a status message from xml' do
|
||||||
status_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id
|
status_message = @user2.post :status_message, :message => 'store this!', :to => @aspect2.id
|
||||||
|
|
||||||
xml = status_message.to_diaspora_xml
|
xml = status_message.to_diaspora_xml
|
||||||
user2.delete
|
@user2.delete
|
||||||
status_message.destroy
|
status_message.destroy
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
receive_with_zord(user, user2.person, xml)
|
receive_with_zord(@user1, @user2.person, xml)
|
||||||
}.should change(Post,:count).by(1)
|
}.should change(Post,:count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not create new aspects on message receive' do
|
it 'should not create new aspects on message receive' do
|
||||||
num_aspects = user.aspects.size
|
num_aspects = @user1.aspects.size
|
||||||
|
|
||||||
2.times do |n|
|
2.times do |n|
|
||||||
status_message = user2.post :status_message, :message => "store this #{n}!", :to => aspect2.id
|
status_message = @user2.post :status_message, :message => "store this #{n}!", :to => @aspect2.id
|
||||||
end
|
end
|
||||||
|
|
||||||
user.aspects.size.should == num_aspects
|
@user1.aspects.size.should == num_aspects
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'update posts' do
|
context 'update posts' do
|
||||||
it 'does not update posts not marked as mutable' do
|
it 'does not update posts not marked as mutable' do
|
||||||
status = user.post :status_message, :message => "store this!", :to => aspect.id
|
status = @user1.post :status_message, :message => "store this!", :to => @aspect.id
|
||||||
status.message = 'foo'
|
status.message = 'foo'
|
||||||
xml = status.to_diaspora_xml
|
xml = status.to_diaspora_xml
|
||||||
|
|
||||||
receive_with_zord(user2, user.person, xml)
|
receive_with_zord(@user2, @user1.person, xml)
|
||||||
|
|
||||||
status.reload.message.should == 'store this!'
|
status.reload.message.should == 'store this!'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates posts marked as mutable' do
|
it 'updates posts marked as mutable' do
|
||||||
photo = user.post(:photo, :user_file => uploaded_photo, :caption => "Original", :to => aspect.id)
|
photo = @user1.post(:photo, :user_file => uploaded_photo, :caption => "Original", :to => @aspect.id)
|
||||||
photo.caption = 'foo'
|
photo.caption = 'foo'
|
||||||
xml = photo.to_diaspora_xml
|
xml = photo.to_diaspora_xml
|
||||||
user2.reload
|
@user2.reload
|
||||||
|
|
||||||
receive_with_zord(user2, user.person, xml)
|
receive_with_zord(@user2, @user1.person, xml)
|
||||||
|
|
||||||
photo.reload.caption.should match(/foo/)
|
photo.reload.caption.should match(/foo/)
|
||||||
end
|
end
|
||||||
|
|
@ -80,115 +79,116 @@ describe 'a user receives a post' do
|
||||||
|
|
||||||
describe 'post refs' do
|
describe 'post refs' do
|
||||||
before do
|
before do
|
||||||
@status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
@status_message = @user2.post :status_message, :message => "hi", :to => @aspect2.id
|
||||||
user.reload
|
@user1.reload
|
||||||
aspect.reload
|
@aspect.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds a received post to the aspect and visible_posts array" do
|
it "adds a received post to the aspect and visible_posts array" do
|
||||||
user.raw_visible_posts.include?(@status_message).should be_true
|
@user1.raw_visible_posts.include?(@status_message).should be_true
|
||||||
aspect.posts.include?(@status_message).should be_true
|
@aspect.posts.include?(@status_message).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes posts upon disconnecting' do
|
it 'removes posts upon disconnecting' do
|
||||||
user.disconnect(user2.person)
|
@user1.disconnect(@user2.person)
|
||||||
user.reload
|
@user1.reload
|
||||||
user.raw_visible_posts.should_not include @status_message
|
@user1.raw_visible_posts.should_not include @status_message
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes a post if the noone links to it' do
|
it 'deletes a post if the noone links to it' do
|
||||||
person = Factory(:person)
|
person = Factory(:person)
|
||||||
user.activate_contact(person, aspect)
|
@user1.activate_contact(person, @aspect)
|
||||||
post = Factory.create(:status_message, :person => person)
|
post = Factory.create(:status_message, :person => person)
|
||||||
post.post_visibilities.should be_empty
|
post.post_visibilities.should be_empty
|
||||||
receive_with_zord(user, person, post.to_diaspora_xml)
|
receive_with_zord(@user1, person, post.to_diaspora_xml)
|
||||||
aspect.post_visibilities.reset
|
@aspect.post_visibilities.reset
|
||||||
aspect.posts(true).should include(post)
|
@aspect.posts(true).should include(post)
|
||||||
post.post_visibilities.reset
|
post.post_visibilities.reset
|
||||||
post.post_visibilities.length.should == 1
|
post.post_visibilities.length.should == 1
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
user.disconnected_by(person)
|
@user1.disconnected_by(person)
|
||||||
}.should change(Post, :count).by(-1)
|
}.should change(Post, :count).by(-1)
|
||||||
end
|
end
|
||||||
it 'deletes post_visibilities on disconnected by' do
|
it 'deletes post_visibilities on disconnected by' do
|
||||||
person = Factory(:person)
|
person = Factory(:person)
|
||||||
user.activate_contact(person, aspect)
|
@user1.activate_contact(person, @aspect)
|
||||||
post = Factory.create(:status_message, :person => person)
|
post = Factory.create(:status_message, :person => person)
|
||||||
post.post_visibilities.should be_empty
|
post.post_visibilities.should be_empty
|
||||||
receive_with_zord(user, person, post.to_diaspora_xml)
|
receive_with_zord(@user1, person, post.to_diaspora_xml)
|
||||||
aspect.post_visibilities.reset
|
@aspect.post_visibilities.reset
|
||||||
aspect.posts(true).should include(post)
|
@aspect.posts(true).should include(post)
|
||||||
post.post_visibilities.reset
|
post.post_visibilities.reset
|
||||||
post.post_visibilities.length.should == 1
|
post.post_visibilities.length.should == 1
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
user.disconnected_by(person)
|
@user1.disconnected_by(person)
|
||||||
}.should change{post.post_visibilities(true).count}.by(-1)
|
}.should change{post.post_visibilities(true).count}.by(-1)
|
||||||
end
|
end
|
||||||
it 'should keep track of user references for one person ' do
|
it 'should keep track of user references for one person ' do
|
||||||
@status_message.reload
|
@status_message.reload
|
||||||
@status_message.user_refs.should == 2
|
@status_message.user_refs.should == 3
|
||||||
|
|
||||||
user.disconnect(user2.person)
|
@user1.disconnect(@user2.person)
|
||||||
@status_message.reload
|
@status_message.reload
|
||||||
@status_message.user_refs.should == 1
|
@status_message.user_refs.should == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not override userrefs on receive by another person' do
|
it 'should not override userrefs on receive by another person' do
|
||||||
@status_message.post_visibilities.reset
|
new_user = Factory(:user)
|
||||||
@status_message.user_refs.should == 2
|
|
||||||
|
|
||||||
user3.activate_contact(user2.person, aspect3)
|
|
||||||
xml = @status_message.to_diaspora_xml
|
|
||||||
|
|
||||||
receive_with_zord(user3, user2.person, xml)
|
|
||||||
|
|
||||||
@status_message.post_visibilities.reset
|
@status_message.post_visibilities.reset
|
||||||
@status_message.user_refs.should == 3
|
@status_message.user_refs.should == 3
|
||||||
|
|
||||||
user.disconnect(user2.person)
|
new_user.activate_contact(@user2.person, @aspect3)
|
||||||
|
xml = @status_message.to_diaspora_xml
|
||||||
|
|
||||||
|
receive_with_zord(new_user, @user2.person, xml)
|
||||||
|
|
||||||
@status_message.post_visibilities.reset
|
@status_message.post_visibilities.reset
|
||||||
@status_message.user_refs.should == 2
|
@status_message.user_refs.should == 4
|
||||||
|
|
||||||
|
@user1.disconnect(@user2.person)
|
||||||
|
@status_message.post_visibilities.reset
|
||||||
|
@status_message.user_refs.should == 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'comments' do
|
describe 'comments' do
|
||||||
before do
|
before do
|
||||||
connect_users(user, aspect, user3, aspect3)
|
connect_users(@user1, @aspect, @user3, @aspect3)
|
||||||
@post = user.post :status_message, :message => "hello", :to => aspect.id
|
@post = @user1.post :status_message, :message => "hello", :to => @aspect.id
|
||||||
|
|
||||||
xml = @post.to_diaspora_xml
|
xml = @post.to_diaspora_xml
|
||||||
|
|
||||||
receive_with_zord(user2, user.person, xml)
|
receive_with_zord(@user2, @user1.person, xml)
|
||||||
receive_with_zord(user3, user.person, xml)
|
receive_with_zord(@user3, @user1.person, xml)
|
||||||
|
|
||||||
@comment = user3.comment('tada',:on => @post)
|
@comment = @user3.comment('tada',:on => @post)
|
||||||
@comment.post_creator_signature = @comment.sign_with_key(user.encryption_key)
|
@comment.post_creator_signature = @comment.sign_with_key(@user1.encryption_key)
|
||||||
@xml = @comment.to_diaspora_xml
|
@xml = @comment.to_diaspora_xml
|
||||||
@comment.delete
|
@comment.delete
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should correctly attach the user already on the pod' do
|
it 'should correctly attach the user already on the pod' do
|
||||||
user2.reload.raw_visible_posts.size.should == 1
|
@user2.reload.raw_visible_posts.size.should == 1
|
||||||
post_in_db = StatusMessage.find(@post.id)
|
post_in_db = StatusMessage.find(@post.id)
|
||||||
post_in_db.comments.should == []
|
post_in_db.comments.should == []
|
||||||
receive_with_zord(user2, user.person, @xml)
|
receive_with_zord(@user2, @user1.person, @xml)
|
||||||
|
|
||||||
post_in_db.comments(true).first.person.should == user3.person
|
post_in_db.comments(true).first.person.should == @user3.person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should correctly marshal a stranger for the downstream user' do
|
it 'should correctly marshal a stranger for the downstream user' do
|
||||||
remote_person = user3.person.dup
|
remote_person = @user3.person.dup
|
||||||
user3.person.delete
|
@user3.person.delete
|
||||||
user3.delete
|
@user3.delete
|
||||||
remote_person.id = nil
|
remote_person.id = nil
|
||||||
|
|
||||||
#stubs async webfinger
|
#stubs async webfinger
|
||||||
Person.should_receive(:by_account_identifier).twice.and_return{ |handle|
|
Person.should_receive(:by_account_identifier).twice.and_return{ |handle|
|
||||||
if handle == user.person.diaspora_handle
|
if handle == @user1.person.diaspora_handle
|
||||||
user.person.save
|
@user1.person.save
|
||||||
user.person
|
@user1.person
|
||||||
else
|
else
|
||||||
remote_person.profile = Factory(:profile)
|
remote_person.profile = Factory(:profile)
|
||||||
remote_person.save!
|
remote_person.save!
|
||||||
|
|
@ -196,27 +196,27 @@ describe 'a user receives a post' do
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
user2.reload.raw_visible_posts.size.should == 1
|
@user2.reload.raw_visible_posts.size.should == 1
|
||||||
post_in_db = StatusMessage.find(@post.id)
|
post_in_db = StatusMessage.find(@post.id)
|
||||||
post_in_db.comments.should == []
|
post_in_db.comments.should == []
|
||||||
|
|
||||||
receive_with_zord(user2, user.person, @xml)
|
receive_with_zord(@user2, @user1.person, @xml)
|
||||||
|
|
||||||
post_in_db.comments(true).first.person.should == remote_person
|
post_in_db.comments(true).first.person.should == remote_person
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'salmon' do
|
describe 'salmon' do
|
||||||
let(:post){user.post :status_message, :message => "hello", :to => aspect.id}
|
let(:post){@user1.post :status_message, :message => "hello", :to => @aspect.id}
|
||||||
let(:salmon){user.salmon( post )}
|
let(:salmon){@user1.salmon( post )}
|
||||||
|
|
||||||
it 'processes a salmon for a post' do
|
it 'processes a salmon for a post' do
|
||||||
salmon_xml = salmon.xml_for(user2.person)
|
salmon_xml = salmon.xml_for(@user2.person)
|
||||||
|
|
||||||
zord = Postzord::Receiver.new(user2, :salmon_xml => salmon_xml)
|
zord = Postzord::Receiver.new(@user2, :salmon_xml => salmon_xml)
|
||||||
zord.perform
|
zord.perform
|
||||||
|
|
||||||
user2.raw_visible_posts.include?(post).should be_true
|
@user2.raw_visible_posts.include?(post).should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,18 @@ require File.join(Rails.root, 'lib/diaspora/exporter')
|
||||||
describe Diaspora::Exporter do
|
describe Diaspora::Exporter do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user1 = Factory.create(:user)
|
@user1 = alice
|
||||||
@user2 = Factory.create(:user)
|
@user2 = Factory.create(:user)
|
||||||
@user3 = Factory.create(:user)
|
@user3 = bob
|
||||||
|
|
||||||
@aspect = @user1.aspects.create(:name => "Old Work")
|
@aspect = @user1.aspects.first
|
||||||
@aspect1 = @user1.aspects.create(:name => "Work")
|
@aspect1 = @user1.aspects.create(:name => "Work")
|
||||||
@aspect2 = @user2.aspects.create(:name => "Family")
|
@aspect2 = @user2.aspects.create(:name => "Family")
|
||||||
@aspect3 = @user3.aspects.create(:name => "Pivots")
|
@aspect3 = @user3.aspects.first
|
||||||
|
|
||||||
@status_message1 = @user1.post(:status_message, :message => "One", :public => true, :to => @aspect1.id)
|
@status_message1 = @user1.post(:status_message, :message => "One", :public => true, :to => @aspect1.id)
|
||||||
@status_message2 = @user1.post(:status_message, :message => "Two", :public => true, :to => @aspect1.id)
|
@status_message2 = @user1.post(:status_message, :message => "Two", :public => true, :to => @aspect1.id)
|
||||||
@status_message3 = @user2.post(:status_message, :message => "Three", :public => false, :to => @aspect2.id)
|
@status_message3 = @user2.post(:status_message, :message => "Three", :public => false, :to => @aspect2.id)
|
||||||
|
|
||||||
@user1.reload
|
|
||||||
@user2.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def exported
|
def exported
|
||||||
|
|
@ -50,8 +47,7 @@ describe Diaspora::Exporter do
|
||||||
context '<contacts/>' do
|
context '<contacts/>' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
connect_users(@user1, @aspect1, @user3, @aspect3)
|
@user1.add_contact_to_aspect(@user1.contact_for(@user3.person), @aspect1)
|
||||||
@user1.add_contact_to_aspect(@user1.contact_for(@user3.person), @aspect)
|
|
||||||
@user1.reload
|
@user1.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -71,10 +67,7 @@ describe Diaspora::Exporter do
|
||||||
|
|
||||||
context '<people/>' do
|
context '<people/>' do
|
||||||
let(:people_xml) {exported.xpath('//people').to_s}
|
let(:people_xml) {exported.xpath('//people').to_s}
|
||||||
before do
|
|
||||||
connect_users(@user1, @aspect1, @user3, @aspect3)
|
|
||||||
@user1.reload
|
|
||||||
end
|
|
||||||
it 'should include persons id' do
|
it 'should include persons id' do
|
||||||
people_xml.should include @user3.person.guid
|
people_xml.should include @user3.person.guid
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ require File.join(Rails.root, 'lib/diaspora/ostatus_builder')
|
||||||
|
|
||||||
describe Diaspora::OstatusBuilder do
|
describe Diaspora::OstatusBuilder do
|
||||||
|
|
||||||
let!(:user) { Factory.create(:user) }
|
let!(:user) { alice }
|
||||||
let(:aspect) { user.aspects.create(:name => "Public People") }
|
let(:aspect) { user.aspects.first }
|
||||||
let!(:public_status_messages) {
|
let!(:public_status_messages) {
|
||||||
3.times.inject([]) do |arr,n|
|
3.times.inject([]) do |arr,n|
|
||||||
s = user.post(:status_message, :message => "hey#{n}", :public => true, :to => aspect.id)
|
s = user.post(:status_message, :message => "hey#{n}", :public => true, :to => aspect.id)
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,20 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Diaspora::Parser do
|
describe Diaspora::Parser do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user1 = alice
|
||||||
@aspect = @user.aspects.create(:name => 'spies')
|
@user2 = bob
|
||||||
@user2 = Factory.create(:user)
|
@user3 = eve
|
||||||
@aspect2 = @user2.aspects.create(:name => "pandas")
|
|
||||||
|
@aspect1 = @user1.aspects.first
|
||||||
|
@aspect2 = @user2.aspects.first
|
||||||
|
@aspect3 = @user3.aspects.first
|
||||||
|
|
||||||
@person = Factory.create(:person)
|
@person = Factory.create(:person)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "parsing compliant XML object" do
|
describe "parsing compliant XML object" do
|
||||||
it 'should be able to correctly parse comment fields' do
|
it 'should be able to correctly parse comment fields' do
|
||||||
post = @user.post :status_message, :message => "hello", :to => @aspect.id
|
post = @user1.post :status_message, :message => "hello", :to => @aspect.id
|
||||||
comment = Factory.create(:comment, :post => post, :person => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!")
|
comment = Factory.create(:comment, :post => post, :person => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!")
|
||||||
comment.delete
|
comment.delete
|
||||||
xml = comment.to_diaspora_xml
|
xml = comment.to_diaspora_xml
|
||||||
|
|
@ -26,44 +31,41 @@ describe Diaspora::Parser do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should accept retractions' do
|
it 'should accept retractions' do
|
||||||
connect_users(@user, @aspect, @user2, @aspect2)
|
|
||||||
message = @user2.post(:status_message, :message => "cats", :to => @aspect2.id)
|
message = @user2.post(:status_message, :message => "cats", :to => @aspect2.id)
|
||||||
retraction = Retraction.for(message)
|
retraction = Retraction.for(message)
|
||||||
xml = retraction.to_diaspora_xml
|
xml = retraction.to_diaspora_xml
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
zord = Postzord::Receiver.new(@user, :person => @user2.person)
|
zord = Postzord::Receiver.new(@user1, :person => @user2.person)
|
||||||
zord.parse_and_receive(xml)
|
zord.parse_and_receive(xml)
|
||||||
}.should change(StatusMessage, :count).by(-1)
|
}.should change(StatusMessage, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should activate the Person if I initiated a request to that url" do
|
it "should activate the Person if I initiated a request to that url" do
|
||||||
@user.send_contact_request_to(@user2.person, @aspect)
|
@user1.send_contact_request_to(@user3.person, @aspect)
|
||||||
request = @user2.request_from(@user.person)
|
request = @user3.request_from(@user1.person)
|
||||||
fantasy_resque do
|
fantasy_resque do
|
||||||
@user2.accept_and_respond(request.id, @aspect2.id)
|
@user3.accept_and_respond(request.id, @aspect3.id)
|
||||||
end
|
end
|
||||||
@user.reload
|
@user1.reload
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
new_contact = @user.contact_for(@user2.person)
|
new_contact = @user1.contact_for(@user3.person)
|
||||||
@aspect.contacts.include?(new_contact).should be true
|
@aspect.contacts.include?(new_contact).should be true
|
||||||
@user.contacts.include?(new_contact).should be true
|
@user1.contacts.include?(new_contact).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should process retraction for a person' do
|
it 'should process retraction for a person' do
|
||||||
connect_users(@user, @aspect, @user2, @aspect2)
|
|
||||||
retraction = Retraction.for(@user2)
|
retraction = Retraction.for(@user2)
|
||||||
retraction_xml = retraction.to_diaspora_xml
|
retraction_xml = retraction.to_diaspora_xml
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
zord = Postzord::Receiver.new(@user, :person => @user2.person)
|
zord = Postzord::Receiver.new(@user1, :person => @user2.person)
|
||||||
zord.parse_and_receive(retraction_xml)
|
zord.parse_and_receive(retraction_xml)
|
||||||
}.should change {
|
}.should change {
|
||||||
@aspect.contacts(true).size }.by(-1)
|
@aspect.contacts(true).size }.by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should marshal a profile for a person' do
|
it 'should marshal a profile for a person' do
|
||||||
connect_users(@user, @aspect, @user2, @aspect2)
|
|
||||||
#Create person
|
#Create person
|
||||||
person = @user2.person
|
person = @user2.person
|
||||||
id = person.id
|
id = person.id
|
||||||
|
|
@ -85,7 +87,7 @@ describe Diaspora::Parser do
|
||||||
old_profile.first_name.should == 'bob'
|
old_profile.first_name.should == 'bob'
|
||||||
|
|
||||||
#Marshal profile
|
#Marshal profile
|
||||||
zord = Postzord::Receiver.new(@user, :person => person)
|
zord = Postzord::Receiver.new(@user1, :person => person)
|
||||||
zord.parse_and_receive(xml)
|
zord.parse_and_receive(xml)
|
||||||
|
|
||||||
#Check that marshaled profile is the same as old profile
|
#Check that marshaled profile is the same as old profile
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ end
|
||||||
|
|
||||||
describe Diaspora::Socketable do
|
describe Diaspora::Socketable do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => "losers")
|
@aspect = @user.aspects.first
|
||||||
@post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id)
|
@post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id)
|
||||||
@post.save
|
@post.save
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ describe Diaspora::Webhooks do
|
||||||
class Foo
|
class Foo
|
||||||
include Diaspora::Webhooks
|
include Diaspora::Webhooks
|
||||||
end
|
end
|
||||||
|
|
||||||
f = Foo.new
|
f = Foo.new
|
||||||
|
|
||||||
proc{ f.subscribers(1)}.should raise_error /override subscribers/
|
proc{ f.subscribers(1)}.should raise_error /override subscribers/
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe 'user encryption' do
|
describe 'user encryption' do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => 'dudes')
|
@aspect = @user.aspects.first
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'encryption' do
|
describe 'encryption' do
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ require File.join(Rails.root, 'lib/postzord/dispatch')
|
||||||
|
|
||||||
describe Postzord::Dispatch do
|
describe Postzord::Dispatch do
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@sm = Factory(:status_message, :public => true)
|
@sm = Factory(:status_message, :public => true)
|
||||||
@subscribers = []
|
@subscribers = []
|
||||||
5.times{@subscribers << Factory(:person)}
|
5.times{@subscribers << Factory(:person)}
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,14 @@ require File.join(Rails.root, 'lib/postzord/receiver')
|
||||||
describe Postzord::Receiver do
|
describe Postzord::Receiver do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@user2 = Factory(:user)
|
@user2 = bob
|
||||||
@person2 = @user2.person
|
@person2 = @user2.person
|
||||||
|
|
||||||
aspect1 = @user.aspects.create(:name => "hey")
|
aspect1 = @user.aspects.first
|
||||||
aspect2 = @user2.aspects.create(:name => "hey")
|
aspect2 = @user2.aspects.first
|
||||||
|
|
||||||
connect_users(@user, aspect1, @user2, aspect2)
|
|
||||||
|
|
||||||
@original_post = @user2.build_post(:status_message, :message => "hey", :aspect_ids => [aspect2.id])
|
@original_post = @user2.build_post(:status_message, :message => "hey", :aspect_ids => [aspect2.id])
|
||||||
|
|
||||||
@salmon_xml = @user2.salmon(@original_post).xml_for(@user.person)
|
@salmon_xml = @user2.salmon(@original_post).xml_for(@user.person)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require 'spec_helper'
|
||||||
require File.join(Rails.root, 'lib', 'pubsubhubbub')
|
require File.join(Rails.root, 'lib', 'pubsubhubbub')
|
||||||
|
|
||||||
describe Pubsubhubbub do
|
describe Pubsubhubbub do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
RestClient.unstub!(:post)
|
RestClient.unstub!(:post)
|
||||||
end
|
end
|
||||||
|
|
@ -15,9 +15,6 @@ describe Pubsubhubbub do
|
||||||
RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success))
|
RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#initialize' do
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#publish' do
|
describe '#publish' do
|
||||||
it 'posts the feed to the given hub' do
|
it 'posts the feed to the given hub' do
|
||||||
hub = "http://hubzord.com/"
|
hub = "http://hubzord.com/"
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Salmon do
|
describe Salmon do
|
||||||
let(:user){Factory.create(:user)}
|
let(:user){alice}
|
||||||
let(:user2) {Factory.create(:user)}
|
let(:user2) {eve}
|
||||||
let(:user3) {Factory.create(:user)}
|
let(:user3) {Factory.create(:user)}
|
||||||
let(:post){ user.post :status_message, :message => "hi", :to => user.aspects.create(:name => "sdg").id }
|
let(:post){ user.post :status_message, :message => "hi", :to => user.aspects.create(:name => "sdg").id }
|
||||||
|
|
||||||
|
|
@ -71,8 +71,8 @@ describe Salmon do
|
||||||
|
|
||||||
it 'should fail if no author is found' do
|
it 'should fail if no author is found' do
|
||||||
parsed_salmon.author_email = 'tom@tom.joindiaspora.com'
|
parsed_salmon.author_email = 'tom@tom.joindiaspora.com'
|
||||||
|
|
||||||
|
|
||||||
proc {parsed_salmon.author.public_key}.should raise_error "did you remember to async webfinger?"
|
proc {parsed_salmon.author.public_key}.should raise_error "did you remember to async webfinger?"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ require 'spec_helper'
|
||||||
require File.join(Rails.root, 'lib/webfinger')
|
require File.join(Rails.root, 'lib/webfinger')
|
||||||
|
|
||||||
describe Webfinger do
|
describe Webfinger do
|
||||||
let(:user1) { Factory.create(:user) }
|
let(:user1) { alice }
|
||||||
let(:user2) { Factory.create(:user) }
|
let(:user2) { eve }
|
||||||
|
|
||||||
let(:account) {"foo@tom.joindiaspora.com"}
|
let(:account) {"foo@tom.joindiaspora.com"}
|
||||||
let(:person){ Factory(:person, :diaspora_handle => account)}
|
let(:person){ Factory(:person, :diaspora_handle => account)}
|
||||||
|
|
@ -39,7 +39,7 @@ describe Webfinger do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'webfinger query chain processing' do
|
context 'webfinger query chain processing' do
|
||||||
describe '#webfinger_profile_url' do
|
describe '#webfinger_profile_url' do
|
||||||
it 'should parse out the webfinger template' do
|
it 'should parse out the webfinger template' do
|
||||||
finger.send(:webfinger_profile_url, diaspora_xrd).should == "http://tom.joindiaspora.com/webfinger/?q=#{account}"
|
finger.send(:webfinger_profile_url, diaspora_xrd).should == "http://tom.joindiaspora.com/webfinger/?q=#{account}"
|
||||||
|
|
@ -79,14 +79,14 @@ describe Webfinger do
|
||||||
diaspora_finger.stub!(:body).and_return(diaspora_finger)
|
diaspora_finger.stub!(:body).and_return(diaspora_finger)
|
||||||
RestClient.stub!(:get).and_return(diaspora_xrd, diaspora_finger, hcard_xml)
|
RestClient.stub!(:get).and_return(diaspora_xrd, diaspora_finger, hcard_xml)
|
||||||
#new_person = Factory.build(:person, :diaspora_handle => "tom@tom.joindiaspora.com")
|
#new_person = Factory.build(:person, :diaspora_handle => "tom@tom.joindiaspora.com")
|
||||||
# http://tom.joindiaspora.com/.well-known/host-meta
|
# http://tom.joindiaspora.com/.well-known/host-meta
|
||||||
f = Webfinger.new("tom@tom.joindiaspora.com").fetch
|
f = Webfinger.new("tom@tom.joindiaspora.com").fetch
|
||||||
|
|
||||||
f.should be_valid
|
f.should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should retry with http if https fails' do
|
it 'should retry with http if https fails' do
|
||||||
f = Webfinger.new("tom@tom.joindiaspora.com")
|
f = Webfinger.new("tom@tom.joindiaspora.com")
|
||||||
|
|
||||||
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
||||||
RestClient.should_receive(:get).twice.and_return(nil, diaspora_xrd)
|
RestClient.should_receive(:get).twice.and_return(nil, diaspora_xrd)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Notifier do
|
describe Notifier do
|
||||||
let!(:user) {Factory.create(:user)}
|
let!(:user) {alice}
|
||||||
let!(:user2) {Factory.create(:user)}
|
let!(:user2) {eve}
|
||||||
|
|
||||||
let!(:aspect) {user.aspects.create(:name => "win")}
|
let!(:aspect) {user.aspects.create(:name => "win")}
|
||||||
let!(:aspect2) {user2.aspects.create(:name => "win")}
|
let!(:aspect2) {user2.aspects.create(:name => "win")}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Aspect do
|
describe Aspect do
|
||||||
let(:user ) { Factory.create(:user) }
|
let(:user ) { alice }
|
||||||
let(:connected_person) { Factory.create(:person) }
|
let(:connected_person) { Factory.create(:person) }
|
||||||
let(:user2) { Factory.create(:user) }
|
let(:user2) { eve }
|
||||||
let(:connected_person_2) { Factory.create(:person) }
|
let(:connected_person_2) { Factory.create(:person) }
|
||||||
|
|
||||||
let(:aspect) {user.aspects.create(:name => 'losers')}
|
let(:aspect) {user.aspects.first }
|
||||||
let(:aspect2) {user2.aspects.create(:name => 'failures')}
|
let(:aspect2) {user2.aspects.first }
|
||||||
let(:aspect1) {user.aspects.create(:name => 'cats')}
|
let(:aspect1) {user.aspects.create(:name => 'cats')}
|
||||||
let(:user3) {Factory.create(:user)}
|
let(:user3) {Factory.create(:user)}
|
||||||
let(:aspect3) {user3.aspects.create(:name => "lala")}
|
let(:aspect3) {user3.aspects.create(:name => "lala")}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,11 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Comment do
|
describe Comment do
|
||||||
let(:user) {Factory.create(:user)}
|
let(:user) {alice}
|
||||||
let(:aspect) {user.aspects.create(:name => "Doofuses")}
|
let(:aspect) {user.aspects.first}
|
||||||
|
|
||||||
let(:user2) {Factory.create(:user)}
|
let(:user2) {bob}
|
||||||
let(:aspect2) {user2.aspects.create(:name => "Lame-faces")}
|
let(:aspect2) {user2.aspects.first}
|
||||||
|
|
||||||
let!(:connecting) { connect_users(user, aspect, user2, aspect2) }
|
|
||||||
|
|
||||||
describe '.hash_from_post_ids' do
|
describe '.hash_from_post_ids' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Invitation do
|
describe Invitation do
|
||||||
let(:user) {Factory.create(:user)}
|
let(:user) {alice}
|
||||||
let!(:aspect) {user.aspects.create(:name => "Invitees")}
|
let(:aspect) {user.aspects.first}
|
||||||
let(:user2) {Factory.create(:user)}
|
let(:user2) {eve}
|
||||||
before do
|
before do
|
||||||
user.invites = 20
|
user.invites = 20
|
||||||
user.save
|
user.save
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ require 'spec_helper'
|
||||||
describe Jobs::NotifyLocalUsers do
|
describe Jobs::NotifyLocalUsers do
|
||||||
describe '#perfom' do
|
describe '#perfom' do
|
||||||
it 'should call Notification.notify on the object' do
|
it 'should call Notification.notify on the object' do
|
||||||
user = Factory(:user)
|
user = alice
|
||||||
person = Factory :person
|
person = Factory :person
|
||||||
object = Factory :status_message
|
object = Factory :status_message
|
||||||
|
|
||||||
Notification.should_receive(:notify).with(instance_of(User), instance_of(StatusMessage), instance_of(Person))
|
Notification.should_receive(:notify).with(instance_of(User), instance_of(StatusMessage), instance_of(Person))
|
||||||
Jobs::NotifyLocalUsers.perform(user.id, object.class.to_s, object.id, person.id)
|
Jobs::NotifyLocalUsers.perform(user.id, object.class.to_s, object.id, person.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Jobs::PostToService do
|
describe Jobs::PostToService do
|
||||||
it 'calls service#post with the given service' do
|
it 'calls service#post with the given service' do
|
||||||
user = Factory(:user)
|
user = alice
|
||||||
aspect = user.aspects.create(:name => "yeah")
|
aspect = user.aspects.create(:name => "yeah")
|
||||||
post = user.post(:status_message, :message => 'foo', :to => aspect.id)
|
post = user.post(:status_message, :message => 'foo', :to => aspect.id)
|
||||||
User.stub!(:find_by_id).with(user.id.to_s).and_return(user)
|
User.stub!(:find_by_id).with(user.id.to_s).and_return(user)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Jobs::PostToServices do
|
describe Jobs::PostToServices do
|
||||||
it 'calls post to services from the given user with given post' do
|
it 'calls post to services from the given user with given post' do
|
||||||
user = Factory.create(:user)
|
user = alice
|
||||||
aspect = user.aspects.create(:name => "yeah")
|
aspect = user.aspects.create(:name => "yeah")
|
||||||
post = user.post(:status_message, :message => 'foo', :to => aspect.id)
|
post = user.post(:status_message, :message => 'foo', :to => aspect.id)
|
||||||
User.stub!(:find_by_id).with(user.id.to_s).and_return(user)
|
User.stub!(:find_by_id).with(user.id.to_s).and_return(user)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Jobs::ReceiveLocal do
|
describe Jobs::ReceiveLocal do
|
||||||
before do
|
before do
|
||||||
@user1 = Factory.create(:user)
|
@user1 = alice
|
||||||
@user2 = Factory.create(:user)
|
@user2 = eve
|
||||||
@status = Factory(:status_message)
|
@status = Factory(:status_message)
|
||||||
@status_type = @status.class.to_s
|
@status_type = @status.class.to_s
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Jobs::ReceiveSalmon do
|
describe Jobs::ReceiveSalmon do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@xml = '<xml></xml>'
|
@xml = '<xml></xml>'
|
||||||
User.stub(:find){ |id|
|
User.stub(:find){ |id|
|
||||||
if id == @user.id
|
if id == @user.id
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Jobs::Receive do
|
describe Jobs::Receive do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@person = Factory(:person)
|
@person = Factory(:person)
|
||||||
@xml = '<xml></xml>'
|
@xml = '<xml></xml>'
|
||||||
User.stub(:find){ |id|
|
User.stub(:find){ |id|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require File.join(Rails.root, 'spec/spec_helper')
|
||||||
|
|
||||||
describe Jobs::SocketWebfinger do
|
describe Jobs::SocketWebfinger do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@account = "tom@tom.joindiaspora.com"
|
@account = "tom@tom.joindiaspora.com"
|
||||||
end
|
end
|
||||||
it 'Makes a Webfinger object' do
|
it 'Makes a Webfinger object' do
|
||||||
|
|
@ -30,7 +30,7 @@ describe Jobs::SocketWebfinger do
|
||||||
Webfinger.stub(:new).and_return(finger)
|
Webfinger.stub(:new).and_return(finger)
|
||||||
person = Factory.create(:person)
|
person = Factory.create(:person)
|
||||||
finger.stub(:fetch).and_return(person)
|
finger.stub(:fetch).and_return(person)
|
||||||
|
|
||||||
opts = {:symbol => true}
|
opts = {:symbol => true}
|
||||||
person.should_receive(:socket_to_user).with(@user, opts)
|
person.should_receive(:socket_to_user).with(@user, opts)
|
||||||
Jobs::SocketWebfinger.perform(@user.id, @account, opts)
|
Jobs::SocketWebfinger.perform(@user.id, @account, opts)
|
||||||
|
|
@ -39,10 +39,10 @@ describe Jobs::SocketWebfinger do
|
||||||
finger = mock()
|
finger = mock()
|
||||||
Webfinger.stub(:new).and_return(finger)
|
Webfinger.stub(:new).and_return(finger)
|
||||||
finger.stub(:fetch).and_raise(Webfinger::WebfingerFailedError)
|
finger.stub(:fetch).and_raise(Webfinger::WebfingerFailedError)
|
||||||
|
|
||||||
opts = {:class => 'people', :status => 'fail', :query => @account, :response => I18n.t('people.webfinger.fail', :handle => @account )}.to_json
|
opts = {:class => 'people', :status => 'fail', :query => @account, :response => I18n.t('people.webfinger.fail', :handle => @account )}.to_json
|
||||||
Diaspora::WebSocket.should_receive(:queue_to_user).with(@user.id, opts)
|
Diaspora::WebSocket.should_receive(:queue_to_user).with(@user.id, opts)
|
||||||
Jobs::SocketWebfinger.perform(@user.id, @account)
|
Jobs::SocketWebfinger.perform(@user.id, @account)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ describe Notification do
|
||||||
before do
|
before do
|
||||||
@sm = Factory(:status_message)
|
@sm = Factory(:status_message)
|
||||||
@person = Factory(:person)
|
@person = Factory(:person)
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@user2 = Factory.create(:user)
|
@user2 = eve
|
||||||
@aspect = @user.aspects.create(:name => "dudes")
|
@aspect = @user.aspects.create(:name => "dudes")
|
||||||
@opts = {:target_id => @sm.id,
|
@opts = {:target_id => @sm.id,
|
||||||
:target_type => @sm.class.name,
|
:target_type => @sm.class.name,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Photo do
|
describe Photo do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => "losers")
|
@aspect = @user.aspects.first
|
||||||
|
|
||||||
@fixture_filename = 'button.png'
|
@fixture_filename = 'button.png'
|
||||||
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename)
|
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Post do
|
describe Post do
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => "winners")
|
@aspect = @user.aspects.create(:name => "winners")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe PostVisibility do
|
describe PostVisibility do
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => 'Boozers')
|
@aspect = @user.aspects.create(:name => 'Boozers')
|
||||||
|
|
||||||
@person = Factory(:person)
|
@person = Factory(:person)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Retraction do
|
describe Retraction do
|
||||||
|
|
||||||
let(:user) { Factory.create(:user) }
|
let(:user) { alice }
|
||||||
let(:person) { Factory(:person) }
|
let(:person) { Factory(:person) }
|
||||||
let(:aspect) { user.aspects.create(:name => "Bruisers") }
|
let(:aspect) { user.aspects.create(:name => "Bruisers") }
|
||||||
let!(:activation) { user.activate_contact(person, aspect) }
|
let!(:activation) { user.activate_contact(person, aspect) }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Services::Facebook do
|
describe Services::Facebook do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@user.aspects.create(:name => "whatever")
|
|
||||||
@post = @user.post(:status_message, :message => "hello", :to =>@user.aspects.first.id)
|
@post = @user.post(:status_message, :message => "hello", :to =>@user.aspects.first.id)
|
||||||
@service = Services::Facebook.new(:access_token => "yeah")
|
@service = Services::Facebook.new(:access_token => "yeah")
|
||||||
@user.services << @service
|
@user.services << @service
|
||||||
|
|
@ -12,7 +11,7 @@ describe Services::Facebook do
|
||||||
|
|
||||||
describe '#post' do
|
describe '#post' do
|
||||||
it 'posts a status message to facebook' do
|
it 'posts a status message to facebook' do
|
||||||
RestClient.should_receive(:post).with("https://graph.facebook.com/me/feed", :message => @post.message, :access_token => @service.access_token)
|
RestClient.should_receive(:post).with("https://graph.facebook.com/me/feed", :message => @post.message, :access_token => @service.access_token)
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
end
|
||||||
it 'swallows exception raised by facebook always being down' do
|
it 'swallows exception raised by facebook always being down' do
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Services::Twitter do
|
describe Services::Twitter do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = alice
|
||||||
@user.aspects.create(:name => "whatever")
|
|
||||||
@post = @user.post(:status_message, :message => "hello", :to =>@user.aspects.first.id)
|
@post = @user.post(:status_message, :message => "hello", :to =>@user.aspects.first.id)
|
||||||
@service = Services::Twitter.new(:access_token => "yeah", :access_secret => "foobar")
|
@service = Services::Twitter.new(:access_token => "yeah", :access_secret => "foobar")
|
||||||
@user.services << @service
|
@user.services << @service
|
||||||
|
|
@ -12,7 +11,7 @@ describe Services::Twitter do
|
||||||
|
|
||||||
describe '#post' do
|
describe '#post' do
|
||||||
it 'posts a status message to twitter' do
|
it 'posts a status message to twitter' do
|
||||||
Twitter.should_receive(:update).with(@post.message)
|
Twitter.should_receive(:update).with(@post.message)
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ require 'spec_helper'
|
||||||
describe StatusMessage do
|
describe StatusMessage do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => "losers")
|
@aspect = @user.aspects.first
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#diaspora_handle=' do
|
describe '#diaspora_handle=' do
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe "attack vectors" do
|
describe "attack vectors" do
|
||||||
|
|
||||||
let(:user) { Factory.create(:user) }
|
let(:user) { alice }
|
||||||
let(:aspect) { user.aspects.create(:name => 'heroes') }
|
let(:aspect) { user.aspects.first }
|
||||||
|
|
||||||
let(:bad_user) { Factory.create(:user)}
|
let(:bad_user) { Factory.create(:user)}
|
||||||
|
|
||||||
let(:user2) { Factory.create(:user) }
|
let(:user2) { eve }
|
||||||
let(:aspect2) { user2.aspects.create(:name => 'losers') }
|
let(:aspect2) { user2.aspects.first }
|
||||||
|
|
||||||
let(:user3) { Factory.create(:user) }
|
let(:user3) { Factory.create(:user) }
|
||||||
let(:aspect3) { user3.aspects.create(:name => 'heroes') }
|
let(:aspect3) { user3.aspects.create(:name => 'heroes') }
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,12 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
|
|
||||||
let!(:user1){Factory.create(:user)}
|
let!(:user1){alice}
|
||||||
let!(:user2){Factory.create(:user)}
|
let!(:user2){bob}
|
||||||
let!(:aspect1){user1.aspects.create(:name => 'heroes')}
|
let!(:aspect1){user1.aspects.first}
|
||||||
let!(:aspect2){user2.aspects.create(:name => 'others')}
|
let!(:aspect2){user2.aspects.first}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
connect_users(user1, aspect1, user2, aspect2)
|
|
||||||
@post = user1.build_post(:status_message, :message => "hey", :to => aspect1.id)
|
@post = user1.build_post(:status_message, :message => "hey", :to => aspect1.id)
|
||||||
@post.save
|
@post.save
|
||||||
user1.dispatch_post(@post, :to => "all")
|
user1.dispatch_post(@post, :to => "all")
|
||||||
|
|
@ -23,7 +22,7 @@ describe User do
|
||||||
it "doesn't call receive on local users" do
|
it "doesn't call receive on local users" do
|
||||||
user1.should_not_receive(:receive_comment)
|
user1.should_not_receive(:receive_comment)
|
||||||
user2.should_not_receive(:receive_comment)
|
user2.should_not_receive(:receive_comment)
|
||||||
|
|
||||||
comment = user2.build_comment "why so formal?", :on => @post
|
comment = user2.build_comment "why so formal?", :on => @post
|
||||||
comment.save!
|
comment.save!
|
||||||
user2.dispatch_comment comment
|
user2.dispatch_comment comment
|
||||||
|
|
@ -34,7 +33,7 @@ describe User do
|
||||||
it "doesn't call receive on local users" do
|
it "doesn't call receive on local users" do
|
||||||
user1.should_not_receive(:receive_comment)
|
user1.should_not_receive(:receive_comment)
|
||||||
user2.should_not_receive(:receive_comment)
|
user2.should_not_receive(:receive_comment)
|
||||||
|
|
||||||
comment = user1.build_comment "why so formal?", :on => @post
|
comment = user1.build_comment "why so formal?", :on => @post
|
||||||
comment.save!
|
comment.save!
|
||||||
user1.dispatch_comment comment
|
user1.dispatch_comment comment
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Diaspora::UserModules::Connecting do
|
describe Diaspora::UserModules::Connecting do
|
||||||
let(:user) { Factory.create(:user) }
|
let(:user) { alice }
|
||||||
let(:aspect) { user.aspects.create(:name => 'heroes') }
|
let(:aspect) { user.aspects.create(:name => 'heroes') }
|
||||||
let(:aspect1) { user.aspects.create(:name => 'other') }
|
let(:aspect1) { user.aspects.create(:name => 'other') }
|
||||||
let(:person) { Factory.create(:person) }
|
let(:person) { Factory.create(:person) }
|
||||||
|
|
@ -14,7 +14,7 @@ describe Diaspora::UserModules::Connecting do
|
||||||
let(:person_two) { Factory.create :person }
|
let(:person_two) { Factory.create :person }
|
||||||
let(:person_three) { Factory.create :person }
|
let(:person_three) { Factory.create :person }
|
||||||
|
|
||||||
let(:user2) { Factory.create(:user) }
|
let(:user2) { eve }
|
||||||
let(:aspect2) { user2.aspects.create(:name => "aspect two") }
|
let(:aspect2) { user2.aspects.create(:name => "aspect two") }
|
||||||
|
|
||||||
describe '#send_contact_request_to' do
|
describe '#send_contact_request_to' do
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
let(:inviter) {new_user = Factory.create(:user); new_user.invites = 5; new_user.save; new_user;}
|
let(:inviter) {new_user = eve; new_user.invites = 5; new_user.save; new_user;}
|
||||||
let(:aspect) {inviter.aspects.create(:name => "awesome")}
|
let(:aspect) {inviter.aspects.create(:name => "awesome")}
|
||||||
let(:another_user) {Factory.create(:user)}
|
let(:another_user) {alice}
|
||||||
let(:wrong_aspect) {another_user.aspects.create(:name => "super")}
|
let(:wrong_aspect) {another_user.aspects.create(:name => "super")}
|
||||||
let(:inviter_with_3_invites) { new_user = Factory.create(:user); new_user.invites = 3; new_user.save; new_user;}
|
let(:inviter_with_3_invites) { new_user = Factory.create(:user); new_user.invites = 3; new_user.save; new_user;}
|
||||||
let(:aspect2) {inviter_with_3_invites.aspects.create(:name => "Jersey Girls")}
|
let(:aspect2) {inviter_with_3_invites.aspects.create(:name => "Jersey Girls")}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
|
|
||||||
let!(:user) { Factory.create(:user) }
|
let!(:user) { alice }
|
||||||
let!(:user2) { Factory.create(:user) }
|
let!(:user2) { eve }
|
||||||
|
|
||||||
let!(:aspect) { user.aspects.create(:name => 'heroes') }
|
let!(:aspect) { user.aspects.first }
|
||||||
let!(:aspect1) { user.aspects.create(:name => 'other') }
|
let!(:aspect1) { user.aspects.create(:name => 'other') }
|
||||||
let!(:aspect2) { user2.aspects.create(:name => 'losers') }
|
let!(:aspect2) { user2.aspects.first }
|
||||||
|
|
||||||
let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s }
|
let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s }
|
||||||
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ require 'spec_helper'
|
||||||
describe User do
|
describe User do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory(:user)
|
@user = alice
|
||||||
@aspect = @user.aspects.create(:name => "cats")
|
@aspect = @user.aspects.first
|
||||||
@user2 = Factory(:user_with_aspect)
|
@user2 = eve
|
||||||
@aspect2 = @user2.aspects.first
|
@aspect2 = @user2.aspects.first
|
||||||
|
|
||||||
@person_one = Factory.create :person
|
@person_one = Factory.create :person
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
let(:user) { Factory.create(:user) }
|
let(:user) { alice }
|
||||||
let(:aspect) { user.aspects.create(:name => 'heroes') }
|
let(:aspect) { user.aspects.create(:name => 'heroes') }
|
||||||
let(:user2) { Factory.create(:user) }
|
let(:user2) { eve }
|
||||||
let(:aspect2) { user2.aspects.create(:name => 'stuff') }
|
let(:aspect2) { user2.aspects.create(:name => 'stuff') }
|
||||||
|
|
||||||
it 'should have a key' do
|
it 'should have a key' do
|
||||||
|
|
@ -16,7 +16,6 @@ describe User do
|
||||||
|
|
||||||
describe 'overwriting people' do
|
describe 'overwriting people' do
|
||||||
it 'does not overwrite old users with factory' do
|
it 'does not overwrite old users with factory' do
|
||||||
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
|
|
||||||
new_user = Factory.create(:user, :id => user.id)
|
new_user = Factory.create(:user, :id => user.id)
|
||||||
new_user.persisted?.should be_true
|
new_user.persisted?.should be_true
|
||||||
new_user.id.should_not == user.id
|
new_user.id.should_not == user.id
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,13 @@ include HelperMethods
|
||||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
#DatabaseCleaner.strategy = nil
|
|
||||||
config.mock_with :mocha
|
config.mock_with :mocha
|
||||||
config.mock_with :rspec
|
config.mock_with :rspec
|
||||||
|
|
||||||
config.use_transactional_fixtures = true
|
config.use_transactional_fixtures = true
|
||||||
|
|
||||||
|
config.global_fixtures = :all
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
I18n.locale = :en
|
I18n.locale = :en
|
||||||
RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success))
|
RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success))
|
||||||
|
|
@ -36,14 +37,17 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
def alice
|
def alice
|
||||||
|
#users(:alice)
|
||||||
User.where(:username => 'alice').first
|
User.where(:username => 'alice').first
|
||||||
end
|
end
|
||||||
|
|
||||||
def bob
|
def bob
|
||||||
|
#users(:bob)
|
||||||
User.where(:username => 'bob').first
|
User.where(:username => 'bob').first
|
||||||
end
|
end
|
||||||
|
|
||||||
def eve
|
def eve
|
||||||
|
#users(:eve)
|
||||||
User.where(:username => 'eve').first
|
User.where(:username => 'eve').first
|
||||||
end
|
end
|
||||||
module Diaspora::WebSocket
|
module Diaspora::WebSocket
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue