diff options
author | maxwell <maxwell@joindiaspora.com> | 2010-10-30 03:23:33 +0400 |
---|---|---|
committer | maxwell <maxwell@joindiaspora.com> | 2010-10-30 03:23:33 +0400 |
commit | 15bd24a64f766e9656e1e8d7edf003d4be748d71 (patch) | |
tree | b0ab075ccf80232511f432b294f48c17cebb2254 /spec | |
parent | c1c045a4cd5ad8406d1ee6b16058934cb23aa3ff (diff) | |
parent | 581985990c80fa3800af796cf4e10e014929e7e9 (diff) |
Merge branch 'master' of github.com:diaspora/diaspora
Conflicts:
spec/lib/message_handler_spec.rb
spec/spec_helper.rb
Diffstat (limited to 'spec')
43 files changed, 1108 insertions, 106 deletions
diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb index 8bfcf61e5..d1db2c3e2 100644 --- a/spec/controllers/albums_controller_spec.rb +++ b/spec/controllers/albums_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe AlbumsController do render_views before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => "lame-os") @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' sign_in :user, @user @@ -31,7 +31,7 @@ describe AlbumsController do end it "doesn't overwrite random attributes" do - new_user = Factory.create :user + new_user = make_user params = {:name => "Bruisers", :person_id => new_user.person.id} put('update', :id => @album.id, "album" => params) @album.reload.person_id.should == @user.person.id diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 7635bbfc1..54a914eaa 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -8,10 +8,10 @@ describe AspectsController do render_views before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => "lame-os") @aspect1 = @user.aspect(:name => "another aspect") - @user2 = Factory.create(:user) + @user2 = make_user @aspect2 = @user2.aspect(:name => "party people") friend_users(@user,@aspect, @user2, @aspect2) @contact = @user.contact_for(@user2.person) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 86d8d448c..f435ca568 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe PhotosController do render_views before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => "lame-os") @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' @fixture_filename = 'button.png' diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 04a443520..c72d290e7 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' describe PublicsController do render_views - let!(:user) { Factory.create :user } - let!(:user2) { Factory.create :user } + let!(:user) { make_user } + let!(:user2) { make_user } let!(:aspect1) { user.aspect(:name => "foo") } let!(:aspect2) { user2.aspect(:name => "far") } let!(:aspect2) { user2.aspect(:name => 'disciples') } @@ -105,7 +105,7 @@ describe PublicsController do describe '#webfinger' do it "succeeds when the person and user exist locally" do - user = Factory(:user) + user = make_user post :webfinger, 'q' => user.person.diaspora_handle response.should be_success end diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index d75b93f05..8b276dfc8 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe RequestsController do render_views before do - @user = Factory.create(:user) + @user = make_user sign_in :user, @user @user.aspect(:name => "lame-os") diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 0c19c1e23..71c7317b4 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe ServicesController do render_views - let(:user) { Factory(:user) } + let(:user) { make_user } let!(:aspect) { user.aspect(:name => "lame-os") } let!(:service1) {a = Factory(:service); user.services << a; a} diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index b7d7c037b..0b7e6ab1a 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -13,7 +13,7 @@ EOT describe SocketsController do render_views before do - @user = Factory.create(:user) + @user = make_user @controller = SocketsController.new end diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 0869972b3..8b96e49cb 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe StatusMessagesController do render_views - let!(:user) { Factory(:user) } + let!(:user) { make_user } let!(:aspect) { user.aspect(:name => "lame-os") } before do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index ae12caf18..b48115f08 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe UsersController do - let(:user) { Factory(:user) } + let(:user) { make_user } let!(:aspect) { user.aspect(:name => "lame-os") } let!(:old_password) { user.encrypted_password } diff --git a/spec/factories.rb b/spec/factories.rb index 32d747937..948f8dc93 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -7,15 +7,19 @@ # http://railscasts.com/episodes/158-factories-not-fixtures #This inclsion, because gpg-agent(not needed) is never run and hence never sets any env. variables on a MAC +def r_str + ActiveSupport::SecureRandom.hex(3) +end + Factory.define :profile do |p| - p.sequence(:first_name){|n| "Robert#{n}"} - p.sequence(:last_name){|n| "Grimm#{n}"} + p.sequence(:first_name){|n| "Robert#{n}#{r_str}"} + p.sequence(:last_name){|n| "Grimm#{n}#{r_str}"} end Factory.define :person do |p| - p.sequence(:diaspora_handle) {|n| "bob-person-#{n}@aol.com"} - p.sequence(:url) {|n| "http://google-#{n}.com/"} + p.sequence(:diaspora_handle) {|n| "bob-person-#{n}#{r_str}@aol.com"} + p.sequence(:url) {|n| "http://google-#{n}#{r_str}.com/"} p.profile Factory.create(:profile, :first_name => "eugene", :last_name => "weinstien") p.serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export @@ -27,8 +31,8 @@ Factory.define :album do |p| end Factory.define :user do |u| - u.sequence(:username) {|n| "bob#{n}"} - u.sequence(:email) {|n| "bob#{n}@pivotallabs.com"} + u.sequence(:username) {|n| "bob#{n}#{r_str}"} + u.sequence(:email) {|n| "bob#{n}#{r_str}@pivotallabs.com"} u.password "bluepin7" u.password_confirmation "bluepin7" u.serialized_private_key OpenSSL::PKey::RSA.generate(1024).export diff --git a/spec/fixtures/users.yaml b/spec/fixtures/users.yaml new file mode 100644 index 000000000..5c90e0040 --- /dev/null +++ b/spec/fixtures/users.yaml @@ -0,0 +1,948 @@ +--- +:users: +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$yl5042/m1NmG58eXtYKb7uiHUuBYq0xPRm7xK.Xdi/a9ypP0UyNFe + serialized_private_key: &id002 | + -----BEGIN RSA PRIVATE KEY----- + MIICXAIBAAKBgQDFEFYV6qVJwk1qHQio2QLBx5D8qkMnFPTg8hq0X9qk8Ft4A1Fu + bPdk9tpSp+FhtL3PqQiVo/ELzv7/Vg+qD6HnWtUytmpSkVdBsseIabyQcL7rzMpK + Jv8eW8+kSakvgQVJSDIFBf67VGHcm3vXSlh3NbU0V/Od2IRBKKbPaTJU6QIDAQAB + AoGAU+SMgXAPRcNOKaqKkTcxkUVgV/Az/mNRjKIE9F0KO8WHayQeeqAxAe6FK0MF + FA9Z7xnK6cmNSLWqoREGQiO9jH00qQM2lBTJHDQnfTifV21LyU28UIj+46LOUO72 + x5BhiDAq3ncl+wh3THlvvYBKEYkH9V5E3Qv190oGqeG/8LECQQDmlYJHuaeKUr8r + nKe3AbZs2gSJb88LR28L3l7MJiRiYd2j+0XDPrqj6BsxB33dIIU5rA3i272zxziw + TwrcYYpfAkEA2sj5EVwAeghH+dQ14je/81k5+gHJa14DyTCMiNsIaVFimNhALZrz + KQ8EGPkTSbHH5R6iyPmHY6fTb16YZKV1twJBANJIcMpmhmNAOTVVpSHhfvNgFBke + jUv09lF1lzBIbJAIPjAIvENllqJZz0p0UZVyzeydewBzc1pbidhIDViT37MCQADG + RVtyX+4OqXKQ9b/fQqax4iqoZvYiVxEXQugZHmaBC0BPQ6rlqYazrugHubHBF1wQ + R7M+buRDa9QxGYkBrPECQBec55rbSGJRomlHRVhKyAfPewcbCO9wurIuWvkTDlac + Ju0kWn4frTvRJnEgPxHsRlQLBiyAMZsQ5UvWmy6rNxs= + -----END RSA PRIVATE KEY----- + + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id001 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 37 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 2 + last_sign_in_at: + username: bob1b1de83 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$yl5042/m1NmG58eXtYKb7u + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob16accc0@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:50 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 3 + gender: + birthday: + last_name: Grimm1c1b679 + bio: + first_name: Robert15cfdfb + updated_at: 2010-10-29 22:43:50 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 4 + url: http://google-11ed884.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id001 + diaspora_handle: bob1b1de83@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$MQH.CJUkEbAA0aMlhs3yVOV0W8obzclj24JLMzlbsLblW58P/2WDu + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id003 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 5 + last_sign_in_at: + username: bob2271e40 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$MQH.CJUkEbAA0aMlhs3yVO + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob2573b5a@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:50 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 6 + gender: + birthday: + last_name: Grimm20d70fb + bio: + first_name: Robert2720656 + updated_at: 2010-10-29 22:43:50 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 7 + url: http://google-2a66ee6.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id003 + diaspora_handle: bob2271e40@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$ngoa90jBWjnsEmd63uM8CehEbGR10eDk5CavVC56K2DFGqospeVPm + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id004 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 8 + last_sign_in_at: + username: bob35b8a98 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$ngoa90jBWjnsEmd63uM8Ce + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob312d7a3@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:50 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 9 + gender: + birthday: + last_name: Grimm309eb5b + bio: + first_name: Robert3ef0451 + updated_at: 2010-10-29 22:43:50 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 10 + url: http://google-32f8058.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id004 + diaspora_handle: bob35b8a98@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$PQxJ9RTpc9Uc72hKckPKbeNLKYNmDSUJvwqaziC4a62WA7vUF3ibm + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id005 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 38 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 11 + last_sign_in_at: + username: bob458f3d8 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$PQxJ9RTpc9Uc72hKckPKbe + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob44fbaa5@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:51 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 12 + gender: + birthday: + last_name: Grimm4c2f0d0 + bio: + first_name: Robert42453f9 + updated_at: 2010-10-29 22:43:51 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 13 + url: http://google-4e5029d.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id005 + diaspora_handle: bob458f3d8@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$XSjtdsL9Yz2GS9By/4hQZeXnXZWPd0uuJtUWeN.VXFtUk/NEkZhOq + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id006 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 14 + last_sign_in_at: + username: bob57d55fd + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$XSjtdsL9Yz2GS9By/4hQZe + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob55c87c3@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:51 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 15 + gender: + birthday: + last_name: Grimm54c2742 + bio: + first_name: Robert5ca48e4 + updated_at: 2010-10-29 22:43:51 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 16 + url: http://google-5ecb435.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id006 + diaspora_handle: bob57d55fd@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$GD1Ox5LmmOLOVycvOkuHtu/gwINhkkIVxKAuksw1z/If9HdKOZj4q + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id007 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 17 + last_sign_in_at: + username: bob6e6db8b + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$GD1Ox5LmmOLOVycvOkuHtu + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob6e9568f@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:51 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 18 + gender: + birthday: + last_name: Grimm66fb47f + bio: + first_name: Robert6bf1362 + updated_at: 2010-10-29 22:43:51 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 19 + url: http://google-637c337.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id007 + diaspora_handle: bob6e6db8b@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$dBJTo2az.3WVZqyb4vNOkuh/ld3TqKmF/Pn2QnWBvSFueD/lOhr.S + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id008 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 20 + last_sign_in_at: + username: bob72cdc62 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$dBJTo2az.3WVZqyb4vNOku + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob7ef7e9b@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:51 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 21 + gender: + birthday: + last_name: Grimm772f10b + bio: + first_name: Robert71c70ee + updated_at: 2010-10-29 22:43:51 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 22 + url: http://google-72202b0.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id008 + diaspora_handle: bob72cdc62@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$xCE8yLMxbcXRh5gLuALK6.FNVtPEZmFd1RBaDLPeWgjc8qIlpwVhe + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id009 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 23 + last_sign_in_at: + username: bob8678b45 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$xCE8yLMxbcXRh5gLuALK6. + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob819d189@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:51 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 24 + gender: + birthday: + last_name: Grimm864aeca + bio: + first_name: Robert81ad1c8 + updated_at: 2010-10-29 22:43:51 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 25 + url: http://google-81b2a1e.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id009 + diaspora_handle: bob8678b45@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$HtD4sIEWTLkRkFBVqQlhseNUnbDnp0lY6SVe3h0r1mIn5iwZ2YeXe + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id010 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 26 + last_sign_in_at: + username: bob927c7ca + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$HtD4sIEWTLkRkFBVqQlhse + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob97eca7c@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:51 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 27 + gender: + birthday: + last_name: Grimm9a36026 + bio: + first_name: Robert997cd3d + updated_at: 2010-10-29 22:43:51 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 28 + url: http://google-9369b50.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id010 + diaspora_handle: bob927c7ca@tom.joindiaspora.co +- :user: !map:ActiveSupport::HashWithIndifferentAccess + encrypted_password: $2a$10$XYFOUzQfR5O68OwTE2wW7eA4I5ScghKIQsRZWLDC.pKXptmm69MUm + serialized_private_key: *id002 + pending_request_ids: [] + + invite_messages: !map:ActiveSupport::HashWithIndifferentAccess {} + + last_sign_in_ip: + invites: 5 + friend_ids: [] + + _id: &id011 !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 39 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 29 + last_sign_in_at: + username: bob10b011c4 + language: en + sign_in_count: 0 + visible_person_ids: [] + + password_salt: $2a$10$XYFOUzQfR5O68OwTE2wW7e + inviter_ids: [] + + remember_token: + reset_password_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + email: bob1070f7a1@pivotallabs.com + invitation_token: + visible_post_ids: [] + + getting_started: true + :person: !map:ActiveSupport::HashWithIndifferentAccess + created_at: 2010-10-29 22:43:52 Z + profile: !map:ActiveSupport::HashWithIndifferentAccess + image_url: + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 40 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 30 + gender: + birthday: + last_name: Grimm10e7204d + bio: + first_name: Robert103bb226 + updated_at: 2010-10-29 22:43:52 Z + _id: !ruby/object:BSON::ObjectId + data: + - 76 + - 203 + - 78 + - 40 + - 204 + - 140 + - 180 + - 3 + - 40 + - 0 + - 0 + - 31 + url: http://google-10a3985b.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAMUQVhXqpUnCTWodCKjZAsHHkPyqQycU9ODyGrRf2qTwW3gDUW5s92T2 + 2lKn4WG0vc+pCJWj8QvO/v9WD6oPoeda1TK2alKRV0Gyx4hpvJBwvuvMykom/x5b + z6RJqS+BBUlIMgUF/rtUYdybe9dKWHc1tTRX853YhEEops9pMlTpAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: *id011 + diaspora_handle: bob10b011c4@tom.joindiaspora.co diff --git a/spec/helper_methods.rb b/spec/helper_methods.rb index 1c4a1189a..e60b39535 100644 --- a/spec/helper_methods.rb +++ b/spec/helper_methods.rb @@ -1,15 +1,4 @@ module HelperMethods - def stub_sockets - Diaspora::WebSocket.stub!(:queue_to_user).and_return(true) - Diaspora::WebSocket.stub!(:subscribe).and_return(true) - Diaspora::WebSocket.stub!(:unsubscribe).and_return(true) - end - - def unstub_sockets - Diaspora::WebSocket.unstub!(:queue_to_user) - Diaspora::WebSocket.unstub!(:subscribe) - Diaspora::WebSocket.unstub!(:unsubscribe) - end def stub_comment_signature_verification Comment.any_instance.stubs(:verify_signature).returns(true) @@ -88,4 +77,50 @@ module HelperMethods def evan_hcard File.open(File.dirname(__FILE__) + '/fixtures/evan_hcard').read end + + def make_user + UserFixer.fixed_user + end + + class UserFixer + def self.regenerate_user_fixtures + users = {:users => build_user_fixtures} + File.open(File.join(Rails.root,"spec/fixtures/users.yaml"),'w') do |file| + file.write(users.to_yaml) + end + end + + def self.build_user_fixtures + arr = [] + 10.times do + user = Factory :user + person = user.person + arr << { :user => user.to_mongo, :person => person.to_mongo} + end + arr + end + + def self.load_user_fixtures + yaml_users = YAML.load_file(File.join(Rails.root,"spec/fixtures/users.yaml")) + @@user_hashes = [] + @@user_number = 0 + yaml_users[:users].each do |yaml_user| + user_id = yaml_user[:user]["_id"].to_id + @@user_hashes << {:id => user_id, :data => yaml_user} + end + end + + def self.fixed_user + db = MongoMapper.database + people = db.collection("people") + users = db.collection("users") + user_hash = @@user_hashes[@@user_number] + @@user_number += 1 + @@user_number = 0 if @@user_number >= @@user_hashes.length + users.insert(user_hash[:data][:user]) + people.insert(user_hash[:data][:person]) + + User.find(user_hash[:id]) + end + end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index f64ca0b97..0ba2bb28a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe ApplicationHelper do before do - @user = Factory.create(:user) + @user = make_user @person = Factory.create(:person) end diff --git a/spec/helpers/publics_helper_spec.rb b/spec/helpers/publics_helper_spec.rb index 9b52c30a4..05322f099 100644 --- a/spec/helpers/publics_helper_spec.rb +++ b/spec/helpers/publics_helper_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe PublicsHelper do before do - @user = Factory.create(:user) + @user = make_user @person = Factory.create(:person) end diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index e2db3b5eb..6e9e6e1f9 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -7,9 +7,9 @@ require File.join(Rails.root, 'lib/diaspora/exporter') describe Diaspora::Exporter do - let!(:user1) { Factory(:user) } - let!(:user2) { Factory(:user) } - let!(:user3) { Factory(:user) } + let!(:user1) { make_user } + let!(:user2) { make_user } + let!(:user3) { make_user } let!(:aspect) { user1.aspect(:name => "Old Work") } let(:aspect1) { user1.aspect(:name => "Work") } diff --git a/spec/lib/diaspora/importer_spec.rb b/spec/lib/diaspora/importer_spec.rb index 9d3197698..d79f8b089 100644 --- a/spec/lib/diaspora/importer_spec.rb +++ b/spec/lib/diaspora/importer_spec.rb @@ -10,11 +10,11 @@ describe Diaspora::Importer do before(:each) do # Five users on pod - @user1 = Factory(:user) - @user2 = Factory(:user) - @user3 = Factory(:user) - @user4 = Factory(:user) - @user5 = Factory(:user) + @user1 = make_user + @user2 = make_user + @user3 = make_user + @user4 = make_user + @user5 = make_user # Two external people referenced on pod @person1 = Factory(:person) diff --git a/spec/lib/diaspora/ostatus_builder.rb b/spec/lib/diaspora/ostatus_builder.rb index fd6131f6a..6c75348cb 100644 --- a/spec/lib/diaspora/ostatus_builder.rb +++ b/spec/lib/diaspora/ostatus_builder.rb @@ -8,7 +8,7 @@ require File.join(Rails.root, 'lib/diaspora/ostatus_builder') describe Diaspora::OstatusBuilder do - let!(:user) { Factory(:user) } + let!(:user) { make_user } let(:aspect) { user.aspect(:name => "Public People") } let!(:status_message1) { user.post(:status_message, :message => "One", :public => true, :to => aspect.id) } let!(:status_message2) { user.post(:status_message, :message => "Two", :public => true, :to => aspect.id) } diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index dc1badc21..4be621c23 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -5,11 +5,11 @@ require 'spec_helper' describe Diaspora::Parser do - let(:user) { Factory.create(:user) } + let(:user) { make_user } let(:aspect) { user.aspect(:name => 'spies') } - let(:user2) { Factory.create(:user) } + let(:user2) { make_user } let(:aspect2) { user2.aspect(:name => "pandas") } - let(:user3) { Factory.create :user } + let(:user3) { make_user } let(:person) { user3.person } describe "parsing compliant XML object" do diff --git a/spec/lib/em-webfinger_spec.rb b/spec/lib/em-webfinger_spec.rb index a0c56877f..9c6d384a2 100644 --- a/spec/lib/em-webfinger_spec.rb +++ b/spec/lib/em-webfinger_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' require File.join(Rails.root, 'lib/em-webfinger') describe EMWebfinger do - let(:user1) { Factory(:user) } - let(:user2) { Factory(:user) } + let(:user1) { make_user } + let(:user2) { make_user } let(:account) {"foo@tom.joindiaspora.com"} let(:person){ Factory(:person, :diaspora_handle => account)} diff --git a/spec/lib/encryptor_spec.rb b/spec/lib/encryptor_spec.rb index 277062c01..c277eb576 100644 --- a/spec/lib/encryptor_spec.rb +++ b/spec/lib/encryptor_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe 'user encryption' do before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => 'dudes') end diff --git a/spec/lib/message_handler_spec.rb b/spec/lib/message_handler_spec.rb index b0c3bc14e..4cd0494c7 100644 --- a/spec/lib/message_handler_spec.rb +++ b/spec/lib/message_handler_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe MessageHandler do + let(:handler) {MessageHandler.new()} let(:message_body) {"I want to pump you up"} let(:message_urls) {["http://www.google.com/", "http://yahoo.com/", "http://foo.com/"]} @@ -159,4 +160,3 @@ describe MessageHandler do end end end - diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index 076e97c28..fbf64673d 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe Salmon do - let(:user){Factory.create :user} - let(:user2) {Factory.create :user} - let(:user3) {Factory.create :user} + let(:user){make_user} + let(:user2) {make_user} + let(:user3) {make_user} let(:post){ user.post :status_message, :message => "hi", :to => user.aspect(:name => "sdg").id } let!(:created_salmon) {Salmon::SalmonSlap.create(user, post.to_diaspora_xml)} diff --git a/spec/lib/verify_spec.rb b/spec/lib/verify_spec.rb index 03df9d026..515cd11af 100644 --- a/spec/lib/verify_spec.rb +++ b/spec/lib/verify_spec.rb @@ -7,9 +7,9 @@ require File.join(Rails.root, 'lib/diaspora/importer') describe Diaspora::Importer do - let!(:user1) { Factory(:user) } - let!(:user2) { Factory(:user) } - let!(:user3) { Factory(:user) } + let!(:user1) { make_user } + let!(:user2) { make_user } + let!(:user3) { make_user } let(:aspect1) { user1.aspect(:name => "Work") } let(:aspect2) { user2.aspect(:name => "Family") } @@ -24,7 +24,7 @@ describe Diaspora::Importer do context 'serialized user' do describe '#verify_user' do it 'should return true for a new valid user' do - new_user = Factory(:user) + new_user = make_user new_user.delete importer.verify_user(new_user).should be true end diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb index 84001fc9f..92ecd1035 100644 --- a/spec/lib/websocket_spec.rb +++ b/spec/lib/websocket_spec.rb @@ -6,10 +6,9 @@ require 'spec_helper' describe Diaspora::WebSocket do before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => "losers") @post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id) - unstub_sockets end it 'should queue a job' do diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 88550680f..2fd26c4cc 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Notifier do - let!(:user) {Factory.create :user} + let!(:user) {make_user} let!(:aspect) {user.aspect(:name => "science")} let!(:person) {Factory.create :person} let!(:request_mail) {Notifier.new_request(user, person)} diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 61b64d25b..c62920588 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -6,15 +6,36 @@ require 'spec_helper' describe 'making sure the spec runner works' do it 'should factory create a user with a person saved' do - user = Factory.create(:user) + user = make_user loaded_user = User.first(:id => user.id) loaded_user.person.owner_id.should == user.id end + describe 'fixtures' do + it 'does not save the fixtures without prompting' do + User.count.should == 0 + end + + it 'returns a user on fixed_user' do + new_user = make_user + new_user.is_a?(User).should be_true + User.count.should == 1 + end + + it 'returns a different user on the second fixed_user' do + new_user = make_user + second_user = make_user + + User.count.should == 2 + new_user.id.should_not == second_user.id + end + + end + describe 'factories' do describe 'build' do it 'does not save a built user' do - pending "This problem is bizarre and needs fixing" + pending 'Why does this happen?' Factory.build(:user).persisted?.should be_false end end @@ -22,9 +43,9 @@ describe 'making sure the spec runner works' do describe '#friend_users' do before do - @user1 = Factory.create(:user) + @user1 = make_user @aspect1 = @user1.aspect(:name => "losers") - @user2 = Factory.create(:user) + @user2 = make_user @aspect2 = @user2.aspect(:name => "bruisers") friend_users(@user1, @aspect1, @user2, @aspect2) end diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb index e5b93593a..9bd0e86f8 100644 --- a/spec/models/album_spec.rb +++ b/spec/models/album_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe Album do - let(:user) { Factory.create(:user) } + let(:user) { make_user } let(:person) { user.person } let(:aspect) { user.aspect(:name => "Foo") } let(:album) { user.post(:album, :name => "test collection", :to => aspect.id) } diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index 5a179cce1..4c7eb2a87 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -5,16 +5,16 @@ require 'spec_helper' describe Aspect do - let(:user ) { Factory.create(:user) } + let(:user ) { make_user } let(:friend) { Factory.create(:person) } - let(:user2) { Factory.create(:user) } + let(:user2) { make_user } let(:friend_2) { Factory.create(:person) } let(:aspect) {user.aspect(:name => 'losers')} let(:aspect2) {user2.aspect(:name => 'failures')} let(:aspect1) {user.aspect(:name => 'cats')} let(:not_friend) { Factory(:person, :diaspora_handle => "not@person.com")} - let(:user3) {Factory(:user)} + let(:user3) {make_user} let(:aspect3) {user3.aspect(:name => "lala")} describe 'creation' do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index b7eafb8d3..19f7fdd5e 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -5,10 +5,10 @@ require 'spec_helper' describe Comment do - let(:user) {Factory.create :user} + let(:user) {make_user} let(:aspect) {user.aspect(:name => "Doofuses")} - let(:user2) {Factory.create(:user)} + let(:user2) {make_user} let(:aspect2) {user2.aspect(:name => "Lame-faces")} it 'validates that the handle belongs to the person' do @@ -114,7 +114,7 @@ describe Comment do end describe 'serialization' do it 'should serialize the handle and not the sender' do - commenter = Factory.create(:user) + commenter = make_user commenter_aspect = commenter.aspect :name => "bruisers" friend_users(user, aspect, commenter, commenter_aspect) post = user.post :status_message, :message => "hello", :to => aspect.id diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 7abf977cd..df871cba3 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' describe Person do before do - @user = Factory.create(:user) - @user2 = Factory.create(:user) + @user = make_user + @user2 = make_user @person = Factory.create(:person) @aspect = @user.aspect(:name => "Dudes") @aspect2 = @user2.aspect(:name => "Abscence of Babes") @@ -24,7 +24,8 @@ describe Person do describe '#diaspora_handle' do context 'local people' do it 'uses the pod config url to set the diaspora_handle' do - @user.person.diaspora_handle.should == @user.username + "@" + APP_CONFIG[:terse_pod_url] + new_user = Factory.create(:user) + new_user.person.diaspora_handle.should == new_user.username + "@" + APP_CONFIG[:terse_pod_url] end end @@ -47,7 +48,7 @@ describe Person do end context '#real_name' do - let!(:user) { Factory(:user) } + let!(:user) { make_user } let!(:person) { user.person } let!(:profile) { person.profile } @@ -176,7 +177,7 @@ describe Person do end context 'people finders for webfinger' do - let(:user) {Factory(:user)} + let(:user) {make_user} let(:person) {Factory(:person)} describe '.by_account_identifier' do diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 17fac6be2..86adb1c89 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe Photo do before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => "losers") @album = @user.post :album, :name => "foo", :to => @aspect.id diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 4c3daf4b6..a7e42ede4 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe Post do before do - @user = Factory.create(:user) + @user = make_user end describe 'xml' do diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 6e5dfbf57..a40ef1863 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' describe Request do - let(:user) { Factory(:user) } - let(:user2) { Factory :user} + let(:user) { make_user } + let(:user2) { make_user} let(:person) {Factory :person} let(:aspect) { user.aspect(:name => "dudes") } let(:request){ user.send_friend_request_to user2.person, aspect } diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 4cbb14e9e..cc34647f6 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe Retraction do - let(:user) { Factory(:user) } + let(:user) { make_user } let(:person) { Factory(:person) } let(:aspect) { user.aspect(:name => "Bruisers") } let!(:activation) { user.activate_friend(person, aspect) } diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 086d66e80..06f346e69 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe StatusMessage do before do - @user = Factory.create(:user) + @user = make_user @aspect = @user.aspect(:name => "losers") end diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index f4ba9a104..0f7ecee5a 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -6,15 +6,15 @@ require 'spec_helper' describe "attack vectors" do - let(:user) { Factory(:user) } + let(:user) { make_user } let(:aspect) { user.aspect(:name => 'heroes') } - let(:bad_user) { Factory(:user)} + let(:bad_user) { make_user} - let(:user2) { Factory(:user) } + let(:user2) { make_user } let(:aspect2) { user2.aspect(:name => 'losers') } - let(:user3) { Factory(:user) } + let(:user3) { make_user } let(:aspect3) { user3.aspect(:name => 'heroes') } before do diff --git a/spec/models/user/invite_spec.rb b/spec/models/user/invite_spec.rb index 21f4670a7..202f5f395 100644 --- a/spec/models/user/invite_spec.rb +++ b/spec/models/user/invite_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe User do - let(:inviter) {Factory.create :user} + let(:inviter) {make_user} let(:aspect) {inviter.aspect(:name => "awesome")} - let(:another_user) {Factory.create :user} + let(:another_user) {make_user} let(:wrong_aspect) {another_user.aspect(:name => "super")} let(:inviter_with_3_invites) {Factory.create :user, :invites => 3} let(:aspect2) {inviter_with_3_invites.aspect(:name => "Jersey Girls")} diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 5e1b115ae..24408e4c7 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' describe User do - let!(:user) { Factory(:user) } - let!(:user2) { Factory(:user) } + let!(:user) { make_user } + let!(:user2) { make_user } let!(:aspect) { user.aspect(:name => 'heroes') } let!(:aspect1) { user.aspect(:name => 'other') } @@ -80,9 +80,9 @@ describe User do end context 'dispatching' do - let!(:user3) { Factory(:user) } + let!(:user3) { make_user } let!(:aspect3) { user3.aspect(:name => 'heroes') } - let!(:user4) { Factory(:user) } + let!(:user4) { make_user } let!(:aspect4) { user4.aspect(:name => 'heroes') } let!(:post) { user.build_post :status_message, :message => "hey" } diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index ad18eb89d..c21f88c4d 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -38,7 +38,7 @@ describe User do end context 'with two users' do - let!(:user) {Factory :user} + let!(:user) {make_user} let!(:first_aspect) {user.aspect(:name => 'bruisers')} let!(:second_aspect) {user.aspect(:name => 'losers')} @@ -58,7 +58,7 @@ describe User do end context 'with two users' do - let!(:user) {Factory :user} + let!(:user) {make_user} let!(:first_aspect) {user.aspect(:name => 'bruisers')} let!(:second_aspect) {user.aspect(:name => 'losers')} let!(:user4) { Factory.create(:user_with_aspect)} diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index f0068a32c..04500d40d 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -6,13 +6,13 @@ require 'spec_helper' describe User do - let(:user) { Factory(:user) } + let(:user) { make_user } let(:aspect) { user.aspect(:name => 'heroes') } - let(:user2) { Factory(:user) } + let(:user2) { make_user } let(:aspect2) { user2.aspect(:name => 'losers') } - let(:user3) { Factory(:user) } + let(:user3) { make_user } let(:aspect3) { user3.aspect(:name => 'heroes') } before do diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 42a42423f..5ec769da8 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe Diaspora::UserModules::Friending do - let(:user) { Factory.create :user } + let(:user) { make_user } let(:aspect) { user.aspect(:name => 'heroes') } let(:aspect1) { user.aspect(:name => 'other') } let(:friend) { Factory.create(:person) } @@ -15,7 +15,7 @@ describe Diaspora::UserModules::Friending do let(:person_two) { Factory.create :person } let(:person_three) { Factory.create :person } - let(:user2) { Factory.create :user } + let(:user2) { make_user } let(:aspect2) { user2.aspect(:name => "aspect two") } before do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e86b89e52..315484ab9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe User do - let(:user) { Factory(:user) } + let(:user) { make_user } let(:aspect) { user.aspect(:name => 'heroes') } - let(:user2) { Factory(:user) } + let(:user2) { make_user } let(:aspect2) { user2.aspect(:name => 'stuff') } it 'should have a key' do @@ -188,12 +188,6 @@ describe User do end end - describe '#diaspora_handle' do - it 'uses the pod config url to set the diaspora_handle' do - user.diaspora_handle.should == user.username + "@" + APP_CONFIG[:terse_pod_url] - end - end - context 'profiles' do it 'should be able to update their profile and send it to their friends' do updated_profile = { diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f850393ee..0c582b65f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,11 +28,11 @@ RSpec.configure do |config| DatabaseCleaner.orm = "mongo_mapper" config.before(:each) do - stub_sockets EventMachine::HttpRequest.stub!(:new).and_return(FakeHttpRequest.new(:success)) EventMachine::HttpRequest.any_instance.stubs(:post) EventMachine::HttpRequest.any_instance.stubs(:get) DatabaseCleaner.clean + UserFixer.load_user_fixtures end end |