From 345d346224b3d94291ea4b7d61e8e628e33b5e53 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 10:00:48 -0800 Subject: [PATCH 01/10] Initial fixture_builder --- spec/support/fixture_builder.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 spec/support/fixture_builder.rb diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb new file mode 100644 index 000000000..c81d2f55b --- /dev/null +++ b/spec/support/fixture_builder.rb @@ -0,0 +1,15 @@ +# I usually put this file in spec/support/fixture_builder.rb +FixtureBuilder.configure do |fbuilder| + # rebuild fixtures automatically when these files change: + fbuilder.files_to_check += Dir["app/models/*.rb", "lib/**/*.rb", "spec/factories/*.rb", "spec/support/fixture_builder.rb"] + + # now declare objects + fbuilder.factory do + alice = Factory(:user_with_aspect, :username => "alice") + bob = Factory(:user_with_aspect, :username => "bob") + eve = Factory(:user_with_aspect, :username => "eve") + + connect_users(bob, bob.aspects.first, alice, alice.aspects.first) + connect_users(bob, bob.aspects.first, eve, eve.aspects.first) + end +end From fdc9534fc7a15c1d5468cc4dc988c847f625167e Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 10:25:26 -0800 Subject: [PATCH 02/10] Fix specs in the presence of fixture_builder --- Gemfile | 1 + Gemfile.lock | 2 + .../data_conversion/import_to_mysql_spec.rb | 108 ++++++++---------- spec/lib/rake_helper_spec.rb | 9 +- spec/spec_helper.rb | 2 +- 5 files changed, 55 insertions(+), 67 deletions(-) diff --git a/Gemfile b/Gemfile index 354476fed..45d456580 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,7 @@ end group :test do gem 'factory_girl_rails' + gem 'fixture_builder', '~> 0.2.0' gem 'capybara', '~> 0.3.9' gem 'cucumber-rails', '0.3.2' gem 'rspec', '>= 2.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index 04879edb4..fc31e4b6c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,6 +162,7 @@ GEM fastthread (1.0.7) ffi (0.6.3) rake (>= 0.8.7) + fixture_builder (0.2.0) fog (0.3.25) builder excon (>= 0.2.4) @@ -371,6 +372,7 @@ DEPENDENCIES em-websocket! factory_girl_rails fastercsv (= 1.5.4) + fixture_builder (~> 0.2.0) fog haml (= 3.0.25) http_accept_language! diff --git a/spec/lib/data_conversion/import_to_mysql_spec.rb b/spec/lib/data_conversion/import_to_mysql_spec.rb index 58bdc444a..fc4ec701e 100644 --- a/spec/lib/data_conversion/import_to_mysql_spec.rb +++ b/spec/lib/data_conversion/import_to_mysql_spec.rb @@ -31,15 +31,13 @@ describe DataConversion::ImportToMysql do @migrator.import_raw_users end it "imports data into the users table" do - Mongo::User.count.should == 6 - User.count.should == 0 - @migrator.process_raw_users - User.count.should == 6 + lambda { + @migrator.process_raw_users + }.should change(User, :count).by(Mongo::User.count) end it "imports all the columns" do @migrator.process_raw_users - bob = User.first - bob.mongo_id.should == "4d2b6eb6cc8cb43cc2000007" + bob = User.where(:mongo_id => "4d2b6eb6cc8cb43cc2000007").first bob.username.should == "bob1d2f837" bob.email.should == "bob1a25dee@pivotallabs.com" bob.serialized_private_key.should_not be_nil @@ -64,21 +62,19 @@ describe DataConversion::ImportToMysql do @migrator.import_raw_aspects end it "imports data into the aspects table" do - Mongo::Aspect.count.should == 4 - Aspect.count.should == 0 - @migrator.process_raw_aspects - Aspect.count.should == 4 + lambda { + @migrator.process_raw_aspects + }.should change(Aspect, :count).by(Mongo::Aspect.count) end it "imports all the columns" do @migrator.process_raw_aspects - aspect = Aspect.first + aspect = Aspect.where(:mongo_id => "4d2b6eb6cc8cb43cc2000008").first aspect.name.should == "generic" - aspect.mongo_id.should == "4d2b6eb6cc8cb43cc2000008" aspect.user_mongo_id.should == "4d2b6eb6cc8cb43cc2000007" end it "sets the relation column" do @migrator.process_raw_aspects - aspect = Aspect.first + aspect = Aspect.where(:mongo_id => "4d2b6eb6cc8cb43cc2000008").first aspect.user.should == User.where(:mongo_id => aspect.user_mongo_id).first end end @@ -91,18 +87,16 @@ describe DataConversion::ImportToMysql do end it "imports data into the services table" do - Mongo::Service.count.should == 2 - Service.count.should == 0 - @migrator.process_raw_services - Service.count.should == 2 + lambda { + @migrator.process_raw_services + }.should change(Service, :count).by(Mongo::Service.count) end it "imports all the columns" do @migrator.process_raw_services - service = Service.first + service = Service.where(:mongo_id => "4d2b6ec4cc8cb43cc200003e").first service.type_before_type_cast.should == "Services::Facebook" service.user_mongo_id.should == "4d2b6eb7cc8cb43cc2000014" - service.mongo_id.should == "4d2b6ec4cc8cb43cc200003e" service.provider.should be_nil service.uid.should be_nil service.access_token.should == "yeah" @@ -111,7 +105,7 @@ describe DataConversion::ImportToMysql do end it 'sets the relation column' do @migrator.process_raw_services - service = Service.first + service = Service.where(:mongo_id => "4d2b6ec4cc8cb43cc200003e").first service.user_id.should == User.where(:mongo_id => service.user_mongo_id).first.id end end @@ -182,18 +176,16 @@ describe DataConversion::ImportToMysql do end it "imports data into the people table" do - Mongo::Person.count.should == 10 - Person.count.should == 0 - @migrator.process_raw_people - Person.count.should == 10 + lambda { + @migrator.process_raw_people + }.should change(Person, :count).by(Mongo::Person.count) end it "imports all the columns of a non-owned person" do @migrator.process_raw_people - mongo_person = Mongo::Person.first - person = Person.first + mongo_person = Mongo::Person.where(:mongo_id => "4d2b6eb6cc8cb43cc2000001").first + person = Person.where(:mongo_id => "4d2b6eb6cc8cb43cc2000001").first person.owner_id.should be_nil - person.mongo_id.should == "4d2b6eb6cc8cb43cc2000001" person.guid.should == person.mongo_id person.url.should == "http://google-1b05052.com/" person.diaspora_handle.should == "bob-person-1fe12fb@aol.com" @@ -203,9 +195,8 @@ describe DataConversion::ImportToMysql do it "imports all the columns of an owned person" do @migrator.process_raw_people - person = Person.where(:owner_id => User.first.id).first - mongo_person = Mongo::Person.where(:mongo_id => person.mongo_id).first - person.mongo_id.should == mongo_person.mongo_id + mongo_person = Mongo::Person.first + person = Person.where(:mongo_id => mongo_person.mongo_id).first person.guid.should == mongo_person.mongo_id person.url.should == mongo_person.url person.diaspora_handle.should == mongo_person.diaspora_handle @@ -214,8 +205,9 @@ describe DataConversion::ImportToMysql do end it 'sets the relational column of an owned person' do @migrator.process_raw_people - person = Person.where(:owner_id => User.first.id).first - person.should_not be_nil + mongo_person = Mongo::Person.where("mongo_people.owner_mongo_id IS NOT NULL").first + person = Person.where(:mongo_id => mongo_person.mongo_id).first + person.owner.should_not be_nil person.diaspora_handle.should include(person.owner.username) end end @@ -229,17 +221,15 @@ describe DataConversion::ImportToMysql do end it "imports data into the mongo_contacts table" do - Mongo::Contact.count.should == 6 - Contact.count.should == 0 - @migrator.process_raw_contacts - Contact.count.should == 6 + lambda { + @migrator.process_raw_contacts + }.should change(Contact, :count).by(Mongo::Contact.count) end it "imports all the columns" do @migrator.process_raw_contacts - contact = Contact.first - mongo_contact = Mongo::Contact.where(:mongo_id => contact.mongo_id).first - contact.mongo_id.should == "4d2b6eb7cc8cb43cc200000f" + mongo_contact = Mongo::Contact.first + contact = Contact.where(:mongo_id => mongo_contact.mongo_id).first contact.user_id.should == User.where(:mongo_id => mongo_contact.user_mongo_id).first.id contact.person_id.should == Person.where(:mongo_id => mongo_contact.person_mongo_id).first.id contact.pending.should be_false @@ -257,18 +247,18 @@ describe DataConversion::ImportToMysql do end it "imports data into the mongo_aspect_memberships table" do - Mongo::AspectMembership.count.should == 6 - AspectMembership.count.should == 0 - @migrator.process_raw_aspect_memberships - AspectMembership.count.should == 6 + lambda { + @migrator.process_raw_aspect_memberships + }.should change(AspectMembership, :count).by(Mongo::AspectMembership.count) end it "imports all the columns" do @migrator.process_raw_aspect_memberships - aspectm = AspectMembership.first mongo_aspectm = Mongo::AspectMembership.first - aspectm.contact_id.should == Contact.where(:mongo_id => mongo_aspectm.contact_mongo_id).first.id - aspectm.aspect_id.should == Aspect.where(:mongo_id => mongo_aspectm.aspect_mongo_id).first.id + aspectm = AspectMembership.where( + :contact_id => Contact.where(:mongo_id => mongo_aspectm.contact_mongo_id).first.id, + :aspect_id => Aspect.where(:mongo_id => mongo_aspectm.aspect_mongo_id).first.id).first + aspectm.should_not be_nil end end describe "profiles" do @@ -280,19 +270,17 @@ describe DataConversion::ImportToMysql do end it "processs data into the mongo_profiles table" do - Mongo::Profile.count.should == 10 - Profile.count.should == 0 - @migrator.process_raw_profiles - Profile.count.should == 10 + lambda { + @migrator.process_raw_profiles + }.should change(Profile, :count).by(Mongo::Profile.count) end it "processs all the columns" do @migrator.process_raw_profiles - profile = Profile.first + profile = Profile.where(:mongo_id => "4d2b6eb6cc8cb43cc2000001").first profile.image_url_medium.should be_nil profile.searchable.should == true profile.image_url.should be_nil - profile.mongo_id.should == "4d2b6eb6cc8cb43cc2000001" profile.gender.should be_nil profile.diaspora_handle.should == profile.person.diaspora_handle profile.last_name.should == 'weinstien' @@ -315,10 +303,9 @@ describe DataConversion::ImportToMysql do end it "imports data into the posts table" do - Mongo::Post.count.should == 6 - Post.count.should == 0 - @migrator.process_raw_posts - Post.count.should == 6 + lambda { + @migrator.process_raw_posts + }.should change(Post, :count).by(Mongo::Post.count) end it "imports all the columns" do @@ -374,11 +361,10 @@ describe DataConversion::ImportToMysql do @migrator.import_raw_comments end - it "imports data into the mongo_comments table" do - Mongo::Comment.count.should == 2 - Comment.count.should == 0 - @migrator.process_raw_comments - Comment.count.should == 2 + it "imports data into the comments table" do + lambda { + @migrator.process_raw_comments + }.should change(Comment, :count).by(Mongo::Comment.count) end it "processes all the columns" do diff --git a/spec/lib/rake_helper_spec.rb b/spec/lib/rake_helper_spec.rb index 815fa0ff2..f78ee923f 100644 --- a/spec/lib/rake_helper_spec.rb +++ b/spec/lib/rake_helper_spec.rb @@ -28,12 +28,11 @@ describe RakeHelpers do end it 'should make a user with 10 invites' do - User.count.should == 0 + lambda { + process_emails(@csv, 1, 1, 10, false) + }.should change(User, :count).by(1) - process_emails(@csv, 1, 1, 10, false) - - User.count.should == 1 - User.first.invites.should == 10 + User.last.invites.should == 10 end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 454da0bce..ecb34ba16 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,11 +13,11 @@ require 'factory_girl' include Devise::TestHelpers include WebMock::API +include HelperMethods # # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} -include HelperMethods RSpec.configure do |config| config.mock_with :mocha From b580b7bd2cc931735c7f2f2faa535837d327fad7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 10:42:50 -0800 Subject: [PATCH 03/10] Putting fixtures in specs... --- Gemfile | 2 +- Gemfile.lock | 4 +-- spec/controllers/aspects_controller_spec.rb | 10 +++---- spec/controllers/comments_controller_spec.rb | 28 ++++++++++---------- spec/misc_spec.rb | 25 +++++++---------- spec/spec_helper.rb | 2 ++ spec/support/fixture_builder.rb | 12 +++++++++ 7 files changed, 45 insertions(+), 38 deletions(-) diff --git a/Gemfile b/Gemfile index 45d456580..4c739a098 100644 --- a/Gemfile +++ b/Gemfile @@ -62,7 +62,7 @@ group :test do gem 'rspec', '>= 2.0.0' gem 'rspec-rails', '>= 2.0.0' gem 'mocha' - gem 'database_cleaner', '0.5.2' + gem 'database_cleaner', '0.6.0' gem 'webmock', :require => false gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false gem 'mongrel', :require => false if RUBY_VERSION.include? '1.8' diff --git a/Gemfile.lock b/Gemfile.lock index fc31e4b6c..95cdd3671 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -136,7 +136,7 @@ GEM cucumber (>= 0.8.0) culerity (0.2.14) daemons (1.1.0) - database_cleaner (0.5.2) + database_cleaner (0.6.0) devise (1.1.3) bcrypt-ruby (~> 2.1.2) warden (~> 0.10.7) @@ -366,7 +366,7 @@ DEPENDENCIES chef (= 0.9.12) cloudfiles (= 1.4.10) cucumber-rails (= 0.3.2) - database_cleaner (= 0.5.2) + database_cleaner (= 0.6.0) devise (= 1.1.3) devise_invitable (= 0.3.5) em-websocket! diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index e3445f2d4..01ce07cc4 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -9,14 +9,12 @@ describe AspectsController do render_views before do - @user = Factory.create(:user) - @user2 = Factory.create(:user) + @user = alice + @user2 = bob - @aspect0 = @user.aspects.create(:name => "lame-os") + @aspect0 = @user.aspects.first @aspect1 = @user.aspects.create(:name => "another aspect") - @aspect2 = @user2.aspects.create(:name => "party people") - - connect_users(@user, @aspect0, @user2, @aspect2) + @aspect2 = @user2.aspects.first @contact = @user.contact_for(@user2.person) @user.getting_started = false diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index ad4fa790e..61a89fdd8 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -7,14 +7,14 @@ require 'spec_helper' describe CommentsController do 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 - sign_in :user, user1 + @user1 = alice + @user2 = bob + + @aspect1 = @user1.aspects.first + @aspect2 = @user2.aspects.first + + sign_in :user, @user1 end describe '#create' do @@ -24,7 +24,7 @@ describe CommentsController do } context "on my own post" do before do - @post = user1.post :status_message, :message => 'GIANTS', :to => aspect1.id + @post = @user1.post :status_message, :message => 'GIANTS', :to => @aspect1.id end it 'responds to format js' do post :create, comment_hash.merge(:format => 'js') @@ -35,8 +35,8 @@ describe CommentsController do context "on a post from a contact" do before do - connect_users(user1, aspect1, user2, aspect2) - @post = user2.post :status_message, :message => 'GIANTS', :to => aspect2.id + connect_users(@user1, @aspect1, @user2, @aspect2) + @post = @user2.post :status_message, :message => 'GIANTS', :to => @aspect2.id end it 'comments' do post :create, comment_hash @@ -46,10 +46,10 @@ describe CommentsController do new_user = Factory.create(:user) comment_hash[:person_id] = new_user.person.id.to_s post :create, comment_hash - Comment.find_by_text(comment_hash[:text]).person_id.should == user1.person.id + Comment.find_by_text(comment_hash[:text]).person_id.should == @user1.person.id end it "doesn't overwrite id" do - old_comment = user1.comment("hello", :on => @post) + old_comment = @user1.comment("hello", :on => @post) comment_hash[:id] = old_comment.id post :create, comment_hash old_comment.reload.text.should == 'hello' @@ -57,10 +57,10 @@ describe CommentsController do end context 'on a post from a stranger' do before do - @post = user2.post :status_message, :message => 'GIANTS', :to => aspect2.id + @post = @user2.post :status_message, :message => 'GIANTS', :to => @aspect2.id end it 'posts no comment' do - user1.should_not_receive(:comment) + @user1.should_not_receive(:comment) post :create, comment_hash response.code.should == '406' end diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 43a83c866..cbe75cccf 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -5,30 +5,25 @@ require 'spec_helper' describe 'making sure the spec runner works' do - it 'factoy creates a user with a person saved' do + it 'factory creates a user with a person saved' do user = Factory.create(:user) loaded_user = User.find(user.id) loaded_user.person.owner_id.should == user.id end - - describe 'factories' do - describe 'build' do - it 'does not save a built user' do - Factory.build(:user).should_not be_persisted - end - - it 'does not save a built person' do - Factory.build(:person).should_not be_persisted - end + describe 'fixtures' do + it 'loads fixtures' do + User.count.should == 3 end end describe '#connect_users' do before do - @user1 = Factory.create(:user) - @aspect1 = @user1.aspects.create(:name => "losers") - @user2 = Factory.create(:user) - @aspect2 = @user2.aspects.create(:name => "bruisers") + @user1 = User.where(:username => 'alice').first + @user2 = User.where(:username => 'eve').first + + @aspect1 = @user1.aspects.first + @aspect2 = @user2.aspects.first + connect_users(@user1, @aspect1, @user2, @aspect2) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ecb34ba16..fa3ef253b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,9 +17,11 @@ include HelperMethods # # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. +#DatabaseCleaner.clean_with(:truncation) Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| + #DatabaseCleaner.strategy = nil config.mock_with :mocha config.mock_with :rspec diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index c81d2f55b..1fc3a8839 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -13,3 +13,15 @@ FixtureBuilder.configure do |fbuilder| connect_users(bob, bob.aspects.first, eve, eve.aspects.first) end end + +def alice + User.where(:username => 'alice').first +end + +def bob + User.where(:username => 'bob').first +end + +def eve + User.where(:username => 'eve').first +end From ac3d037dc4ff62377a998338a1d68e83cf415e40 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 10:48:06 -0800 Subject: [PATCH 04/10] Comments controller spec using fixtures --- spec/controllers/comments_controller_spec.rb | 3 +- spec/fixtures/aspect_memberships.yml | 25 ++++ spec/fixtures/aspects.yml | 25 ++++ spec/fixtures/comments.yml | 2 + spec/fixtures/contacts.yml | 33 +++++ spec/fixtures/invitations.yml | 2 + spec/fixtures/mongo_aspect_memberships.yml | 2 + spec/fixtures/mongo_aspects.yml | 2 + spec/fixtures/mongo_comments.yml | 2 + spec/fixtures/mongo_contacts.yml | 2 + spec/fixtures/mongo_invitations.yml | 2 + spec/fixtures/mongo_notifications.yml | 2 + spec/fixtures/mongo_people.yml | 2 + spec/fixtures/mongo_post_visibilities.yml | 2 + spec/fixtures/mongo_posts.yml | 2 + spec/fixtures/mongo_profiles.yml | 2 + spec/fixtures/mongo_requests.yml | 2 + spec/fixtures/mongo_services.yml | 2 + spec/fixtures/mongo_users.yml | 2 + spec/fixtures/notifications.yml | 2 + spec/fixtures/people.yml | 49 ++++++++ spec/fixtures/post_visibilities.yml | 2 + spec/fixtures/posts.yml | 2 + spec/fixtures/profiles.yml | 49 ++++++++ spec/fixtures/requests.yml | 2 + spec/fixtures/services.yml | 2 + spec/fixtures/users.yml | 121 +++++++++++++++++++ spec/spec_helper.rb | 11 ++ spec/support/fixture_builder.rb | 11 -- 29 files changed, 354 insertions(+), 13 deletions(-) create mode 100644 spec/fixtures/aspect_memberships.yml create mode 100644 spec/fixtures/aspects.yml create mode 100644 spec/fixtures/comments.yml create mode 100644 spec/fixtures/contacts.yml create mode 100644 spec/fixtures/invitations.yml create mode 100644 spec/fixtures/mongo_aspect_memberships.yml create mode 100644 spec/fixtures/mongo_aspects.yml create mode 100644 spec/fixtures/mongo_comments.yml create mode 100644 spec/fixtures/mongo_contacts.yml create mode 100644 spec/fixtures/mongo_invitations.yml create mode 100644 spec/fixtures/mongo_notifications.yml create mode 100644 spec/fixtures/mongo_people.yml create mode 100644 spec/fixtures/mongo_post_visibilities.yml create mode 100644 spec/fixtures/mongo_posts.yml create mode 100644 spec/fixtures/mongo_profiles.yml create mode 100644 spec/fixtures/mongo_requests.yml create mode 100644 spec/fixtures/mongo_services.yml create mode 100644 spec/fixtures/mongo_users.yml create mode 100644 spec/fixtures/notifications.yml create mode 100644 spec/fixtures/people.yml create mode 100644 spec/fixtures/post_visibilities.yml create mode 100644 spec/fixtures/posts.yml create mode 100644 spec/fixtures/profiles.yml create mode 100644 spec/fixtures/requests.yml create mode 100644 spec/fixtures/services.yml create mode 100644 spec/fixtures/users.yml diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 61a89fdd8..80325a028 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -35,7 +35,6 @@ describe CommentsController do context "on a post from a contact" do before do - connect_users(@user1, @aspect1, @user2, @aspect2) @post = @user2.post :status_message, :message => 'GIANTS', :to => @aspect2.id end it 'comments' do @@ -57,7 +56,7 @@ describe CommentsController do end context 'on a post from a stranger' do before do - @post = @user2.post :status_message, :message => 'GIANTS', :to => @aspect2.id + @post = eve.post :status_message, :message => 'GIANTS', :to => eve.aspects.first.id end it 'posts no comment' do @user1.should_not_receive(:comment) diff --git a/spec/fixtures/aspect_memberships.yml b/spec/fixtures/aspect_memberships.yml new file mode 100644 index 000000000..4a5f858e3 --- /dev/null +++ b/spec/fixtures/aspect_memberships.yml @@ -0,0 +1,25 @@ +--- +aspect_memberships_002: + created_at: 2011-01-18 18:44:07 Z + aspect_id: 1 + updated_at: 2011-01-18 18:44:07 Z + contact_id: 2 + id: 2 +aspect_memberships_003: + created_at: 2011-01-18 18:44:07 Z + aspect_id: 2 + updated_at: 2011-01-18 18:44:07 Z + contact_id: 3 + id: 3 +aspect_memberships_004: + created_at: 2011-01-18 18:44:07 Z + aspect_id: 3 + updated_at: 2011-01-18 18:44:07 Z + contact_id: 4 + id: 4 +aspect_memberships_001: + created_at: 2011-01-18 18:44:07 Z + aspect_id: 2 + updated_at: 2011-01-18 18:44:07 Z + contact_id: 1 + id: 1 diff --git a/spec/fixtures/aspects.yml b/spec/fixtures/aspects.yml new file mode 100644 index 000000000..08ba5e30c --- /dev/null +++ b/spec/fixtures/aspects.yml @@ -0,0 +1,25 @@ +--- +generic_1: + name: generic + mongo_id: + created_at: 2011-01-18 18:44:06 Z + updated_at: 2011-01-18 18:44:07 Z + id: 2 + user_mongo_id: + user_id: 4 +generic_2: + name: generic + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + id: 3 + user_mongo_id: + user_id: 5 +generic: + name: generic + mongo_id: + created_at: 2011-01-18 18:44:06 Z + updated_at: 2011-01-18 18:44:06 Z + id: 1 + user_mongo_id: + user_id: 3 diff --git a/spec/fixtures/comments.yml b/spec/fixtures/comments.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/comments.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/contacts.yml b/spec/fixtures/contacts.yml new file mode 100644 index 000000000..9c788d0ad --- /dev/null +++ b/spec/fixtures/contacts.yml @@ -0,0 +1,33 @@ +--- +contacts_003: + pending: false + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + id: 3 + user_id: 4 + person_id: 5 +contacts_004: + pending: false + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + id: 4 + user_id: 5 + person_id: 4 +contacts_001: + pending: false + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + id: 1 + user_id: 4 + person_id: 3 +contacts_002: + pending: false + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + id: 2 + user_id: 3 + person_id: 4 diff --git a/spec/fixtures/invitations.yml b/spec/fixtures/invitations.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/invitations.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_aspect_memberships.yml b/spec/fixtures/mongo_aspect_memberships.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_aspect_memberships.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_aspects.yml b/spec/fixtures/mongo_aspects.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_aspects.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_comments.yml b/spec/fixtures/mongo_comments.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_comments.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_contacts.yml b/spec/fixtures/mongo_contacts.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_contacts.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_invitations.yml b/spec/fixtures/mongo_invitations.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_invitations.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_notifications.yml b/spec/fixtures/mongo_notifications.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_notifications.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_people.yml b/spec/fixtures/mongo_people.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_people.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_post_visibilities.yml b/spec/fixtures/mongo_post_visibilities.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_post_visibilities.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_posts.yml b/spec/fixtures/mongo_posts.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_posts.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_profiles.yml b/spec/fixtures/mongo_profiles.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_profiles.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_requests.yml b/spec/fixtures/mongo_requests.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_requests.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_services.yml b/spec/fixtures/mongo_services.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_services.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/mongo_users.yml b/spec/fixtures/mongo_users.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/mongo_users.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/notifications.yml b/spec/fixtures/notifications.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/notifications.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/people.yml b/spec/fixtures/people.yml new file mode 100644 index 000000000..95b3f2321 --- /dev/null +++ b/spec/fixtures/people.yml @@ -0,0 +1,49 @@ +--- +people_001: + mongo_id: + created_at: 2011-01-18 18:44:06 Z + guid: 89e32c010f204d98 + updated_at: 2011-01-18 18:44:06 Z + url: http://google-1d915c9.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAPEQ08ZWNCiEh/fV/aQ19fMGdeK2r0ns+MB8kcbrkduTqvQ/c/RFkhJX + KWti8QomQVudx30mKMuD+r8XY48xw3H3XQDK2rtpFQmgJ4f/Wj4E6yFJo5pC7OL9 + 253WWqLGAJOJy9IxF76Mlo9Qazm7Z7aj1zp5kUXYusge2XAfkb0fAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: 3 + id: 3 + diaspora_handle: alice@example.org +people_002: + mongo_id: + created_at: 2011-01-18 18:44:07 Z + guid: 5d3d9ce10a10eafe + updated_at: 2011-01-18 18:44:07 Z + url: http://google-245c017.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAPEQ08ZWNCiEh/fV/aQ19fMGdeK2r0ns+MB8kcbrkduTqvQ/c/RFkhJX + KWti8QomQVudx30mKMuD+r8XY48xw3H3XQDK2rtpFQmgJ4f/Wj4E6yFJo5pC7OL9 + 253WWqLGAJOJy9IxF76Mlo9Qazm7Z7aj1zp5kUXYusge2XAfkb0fAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: 4 + id: 4 + diaspora_handle: bob@example.org +people_003: + mongo_id: + created_at: 2011-01-18 18:44:07 Z + guid: 742a7d253debf2d6 + updated_at: 2011-01-18 18:44:07 Z + url: http://google-330296d.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAPEQ08ZWNCiEh/fV/aQ19fMGdeK2r0ns+MB8kcbrkduTqvQ/c/RFkhJX + KWti8QomQVudx30mKMuD+r8XY48xw3H3XQDK2rtpFQmgJ4f/Wj4E6yFJo5pC7OL9 + 253WWqLGAJOJy9IxF76Mlo9Qazm7Z7aj1zp5kUXYusge2XAfkb0fAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: 5 + id: 5 + diaspora_handle: eve@example.org diff --git a/spec/fixtures/post_visibilities.yml b/spec/fixtures/post_visibilities.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/post_visibilities.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/posts.yml b/spec/fixtures/posts.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/posts.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/profiles.yml b/spec/fixtures/profiles.yml new file mode 100644 index 000000000..97cf135d7 --- /dev/null +++ b/spec/fixtures/profiles.yml @@ -0,0 +1,49 @@ +--- +profiles_001: + image_url_medium: + mongo_id: + created_at: 2011-01-18 18:44:06 Z + searchable: true + image_url: + updated_at: 2011-01-18 18:44:06 Z + id: 3 + gender: + diaspora_handle: + person_id: 3 + last_name: Grimm1a80b30 + birthday: + image_url_small: + bio: + first_name: Robert19c3152 +profiles_002: + image_url_medium: + mongo_id: + created_at: 2011-01-18 18:44:06 Z + searchable: true + image_url: + updated_at: 2011-01-18 18:44:07 Z + id: 4 + gender: + diaspora_handle: + person_id: 4 + last_name: Grimm295050b + birthday: + image_url_small: + bio: + first_name: Robert2909f07 +profiles_003: + image_url_medium: + mongo_id: + created_at: 2011-01-18 18:44:07 Z + searchable: true + image_url: + updated_at: 2011-01-18 18:44:07 Z + id: 5 + gender: + diaspora_handle: + person_id: 5 + last_name: Grimm3c16b10 + birthday: + image_url_small: + bio: + first_name: Robert3574823 diff --git a/spec/fixtures/requests.yml b/spec/fixtures/requests.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/requests.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/services.yml b/spec/fixtures/services.yml new file mode 100644 index 000000000..20670d5f5 --- /dev/null +++ b/spec/fixtures/services.yml @@ -0,0 +1,2 @@ +--- {} + diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml new file mode 100644 index 000000000..02648fdf6 --- /dev/null +++ b/spec/fixtures/users.yml @@ -0,0 +1,121 @@ +--- +alice: + encrypted_password: $2a$10$10wn.2788it4RyLvmIqap.zJfK8kAoM7IVsD6l0vPyzxQY7aH4m4m + serialized_private_key: | + -----BEGIN RSA PRIVATE KEY----- + MIICXQIBAAKBgQDxENPGVjQohIf31f2kNfXzBnXitq9J7PjAfJHG65Hbk6r0P3P0 + RZISVylrYvEKJkFbncd9JijLg/q/F2OPMcNx910Aytq7aRUJoCeH/1o+BOshSaOa + Quzi/dud1lqixgCTicvSMRe+jJaPUGs5u2e2o9c6eZFF2LrIHtlwH5G9HwIDAQAB + AoGAIk7BxPVZwPZzn1ruGSOw2CBwQI69TakTEdnoqUW3YWeXqeEp8HbCPif3dhgD + s+0T2iUPUglPPv+OfQmoGqX7aYMTJOIrFPxYkBKkbfW8ZoNy/GHibblLJscJ54iF + iJcGL6bBGga36QSA+aw29N7+qtMQdebsBHsj6qZpFxS+N3ECQQD6/t4eX8BdHKoB + IfWpZV1JETyZAE+sGiUUF3QgyE3C7v5o99xtEZ6jvRMcwURf/3Dw3FeATSAgVC0Q + LReupEHZAkEA9d9GkOyioKoAEmVfjc08va0otSv9OR81MYWfXRuCliMMQC3wHdU4 + kr912zY2FDHLZtxy12YImDG/hpHYbpYjtwJBALvoIxJKTRFobD381pXDNVuGc/93 + pC4MRMYN6PrB+rV9hym+pl9hWYrr+msEpdPYwQ0RaNC87NhHLJV3rMsqXcECQFC8 + UF+mVICNUhi4UPgvPJLMGWHkX/Ix3TW1uu7H6cmDGLK6Yu5o5XrKg9jHpFpdP303 + Rj6Usp3HOCzoFzm482ECQQCYJ01wP0IsjFruXqhlclYxk/1cKuRt5NmhkNflJSWl + BrEFy9v3tTGVI6AAR1S7cYWFEyOj0OICMOqGHU72GIIv + -----END RSA PRIVATE KEY----- + + mongo_id: + created_at: 2011-01-18 18:44:06 Z + updated_at: 2011-01-18 18:44:06 Z + last_sign_in_ip: + invites: 0 + username: alice + last_sign_in_at: + language: en + sign_in_count: 0 + id: 3 + disable_mail: false + password_salt: $2a$10$10wn.2788it4RyLvmIqap. + reset_password_token: + remember_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + invitation_token: + getting_started: true + email: bob1f866f6@pivotallabs.com +eve: + encrypted_password: $2a$10$uDyK3VOraaekpPhbr8dPjuGqdshJlt9vSRUWvh9R1obnqqMgp60ry + serialized_private_key: | + -----BEGIN RSA PRIVATE KEY----- + MIICXQIBAAKBgQDxENPGVjQohIf31f2kNfXzBnXitq9J7PjAfJHG65Hbk6r0P3P0 + RZISVylrYvEKJkFbncd9JijLg/q/F2OPMcNx910Aytq7aRUJoCeH/1o+BOshSaOa + Quzi/dud1lqixgCTicvSMRe+jJaPUGs5u2e2o9c6eZFF2LrIHtlwH5G9HwIDAQAB + AoGAIk7BxPVZwPZzn1ruGSOw2CBwQI69TakTEdnoqUW3YWeXqeEp8HbCPif3dhgD + s+0T2iUPUglPPv+OfQmoGqX7aYMTJOIrFPxYkBKkbfW8ZoNy/GHibblLJscJ54iF + iJcGL6bBGga36QSA+aw29N7+qtMQdebsBHsj6qZpFxS+N3ECQQD6/t4eX8BdHKoB + IfWpZV1JETyZAE+sGiUUF3QgyE3C7v5o99xtEZ6jvRMcwURf/3Dw3FeATSAgVC0Q + LReupEHZAkEA9d9GkOyioKoAEmVfjc08va0otSv9OR81MYWfXRuCliMMQC3wHdU4 + kr912zY2FDHLZtxy12YImDG/hpHYbpYjtwJBALvoIxJKTRFobD381pXDNVuGc/93 + pC4MRMYN6PrB+rV9hym+pl9hWYrr+msEpdPYwQ0RaNC87NhHLJV3rMsqXcECQFC8 + UF+mVICNUhi4UPgvPJLMGWHkX/Ix3TW1uu7H6cmDGLK6Yu5o5XrKg9jHpFpdP303 + Rj6Usp3HOCzoFzm482ECQQCYJ01wP0IsjFruXqhlclYxk/1cKuRt5NmhkNflJSWl + BrEFy9v3tTGVI6AAR1S7cYWFEyOj0OICMOqGHU72GIIv + -----END RSA PRIVATE KEY----- + + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + last_sign_in_ip: + invites: 0 + username: eve + last_sign_in_at: + language: en + sign_in_count: 0 + id: 5 + disable_mail: false + password_salt: $2a$10$uDyK3VOraaekpPhbr8dPju + reset_password_token: + remember_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + invitation_token: + getting_started: true + email: bob3884c35@pivotallabs.com +bob: + encrypted_password: $2a$10$YXDxHoVUIaIgyS405RS3NeenGVRrexiZei0.7l.LbyLDf.YqtCvfS + serialized_private_key: | + -----BEGIN RSA PRIVATE KEY----- + MIICXQIBAAKBgQDxENPGVjQohIf31f2kNfXzBnXitq9J7PjAfJHG65Hbk6r0P3P0 + RZISVylrYvEKJkFbncd9JijLg/q/F2OPMcNx910Aytq7aRUJoCeH/1o+BOshSaOa + Quzi/dud1lqixgCTicvSMRe+jJaPUGs5u2e2o9c6eZFF2LrIHtlwH5G9HwIDAQAB + AoGAIk7BxPVZwPZzn1ruGSOw2CBwQI69TakTEdnoqUW3YWeXqeEp8HbCPif3dhgD + s+0T2iUPUglPPv+OfQmoGqX7aYMTJOIrFPxYkBKkbfW8ZoNy/GHibblLJscJ54iF + iJcGL6bBGga36QSA+aw29N7+qtMQdebsBHsj6qZpFxS+N3ECQQD6/t4eX8BdHKoB + IfWpZV1JETyZAE+sGiUUF3QgyE3C7v5o99xtEZ6jvRMcwURf/3Dw3FeATSAgVC0Q + LReupEHZAkEA9d9GkOyioKoAEmVfjc08va0otSv9OR81MYWfXRuCliMMQC3wHdU4 + kr912zY2FDHLZtxy12YImDG/hpHYbpYjtwJBALvoIxJKTRFobD381pXDNVuGc/93 + pC4MRMYN6PrB+rV9hym+pl9hWYrr+msEpdPYwQ0RaNC87NhHLJV3rMsqXcECQFC8 + UF+mVICNUhi4UPgvPJLMGWHkX/Ix3TW1uu7H6cmDGLK6Yu5o5XrKg9jHpFpdP303 + Rj6Usp3HOCzoFzm482ECQQCYJ01wP0IsjFruXqhlclYxk/1cKuRt5NmhkNflJSWl + BrEFy9v3tTGVI6AAR1S7cYWFEyOj0OICMOqGHU72GIIv + -----END RSA PRIVATE KEY----- + + mongo_id: + created_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 18:44:07 Z + last_sign_in_ip: + invites: 0 + username: bob + last_sign_in_at: + language: en + sign_in_count: 0 + id: 4 + disable_mail: false + password_salt: $2a$10$YXDxHoVUIaIgyS405RS3Ne + reset_password_token: + remember_token: + current_sign_in_ip: + remember_created_at: + current_sign_in_at: + invitation_sent_at: + invitation_token: + getting_started: true + email: bob25202ed@pivotallabs.com diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fa3ef253b..b824f3dfd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,6 +35,17 @@ RSpec.configure do |config| end end +def alice + User.where(:username => 'alice').first +end + +def bob + User.where(:username => 'bob').first +end + +def eve + User.where(:username => 'eve').first +end module Diaspora::WebSocket def self.redis FakeRedis.new diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 1fc3a8839..161590b19 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -14,14 +14,3 @@ FixtureBuilder.configure do |fbuilder| end end -def alice - User.where(:username => 'alice').first -end - -def bob - User.where(:username => 'bob').first -end - -def eve - User.where(:username => 'eve').first -end From 1353929d44376601d7f295dae3c60b96c7a3ef49 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 13:31:10 -0800 Subject: [PATCH 05/10] Made specs work with fixtures, spec_helper needs work --- spec/controllers/home_controller_spec.rb | 4 +- .../invitations_controller_spec.rb | 27 ++- .../notifications_controller_spec.rb | 18 +- spec/controllers/people_controller_spec.rb | 93 +++++------ spec/controllers/photos_controller_spec.rb | 92 +++++------ spec/controllers/posts_controller_spec.rb | 8 +- spec/controllers/publics_controller_spec.rb | 40 ++--- spec/controllers/requests_controller_spec.rb | 11 +- spec/controllers/services_controller_spec.rb | 37 ++--- spec/controllers/sockets_controller_spec.rb | 4 +- .../status_message_controller_spec.rb | 43 +++-- spec/controllers/users_controller_spec.rb | 4 +- spec/helpers/application_helper_spec.rb | 18 +- spec/helpers/requests_helper_spec.rb | 9 - spec/helpers/sockets_helper_spec.rb | 8 - spec/helpers/stream_helper_spec.rb | 6 +- spec/helpers/users_helper_spec.rb | 10 +- spec/intergration/receiving_spec.rb | 156 +++++++++--------- spec/lib/diaspora/exporter_spec.rb | 19 +-- spec/lib/diaspora/ostatus_builder.rb | 4 +- spec/lib/diaspora/parser_spec.rb | 36 ++-- spec/lib/diaspora/web_socket_spec.rb | 4 +- spec/lib/diaspora/webhooks_spec.rb | 2 +- spec/lib/encryptor_spec.rb | 4 +- spec/lib/postzord/dispatch_spec.rb | 2 +- spec/lib/postzord/receiver_spec.rb | 11 +- spec/lib/pubsubhubbub_spec.rb | 5 +- spec/lib/salmon_salmon_spec.rb | 8 +- spec/lib/webfinger_spec.rb | 12 +- spec/mailers/notifier_spec.rb | 4 +- spec/models/aspect_spec.rb | 8 +- spec/models/comment_spec.rb | 10 +- spec/models/invitation_spec.rb | 6 +- spec/models/jobs/notify_local_users_spec.rb | 4 +- spec/models/jobs/post_to_service_spec.rb | 2 +- spec/models/jobs/post_to_services_spec.rb | 2 +- spec/models/jobs/receive_local_spec.rb | 4 +- spec/models/jobs/receive_salmon_spec.rb | 2 +- spec/models/jobs/receive_spec.rb | 2 +- spec/models/jobs/socket_webfinger_spec.rb | 8 +- spec/models/notification_spec.rb | 4 +- spec/models/photo_spec.rb | 4 +- spec/models/post_spec.rb | 2 +- spec/models/post_visibility_spec.rb | 2 +- spec/models/retraction_spec.rb | 2 +- spec/models/services/facebook_spec.rb | 7 +- spec/models/services/twitter_spec.rb | 7 +- spec/models/status_message_spec.rb | 4 +- spec/models/user/attack_vectors_spec.rb | 8 +- spec/models/user/commenting_spec.rb | 13 +- spec/models/user/connecting_spec.rb | 4 +- spec/models/user/invite_spec.rb | 4 +- spec/models/user/posting_spec.rb | 8 +- spec/models/user/querying_spec.rb | 6 +- spec/models/user_spec.rb | 5 +- spec/spec_helper.rb | 6 +- 56 files changed, 393 insertions(+), 440 deletions(-) delete mode 100644 spec/helpers/requests_helper_spec.rb delete mode 100644 spec/helpers/sockets_helper_spec.rb diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 1640bfd9e..fd151a0b4 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -9,7 +9,7 @@ describe HomeController do render_views before do - @user = Factory.create(:user) + @user = alice sign_in @user sign_out @user end @@ -37,7 +37,7 @@ describe HomeController do describe "custom logging on redirect" do before do - sign_in :user, Factory(:user) + sign_in :user, bob @action = :show @action_params = {"lasers" => "green"} end diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb index 72626d7b7..07272b689 100644 --- a/spec/controllers/invitations_controller_spec.rb +++ b/spec/controllers/invitations_controller_spec.rb @@ -9,22 +9,20 @@ describe InvitationsController do render_views - let!(:user) { Factory.create(:user) } - let!(:aspect) { user.aspects.create(:name => "WIN!!") } - before do + @user = alice + @aspect = @user.aspects.first request.env["devise.mapping"] = Devise.mappings[:user] end describe "#create" 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"} - @controller.stub!(:current_user).and_return(user) + sign_in :user, @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' end @@ -54,8 +52,8 @@ describe InvitationsController do end it "doesn't invite anyone if you have 0 invites" do - user.invites = 0 - user.save! + @user.invites = 0 + @user.save! lambda { post :create, :user => @invite.merge(:email => "mbs@gmail.com, foo@bar.com, foo.com, lala@foo, cool@bar.com") }.should_not change(User, :count) @@ -69,8 +67,8 @@ describe InvitationsController do describe "#update" do before do - user.invites = 5 - @invited_user = user.invite_user("a@a.com", user.aspects.first.id) + @user.invites = 5 + @invited_user = @user.invite_user("a@a.com", @aspect.id) @accept_params = {:user=> {:password_confirmation =>"password", :username=>"josh", @@ -91,7 +89,6 @@ describe InvitationsController do end it 'adds a pending request' do - put :update, @accept_params Request.where(:recipient_id => invited.person.id).count.should == 1 end @@ -100,7 +97,7 @@ describe InvitationsController do context 'failure' do before do @fail_params = @accept_params - @fail_params[:user][:username] = user.username + @fail_params[:user][:username] = @user.username end it 'stays on the invitation accept form' do put :update, @fail_params @@ -115,7 +112,7 @@ describe InvitationsController do describe '#new' do it 'renders' do - sign_in :user, user + sign_in :user, @user get :new end end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index b89cec9b3..614d6d33d 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -6,24 +6,24 @@ require 'spec_helper' describe NotificationsController do - let!(:user) { Factory.create(:user) } - let!(:aspect) { user.aspects.create(:name => "AWESOME!!") } before do - sign_in :user, user + @user = alice + @aspect = @user.aspects.first + sign_in :user, @user end describe '#update' 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 Notification.first.unread.should == false end 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) put :update, :id => note.id @@ -35,8 +35,8 @@ describe NotificationsController do describe "#read_all" do it 'marks all notifications as read' do 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 get :read_all @@ -47,7 +47,7 @@ describe NotificationsController do describe '#index' do it 'paginates the notifications' do 35.times do - Notification.create(:recipient_id => user.id) + Notification.create(:recipient_id => @user.id) end get :index diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 7d913f28c..1e51f2c38 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -7,21 +7,20 @@ require 'spec_helper' describe PeopleController do render_views - let(:user) { Factory.create(:user) } - let!(:aspect) { user.aspects.create(:name => "lame-os") } - before do - sign_in :user, user + @user = alice + @aspect = @user.aspects.first + sign_in :user, @user end describe '#similar_people' do before do @contacts = [] - @aspect1 = user.aspects.create(:name => "foos") - @aspect2 = user.aspects.create(:name => "bars") + @aspect1 = @user.aspects.create(:name => "foos") + @aspect2 = @user.aspects.create(:name => "bars") 3.times do - @contacts << Contact.create(:user => user, :person => Factory.create(:person)) + @contacts << Contact.create(:user => @user, :person => Factory.create(:person)) end end @@ -57,7 +56,7 @@ describe PeopleController do @contacts[0].save 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.save @contacts << c @@ -83,16 +82,16 @@ describe PeopleController do @everyone << Factory.create(:person) end - user.send_contact_request_to(@everyone[3], aspect) - user.send_contact_request_to(@everyone[2], aspect) - user.activate_contact(@everyone[4], aspect) - user.activate_contact(@everyone[5], aspect) + @user.send_contact_request_to(@everyone[3], @aspect) + @user.send_contact_request_to(@everyone[2], @aspect) + @user.activate_contact(@everyone[4], @aspect) + @user.activate_contact(@everyone[5], @aspect) - user.reload - user.aspects.reload + @user.reload + @user.aspects.reload @people = @everyone @people.length.should == 10 - @hashes = @controller.hashes_for_people(@people, user.aspects) + @hashes = @controller.hashes_for_people(@people, @user.aspects) end it 'has the correct result for no relationship' do hash = @hashes.first @@ -100,21 +99,21 @@ describe PeopleController do hash[:person].should == @people.first hash[:contact].should be_false hash[:request].should be_false - hash[:aspects].should == user.aspects + hash[:aspects].should == @user.aspects end it 'has the correct result for a connected person' do hash = @hashes[4] hash[:person].should == @people[4] hash[:contact].should be_true hash[:contact].should_not be_pending - hash[:aspects].should == user.aspects + hash[:aspects].should == @user.aspects end it 'has the correct result for a requested person' do hash = @hashes[2] hash[:person].should == @people[2] hash[:contact].should be_true hash[:contact].should be_pending - hash[:aspects].should == user.aspects + hash[:aspects].should == @user.aspects end end describe '#index' do @@ -144,14 +143,13 @@ describe PeopleController do assigns[:people].should =~ [@eugene, eugene2] end it 'shows a contact' do - user2 = Factory.create(:user) - connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience')) + user2 = bob get :index, :q => user2.person.profile.first_name.to_s response.should redirect_to user2.person end it 'shows a non-contact' do - user2 = Factory.create(:user) + user2 = eve user2.person.profile.searchable = true user2.save get :index, :q => user2.person.profile.first_name.to_s @@ -171,20 +169,20 @@ describe PeopleController do describe '#show' 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 end it 'renders with a post' do - user.post :status_message, :message => 'test more', :to => aspect.id - get :show, :id => user.person.id + @user.post :status_message, :message => 'test more', :to => @aspect.id + get :show, :id => @user.person.id response.should be_success end it 'renders with a post' do - message = user.post :status_message, :message => 'test more', :to => aspect.id - user.comment 'I mean it', :on => message - get :show, :id => user.person.id + message = @user.post :status_message, :message => 'test more', :to => @aspect.id + @user.comment 'I mean it', :on => message + get :show, :id => @user.person.id response.should be_success end @@ -194,25 +192,24 @@ describe PeopleController do end 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 end it "renders the show page of a contact" do - user2 = Factory.create(:user) - connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience')) + user2 = bob get :show, :id => user2.person.id response.should be_success end it "renders the show page of a non-contact" do - user2 = Factory.create(:user) + user2 = eve get :show, :id => user2.person.id response.should be_success end 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) get :show, :id => user2.person.id @@ -223,14 +220,14 @@ describe PeopleController do describe '#webfinger' do it 'enqueues a webfinger job' do - Resque.should_receive(:enqueue).with(Jobs::SocketWebfinger, user.id, user.diaspora_handle, anything).once - get :retrieve_remote, :diaspora_handle => user.diaspora_handle + Resque.should_receive(:enqueue).with(Jobs::SocketWebfinger, @user.id, @user.diaspora_handle, anything).once + get :retrieve_remote, :diaspora_handle => @user.diaspora_handle end end describe '#update' do it "sets the flash" do - put :update, :id => user.person.id, + put :update, :id => @user.person.id, :profile => { :image_url => "", :first_name => "Will", @@ -241,35 +238,35 @@ describe PeopleController do context 'with a profile photo set' do before do - @params = { :id => user.person.id, + @params = { :id => @user.person.id, :profile => {:image_url => "", - :last_name => user.person.profile.last_name, - :first_name => user.person.profile.first_name }} + :last_name => @user.person.profile.last_name, + :first_name => @user.person.profile.first_name }} - user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" - user.person.profile.save + @user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" + @user.person.profile.save end 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 - Person.find(user.person.id).profile.image_url.should == image_url + Person.find(@user.person.id).profile.image_url.should == image_url end end it 'does not allow mass assignment' do - person = user.person + person = @user.person new_user = Factory.create(:user) - person.owner_id.should == user.id - put :update, :id => user.person.id, :owner_id => new_user.id - Person.find(person.id).owner_id.should == user.id + person.owner_id.should == @user.id + put :update, :id => @user.person.id, :owner_id => new_user.id + Person.find(person.id).owner_id.should == @user.id end 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'} } 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 diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 23b0f8f7a..f9d64ad37 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -7,35 +7,31 @@ require 'spec_helper' describe PhotosController do 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 - connect_users(user1, aspect1, user2, aspect2) - photo1; photo2 - @controller.stub!(:current_user).and_return(user1) - sign_in :user, user1 + @user1 = alice + @user2 = bob + + @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 it 'has working context' do - photo1.url.should_not be_nil - Photo.find(photo1.id).url.should_not be_nil - photo2.url.should_not be_nil - Photo.find(photo2.id).url.should_not be_nil + @photo1.url.should_not be_nil + Photo.find(@photo1.id).url.should_not be_nil + @photo2.url.should_not be_nil + Photo.find(@photo2.id).url.should_not be_nil end describe '#create' do before do - @controller.stub!(:file_handler).and_return(File.open(fixture_name)) - @params = {:photo => {:user_file => File.open(fixture_name), :aspect_ids => "all"} } + @controller.stub!(:file_handler).and_return(uploaded_photo) + @params = {:photo => {:user_file => uploaded_photo, :aspect_ids => "all"} } end it 'can make a photo' do @@ -44,100 +40,100 @@ describe PhotosController do }.should change(Photo, :count).by(1) end 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 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 describe '#index' do it "displays the logged in user's pictures" do - get :index, :person_id => user1.person.id.to_s - assigns[:person].should == user1.person - assigns[:posts].should == [photo1] + get :index, :person_id => @user1.person.id.to_s + assigns[:person].should == @user1.person + assigns[:posts].should == [@photo1] end 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[:posts].should == [photo2] + assigns[:person].should == @user2.person + assigns[:posts].should == [@photo2] end end describe '#show' 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 - assigns[:photo].should == photo1 + assigns[:photo].should == @photo1 assigns[:ownership].should be_true end 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 - assigns[:photo].should == photo2 + assigns[:photo].should == @photo2 assigns[:ownership].should be_false end end describe '#edit' do it 'lets the user edit a photo' do - get :edit, :id => photo1.id + get :edit, :id => @photo1.id response.status.should == 200 end it 'does not let the user edit a photo that is not his' do - get :edit, :id => photo2.id - response.should redirect_to(:action => :index, :person_id => user1.person.id.to_s) + get :edit, :id => @photo2.id + response.should redirect_to(:action => :index, :person_id => @user1.person.id.to_s) end end describe '#destroy' do it 'allows the user to delete his photos' do - delete :destroy, :id => photo1.id - Photo.find_by_id(photo1.id).should be_nil + delete :destroy, :id => @photo1.id + Photo.find_by_id(@photo1.id).should be_nil end it 'will not let you destory posts you do not own' do - delete :destroy, :id => photo2.id - Photo.find_by_id(photo2.id).should be_true + delete :destroy, :id => @photo2.id + Photo.find_by_id(@photo2.id).should be_true end end describe "#update" do it "updates the caption of a photo" do - put :update, :id => photo1.id, :photo => { :caption => "now with lasers!" } - photo1.reload.caption.should == "now with lasers!" + put :update, :id => @photo1.id, :photo => { :caption => "now with lasers!" } + @photo1.reload.caption.should == "now with lasers!" end it "doesn't overwrite random attributes" do new_user = Factory.create(:user) params = { :caption => "now with lasers!", :person_id => new_user.id } - put :update, :id => photo1.id, :photo => params - photo1.reload.person_id.should == user1.person.id + put :update, :id => @photo1.id, :photo => params + @photo1.reload.person_id.should == @user1.person.id end it 'redirects if you do not have access to the post' do params = { :caption => "now with lasers!" } - put :update, :id => photo2.id, :photo => params - response.should redirect_to(:action => :index, :person_id => user1.person.id.to_s) + put :update, :id => @photo2.id, :photo => params + response.should redirect_to(:action => :index, :person_id => @user1.person.id.to_s) end end describe "#make_profile_photo" 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" end 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" end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 5c3426358..b75c9e53a 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -6,21 +6,21 @@ require 'spec_helper' describe PostsController do render_views - + before do - @user = Factory.create(:user) + @user = alice @controller.stub!(:current_user).and_return(nil) end describe '#show' 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 response.status= 200 end 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 response.status = 302 end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index fe714b2be..b3fe3cf36 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -7,60 +7,62 @@ require 'spec_helper' describe PublicsController do render_views - let(:user) { Factory.create(:user) } - let(:person) { Factory(:person) } + before do + @user = alice + @person = Factory(:person) + end describe '#receive' do let(:xml) { "" } 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 end it 'enqueues a receive job' do - Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, xml).once - post :receive, "id" => user.person.id.to_s, "xml" => xml + Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, @user.id, xml).once + post :receive, "id" => @user.person.id.to_s, "xml" => xml end it 'unescapes the xml before sending it to receive_salmon' do - aspect = user.aspects.create(:name => 'foo') - post1 = user.post(:status_message, :message => 'moms', :to => [aspect.id]) + aspect = @user.aspects.create(:name => 'foo') + post1 = @user.post(:status_message, :message => 'moms', :to => [aspect.id]) xml2 = post1.to_diaspora_xml 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) - 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 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' end 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 end end describe '#hcard' do it "succeeds" do - post :hcard, "id" => user.person.id.to_s + post :hcard, "id" => @user.person.id.to_s response.should be_success end it 'sets the person' do - post :hcard, "id" => user.person.id.to_s - assigns[:person].should == user.person + post :hcard, "id" => @user.person.id.to_s + assigns[:person].should == @user.person end 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 response.should be_not_found end @@ -68,8 +70,7 @@ describe PublicsController do describe '#webfinger' 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 end @@ -80,8 +81,7 @@ describe PublicsController do end 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 end diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index d6b0d19ea..92ec71b3c 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -7,17 +7,12 @@ require 'spec_helper' describe RequestsController do render_views before do - @user = Factory.create(:user) + @user = alice + @other_user = eve + @controller.stub!(:current_user).and_return(@user) sign_in :user, @user 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 describe '#destroy' do diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index d940243c6..6c4b70eb0 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -6,10 +6,6 @@ require 'spec_helper' describe ServicesController do render_views - let(:user) { Factory.create(:user) } - let!(:aspect) { user.aspects.create(:name => "lame-os") } - - let(:mock_access_token) { Object.new } let(:omniauth_auth) { @@ -21,20 +17,22 @@ describe ServicesController do } before do - sign_in :user, user - @controller.stub!(:current_user).and_return(user) + @user = alice + @aspect = @user.aspects.first + + sign_in :user, @user + @controller.stub!(:current_user).and_return(@user) mock_access_token.stub!(:token => "12345", :secret => "56789") end 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 + 4.times do + @user.services << Factory(:service) + end + get :index - assigns[:services].should == user.services + assigns[:services].should == @user.services end end @@ -43,18 +41,18 @@ describe ServicesController do request.env['omniauth.auth'] = omniauth_auth lambda{ post :create - }.should change(user.services, :count).by(1) + }.should change(@user.services, :count).by(1) end 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 post :create response.should redirect_to getting_started_path(:step => 3) end it 'redirects to services url' do - user.getting_started = false + @user.getting_started = false request.env['omniauth.auth'] = omniauth_auth post :create response.should redirect_to services_url @@ -63,23 +61,22 @@ describe ServicesController do it 'creates a twitter service' do Service.delete_all - user.getting_started = false + @user.getting_started = false request.env['omniauth.auth'] = omniauth_auth post :create - user.reload - user.services.first.class.name.should == "Services::Twitter" + @user.reload.services.first.class.name.should == "Services::Twitter" end end describe '#destroy' do before do @service1 = Factory.create(:service) - user.services << @service1 + @user.services << @service1 end it 'destroys a service selected by id' do lambda{ delete :destroy, :id => @service1.id - }.should change(user.services, :count).by(-1) + }.should change(@user.services, :count).by(-1) end end end diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index 970edbfda..c8bab6399 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -13,13 +13,13 @@ EOT describe SocketsController do render_views before do - @user = Factory.create(:user) + @user = alice @controller = SocketsController.new end describe 'actionhash' 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 @fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png' end diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 789c71d13..2b4f1926e 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -7,26 +7,25 @@ require 'spec_helper' describe StatusMessagesController do 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 - connect_users(user1, aspect1, user2, aspect2) + @user1 = alice + @user2 = bob + + @aspect1 = @user1.aspects.first + @aspect2 = @user2.aspects.first + request.env["HTTP_REFERER"] = "" - sign_in :user, user1 - @controller.stub!(:current_user).and_return(user1) - user1.reload + sign_in :user, @user1 + @controller.stub!(:current_user).and_return(@user1) + @user1.reload end describe '#show' 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! - user1.add_to_streams(message, [aspect1]) - user1.dispatch_post message, :to => aspect1.id + @user1.add_to_streams(message, [@aspect1]) + @user1.dispatch_post message, :to => @aspect1.id get :show, "id" => message.id.to_s response.should be_success @@ -39,7 +38,7 @@ describe StatusMessagesController do :public => "true", :message => "facebook, is that you?", }, - :aspect_ids => [aspect1.id.to_s] } + :aspect_ids => [@aspect1.id.to_s] } } it 'responds to js requests' do post :create, status_message_hash.merge(:format => 'js') @@ -47,14 +46,14 @@ describe StatusMessagesController do end 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 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 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 post :create, status_message_hash old_status_message.reload.message.should == 'hello' @@ -65,8 +64,8 @@ describe StatusMessagesController do fixture_filename = 'button.png' fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', fixture_filename) - @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) + @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) @photo1.save! @photo2.save! @@ -75,7 +74,7 @@ describe StatusMessagesController do @hash[:photos] = [@photo1.id.to_s, @photo2.id.to_s] end 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 end it "sets the pending bit of referenced photos" do @@ -87,8 +86,8 @@ describe StatusMessagesController do end describe '#destroy' do - let!(:message) {user1.post(:status_message, :message => "hey", :to => aspect1.id)} - let!(:message2) {user2.post(:status_message, :message => "hey", :to => aspect2.id)} + let!(:message) {@user1.post(:status_message, :message => "hey", :to => @aspect1.id)} + let!(:message2) {@user2.post(:status_message, :message => "hey", :to => @aspect2.id)} it 'let a user delete his photos' do delete :destroy, :id => message.id diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 7f1adfff8..84304444a 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' describe UsersController do render_views - let(:user) { Factory.create(:user) } - let!(:aspect) { user.aspects.create(:name => "lame-os") } + let(:user) { alice } + let!(:aspect) { user.aspects.first } let!(:old_password) { user.encrypted_password } let!(:old_language) { user.language } diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 0f1eb22c5..9b41426ed 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(:user) + @user = alice @person = Factory.create(:person) end @@ -41,7 +41,7 @@ describe ApplicationHelper do person_image_link(@person).should include(person_path(@person)) end end - + describe "#person_image_tag" do it "should not allow basic XSS/HTML" do @person.profile.first_name = "I'm

Evil" @@ -176,7 +176,7 @@ describe ApplicationHelper do message = '[link text](http://someurl.com "some title") [link text](http://someurl.com "some title")' markdownify(message).should == 'link text link text' end - + 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)" markdownify(message).should == 'This text with many links tests http, FTP, any protocol' @@ -199,7 +199,7 @@ describe ApplicationHelper do it 'skips inserting newlines if you pass the newlines option' do message = "These\nare\n\some\nnew\lines" res = markdownify(message, :newlines => false) - res.should == message + res.should == message end it 'generates breaklines' do @@ -207,7 +207,7 @@ describe ApplicationHelper do res = markdownify(message) res.should == "These
are
some
new
lines" end - + 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" res = markdownify(message) @@ -229,19 +229,19 @@ describe ApplicationHelper do person_link(@person).should include @person.diaspora_handle end - + 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_link(@person).should include @person.diaspora_handle end - + it "should not allow basic XSS/HTML" do @person.profile.first_name = "I'm

Evil" @person.profile.last_name = "I'm

Evil" person_link(@person).should_not include("

") - end + end end context 'performance' do before do diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb deleted file mode 100644 index c02743f40..000000000 --- a/spec/helpers/requests_helper_spec.rb +++ /dev/null @@ -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 diff --git a/spec/helpers/sockets_helper_spec.rb b/spec/helpers/sockets_helper_spec.rb deleted file mode 100644 index 4d93f00e6..000000000 --- a/spec/helpers/sockets_helper_spec.rb +++ /dev/null @@ -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 diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/stream_helper_spec.rb index 2247d6945..812845457 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/stream_helper_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' describe StreamHelper do before do - @user = Factory(:user) - @aspect = @user.aspects.create(:name => 'aspect') + @user = alice + @aspect = @user.aspects.first @post = @user.post(:status_message, :message => "hi", :to => @aspect.id) end 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}) end it 'renders it fast the second time' do diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index b6df383b4..5e8562aac 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -5,15 +5,17 @@ require 'spec_helper' describe UsersHelper 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 - first_name_or_username(user).should == user.person.profile.first_name + first_name_or_username(@user).should == @user.person.profile.first_name end it 'should display the username if the first name is empty' do - user.person.profile.first_name = "" - first_name_or_username(user).should == user.username + @user.person.profile.first_name = "" + first_name_or_username(@user).should == @user.username end end end diff --git a/spec/intergration/receiving_spec.rb b/spec/intergration/receiving_spec.rb index 310cfea33..afe49755f 100644 --- a/spec/intergration/receiving_spec.rb +++ b/spec/intergration/receiving_spec.rb @@ -6,73 +6,72 @@ require 'spec_helper' 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) zord = Postzord::Receiver.new(user, :person => person) zord.parse_and_receive(xml) end 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 it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do - contact = user.contact_for(user2.person) - user.add_contact_to_aspect(contact, user.aspects.create(:name => "villains")) - status = user2.build_post(:status_message, :message => "Users do things", :to => aspect2.id) + contact = @user1.contact_for(@user2.person) + @user1.add_contact_to_aspect(contact, @user1.aspects.create(:name => "villains")) + status = @user2.build_post(:status_message, :message => "Users do things", :to => @aspect2.id) 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 end 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 - user2.delete + @user2.delete status_message.destroy lambda { - receive_with_zord(user, user2.person, xml) + receive_with_zord(@user1, @user2.person, xml) }.should change(Post,:count).by(1) end it 'should not create new aspects on message receive' do - num_aspects = user.aspects.size + num_aspects = @user1.aspects.size 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 - user.aspects.size.should == num_aspects + @user1.aspects.size.should == num_aspects end context 'update posts' 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' 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!' end 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' 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/) end @@ -80,115 +79,116 @@ describe 'a user receives a post' do describe 'post refs' do before do - @status_message = user2.post :status_message, :message => "hi", :to => aspect2.id - user.reload - aspect.reload + @status_message = @user2.post :status_message, :message => "hi", :to => @aspect2.id + @user1.reload + @aspect.reload end it "adds a received post to the aspect and visible_posts array" do - user.raw_visible_posts.include?(@status_message).should be_true - aspect.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 end it 'removes posts upon disconnecting' do - user.disconnect(user2.person) - user.reload - user.raw_visible_posts.should_not include @status_message + @user1.disconnect(@user2.person) + @user1.reload + @user1.raw_visible_posts.should_not include @status_message end it 'deletes a post if the noone links to it' do person = Factory(:person) - user.activate_contact(person, aspect) + @user1.activate_contact(person, @aspect) post = Factory.create(:status_message, :person => person) post.post_visibilities.should be_empty - receive_with_zord(user, person, post.to_diaspora_xml) - aspect.post_visibilities.reset - aspect.posts(true).should include(post) + receive_with_zord(@user1, person, post.to_diaspora_xml) + @aspect.post_visibilities.reset + @aspect.posts(true).should include(post) post.post_visibilities.reset post.post_visibilities.length.should == 1 lambda { - user.disconnected_by(person) + @user1.disconnected_by(person) }.should change(Post, :count).by(-1) end it 'deletes post_visibilities on disconnected by' do person = Factory(:person) - user.activate_contact(person, aspect) + @user1.activate_contact(person, @aspect) post = Factory.create(:status_message, :person => person) post.post_visibilities.should be_empty - receive_with_zord(user, person, post.to_diaspora_xml) - aspect.post_visibilities.reset - aspect.posts(true).should include(post) + receive_with_zord(@user1, person, post.to_diaspora_xml) + @aspect.post_visibilities.reset + @aspect.posts(true).should include(post) post.post_visibilities.reset post.post_visibilities.length.should == 1 lambda { - user.disconnected_by(person) + @user1.disconnected_by(person) }.should change{post.post_visibilities(true).count}.by(-1) end it 'should keep track of user references for one person ' do @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.user_refs.should == 1 + @status_message.user_refs.should == 2 end it 'should not override userrefs on receive by another person' do - @status_message.post_visibilities.reset - @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) - + new_user = Factory(:user) @status_message.post_visibilities.reset @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.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 describe 'comments' do before do - connect_users(user, aspect, user3, aspect3) - @post = user.post :status_message, :message => "hello", :to => aspect.id + connect_users(@user1, @aspect, @user3, @aspect3) + @post = @user1.post :status_message, :message => "hello", :to => @aspect.id xml = @post.to_diaspora_xml - receive_with_zord(user2, user.person, xml) - receive_with_zord(user3, user.person, xml) + receive_with_zord(@user2, @user1.person, xml) + receive_with_zord(@user3, @user1.person, xml) - @comment = user3.comment('tada',:on => @post) - @comment.post_creator_signature = @comment.sign_with_key(user.encryption_key) + @comment = @user3.comment('tada',:on => @post) + @comment.post_creator_signature = @comment.sign_with_key(@user1.encryption_key) @xml = @comment.to_diaspora_xml @comment.delete end 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.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 it 'should correctly marshal a stranger for the downstream user' do - remote_person = user3.person.dup - user3.person.delete - user3.delete + remote_person = @user3.person.dup + @user3.person.delete + @user3.delete remote_person.id = nil #stubs async webfinger Person.should_receive(:by_account_identifier).twice.and_return{ |handle| - if handle == user.person.diaspora_handle - user.person.save - user.person + if handle == @user1.person.diaspora_handle + @user1.person.save + @user1.person else remote_person.profile = Factory(:profile) remote_person.save! @@ -196,27 +196,27 @@ describe 'a user receives a post' do 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.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 end end describe 'salmon' do - let(:post){user.post :status_message, :message => "hello", :to => aspect.id} - let(:salmon){user.salmon( post )} + let(:post){@user1.post :status_message, :message => "hello", :to => @aspect.id} + let(:salmon){@user1.salmon( post )} 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 - user2.raw_visible_posts.include?(post).should be_true + @user2.raw_visible_posts.include?(post).should be_true end end end diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index a3d3981ff..ed8f98ebf 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -8,21 +8,18 @@ require File.join(Rails.root, 'lib/diaspora/exporter') describe Diaspora::Exporter do before do - @user1 = Factory.create(:user) + @user1 = alice @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") @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_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) - - @user1.reload - @user2.reload end def exported @@ -50,8 +47,7 @@ describe Diaspora::Exporter do context '' do before do - connect_users(@user1, @aspect1, @user3, @aspect3) - @user1.add_contact_to_aspect(@user1.contact_for(@user3.person), @aspect) + @user1.add_contact_to_aspect(@user1.contact_for(@user3.person), @aspect1) @user1.reload end @@ -71,10 +67,7 @@ describe Diaspora::Exporter do context '' do 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 people_xml.should include @user3.person.guid end diff --git a/spec/lib/diaspora/ostatus_builder.rb b/spec/lib/diaspora/ostatus_builder.rb index 890c47516..687443104 100644 --- a/spec/lib/diaspora/ostatus_builder.rb +++ b/spec/lib/diaspora/ostatus_builder.rb @@ -8,8 +8,8 @@ require File.join(Rails.root, 'lib/diaspora/ostatus_builder') describe Diaspora::OstatusBuilder do - let!(:user) { Factory.create(:user) } - let(:aspect) { user.aspects.create(:name => "Public People") } + let!(:user) { alice } + let(:aspect) { user.aspects.first } let!(:public_status_messages) { 3.times.inject([]) do |arr,n| s = user.post(:status_message, :message => "hey#{n}", :public => true, :to => aspect.id) diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index b174948a6..2cab417bb 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -6,15 +6,20 @@ require 'spec_helper' describe Diaspora::Parser do before do - @user = Factory.create(:user) - @aspect = @user.aspects.create(:name => 'spies') - @user2 = Factory.create(:user) - @aspect2 = @user2.aspects.create(:name => "pandas") + @user1 = alice + @user2 = bob + @user3 = eve + + @aspect1 = @user1.aspects.first + @aspect2 = @user2.aspects.first + @aspect3 = @user3.aspects.first + @person = Factory.create(:person) end + describe "parsing compliant XML object" 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.delete xml = comment.to_diaspora_xml @@ -26,44 +31,41 @@ describe Diaspora::Parser do end it 'should accept retractions' do - connect_users(@user, @aspect, @user2, @aspect2) message = @user2.post(:status_message, :message => "cats", :to => @aspect2.id) retraction = Retraction.for(message) xml = retraction.to_diaspora_xml lambda { - zord = Postzord::Receiver.new(@user, :person => @user2.person) + zord = Postzord::Receiver.new(@user1, :person => @user2.person) zord.parse_and_receive(xml) }.should change(StatusMessage, :count).by(-1) end it "should activate the Person if I initiated a request to that url" do - @user.send_contact_request_to(@user2.person, @aspect) - request = @user2.request_from(@user.person) + @user1.send_contact_request_to(@user3.person, @aspect) + request = @user3.request_from(@user1.person) fantasy_resque do - @user2.accept_and_respond(request.id, @aspect2.id) + @user3.accept_and_respond(request.id, @aspect3.id) end - @user.reload + @user1.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 - @user.contacts.include?(new_contact).should be true + @user1.contacts.include?(new_contact).should be true end it 'should process retraction for a person' do - connect_users(@user, @aspect, @user2, @aspect2) retraction = Retraction.for(@user2) retraction_xml = retraction.to_diaspora_xml lambda { - zord = Postzord::Receiver.new(@user, :person => @user2.person) + zord = Postzord::Receiver.new(@user1, :person => @user2.person) zord.parse_and_receive(retraction_xml) }.should change { @aspect.contacts(true).size }.by(-1) end it 'should marshal a profile for a person' do - connect_users(@user, @aspect, @user2, @aspect2) #Create person person = @user2.person id = person.id @@ -85,7 +87,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Marshal profile - zord = Postzord::Receiver.new(@user, :person => person) + zord = Postzord::Receiver.new(@user1, :person => person) zord.parse_and_receive(xml) #Check that marshaled profile is the same as old profile diff --git a/spec/lib/diaspora/web_socket_spec.rb b/spec/lib/diaspora/web_socket_spec.rb index 0cb495cd1..eacfc9407 100644 --- a/spec/lib/diaspora/web_socket_spec.rb +++ b/spec/lib/diaspora/web_socket_spec.rb @@ -25,8 +25,8 @@ end describe Diaspora::Socketable do before do - @user = Factory.create(:user) - @aspect = @user.aspects.create(:name => "losers") + @user = alice + @aspect = @user.aspects.first @post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id) @post.save end diff --git a/spec/lib/diaspora/webhooks_spec.rb b/spec/lib/diaspora/webhooks_spec.rb index 590b737b7..99d2b0617 100644 --- a/spec/lib/diaspora/webhooks_spec.rb +++ b/spec/lib/diaspora/webhooks_spec.rb @@ -10,7 +10,7 @@ describe Diaspora::Webhooks do class Foo include Diaspora::Webhooks end - + f = Foo.new proc{ f.subscribers(1)}.should raise_error /override subscribers/ diff --git a/spec/lib/encryptor_spec.rb b/spec/lib/encryptor_spec.rb index 9f1e4d310..476afd08f 100644 --- a/spec/lib/encryptor_spec.rb +++ b/spec/lib/encryptor_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' describe 'user encryption' do before do - @user = Factory.create(:user) - @aspect = @user.aspects.create(:name => 'dudes') + @user = alice + @aspect = @user.aspects.first end describe 'encryption' do diff --git a/spec/lib/postzord/dispatch_spec.rb b/spec/lib/postzord/dispatch_spec.rb index 8e9b8ec77..14d13a24b 100644 --- a/spec/lib/postzord/dispatch_spec.rb +++ b/spec/lib/postzord/dispatch_spec.rb @@ -9,7 +9,7 @@ require File.join(Rails.root, 'lib/postzord/dispatch') describe Postzord::Dispatch do before do - @user = Factory(:user) + @user = alice @sm = Factory(:status_message, :public => true) @subscribers = [] 5.times{@subscribers << Factory(:person)} diff --git a/spec/lib/postzord/receiver_spec.rb b/spec/lib/postzord/receiver_spec.rb index ea97f533e..088c4ac0d 100644 --- a/spec/lib/postzord/receiver_spec.rb +++ b/spec/lib/postzord/receiver_spec.rb @@ -10,17 +10,14 @@ require File.join(Rails.root, 'lib/postzord/receiver') describe Postzord::Receiver do before do - @user = Factory(:user) - @user2 = Factory(:user) + @user = alice + @user2 = bob @person2 = @user2.person - aspect1 = @user.aspects.create(:name => "hey") - aspect2 = @user2.aspects.create(:name => "hey") - - connect_users(@user, aspect1, @user2, aspect2) + aspect1 = @user.aspects.first + aspect2 = @user2.aspects.first @original_post = @user2.build_post(:status_message, :message => "hey", :aspect_ids => [aspect2.id]) - @salmon_xml = @user2.salmon(@original_post).xml_for(@user.person) end diff --git a/spec/lib/pubsubhubbub_spec.rb b/spec/lib/pubsubhubbub_spec.rb index 6428a9aca..e1fe7bf92 100644 --- a/spec/lib/pubsubhubbub_spec.rb +++ b/spec/lib/pubsubhubbub_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' require File.join(Rails.root, 'lib', 'pubsubhubbub') describe Pubsubhubbub do - + before do RestClient.unstub!(:post) end @@ -15,9 +15,6 @@ describe Pubsubhubbub do RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success)) end - describe '#initialize' do - end - describe '#publish' do it 'posts the feed to the given hub' do hub = "http://hubzord.com/" diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index 210b9a916..4e4d4e088 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' describe Salmon do - let(:user){Factory.create(:user)} - let(:user2) {Factory.create(:user)} + let(:user){alice} + let(:user2) {eve} let(:user3) {Factory.create(:user)} 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 parsed_salmon.author_email = 'tom@tom.joindiaspora.com' - - + + proc {parsed_salmon.author.public_key}.should raise_error "did you remember to async webfinger?" end diff --git a/spec/lib/webfinger_spec.rb b/spec/lib/webfinger_spec.rb index 7c60e2658..712ad5e41 100644 --- a/spec/lib/webfinger_spec.rb +++ b/spec/lib/webfinger_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' require File.join(Rails.root, 'lib/webfinger') describe Webfinger do - let(:user1) { Factory.create(:user) } - let(:user2) { Factory.create(:user) } + let(:user1) { alice } + let(:user2) { eve } let(:account) {"foo@tom.joindiaspora.com"} let(:person){ Factory(:person, :diaspora_handle => account)} @@ -39,7 +39,7 @@ describe Webfinger do end end - context 'webfinger query chain processing' do + context 'webfinger query chain processing' do describe '#webfinger_profile_url' do it 'should parse out the webfinger template' do 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) RestClient.stub!(:get).and_return(diaspora_xrd, diaspora_finger, hcard_xml) #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.should be_valid end - + 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) RestClient.should_receive(:get).twice.and_return(nil, diaspora_xrd) diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 94509d091..e64bd47eb 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Notifier do - let!(:user) {Factory.create(:user)} - let!(:user2) {Factory.create(:user)} + let!(:user) {alice} + let!(:user2) {eve} let!(:aspect) {user.aspects.create(:name => "win")} let!(:aspect2) {user2.aspects.create(:name => "win")} diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index a80af2750..ae8adb5bd 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -5,13 +5,13 @@ require 'spec_helper' describe Aspect do - let(:user ) { Factory.create(:user) } + let(:user ) { alice } let(:connected_person) { Factory.create(:person) } - let(:user2) { Factory.create(:user) } + let(:user2) { eve } let(:connected_person_2) { Factory.create(:person) } - let(:aspect) {user.aspects.create(:name => 'losers')} - let(:aspect2) {user2.aspects.create(:name => 'failures')} + let(:aspect) {user.aspects.first } + let(:aspect2) {user2.aspects.first } let(:aspect1) {user.aspects.create(:name => 'cats')} let(:user3) {Factory.create(:user)} let(:aspect3) {user3.aspects.create(:name => "lala")} diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 7d7e480f4..921d5538c 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -5,13 +5,11 @@ require 'spec_helper' describe Comment do - let(:user) {Factory.create(:user)} - let(:aspect) {user.aspects.create(:name => "Doofuses")} + let(:user) {alice} + let(:aspect) {user.aspects.first} - let(:user2) {Factory.create(:user)} - let(:aspect2) {user2.aspects.create(:name => "Lame-faces")} - - let!(:connecting) { connect_users(user, aspect, user2, aspect2) } + let(:user2) {bob} + let(:aspect2) {user2.aspects.first} describe '.hash_from_post_ids' do before do diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index c16763270..29fe1e135 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe Invitation do - let(:user) {Factory.create(:user)} - let!(:aspect) {user.aspects.create(:name => "Invitees")} - let(:user2) {Factory.create(:user)} + let(:user) {alice} + let(:aspect) {user.aspects.first} + let(:user2) {eve} before do user.invites = 20 user.save diff --git a/spec/models/jobs/notify_local_users_spec.rb b/spec/models/jobs/notify_local_users_spec.rb index 2512f07c4..61286fe88 100644 --- a/spec/models/jobs/notify_local_users_spec.rb +++ b/spec/models/jobs/notify_local_users_spec.rb @@ -7,12 +7,12 @@ require 'spec_helper' describe Jobs::NotifyLocalUsers do describe '#perfom' do it 'should call Notification.notify on the object' do - user = Factory(:user) + user = alice person = Factory :person object = Factory :status_message 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) - end + end end end diff --git a/spec/models/jobs/post_to_service_spec.rb b/spec/models/jobs/post_to_service_spec.rb index 8e0b34511..3319d39e2 100644 --- a/spec/models/jobs/post_to_service_spec.rb +++ b/spec/models/jobs/post_to_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Jobs::PostToService do it 'calls service#post with the given service' do - user = Factory(:user) + user = alice aspect = user.aspects.create(:name => "yeah") post = user.post(:status_message, :message => 'foo', :to => aspect.id) User.stub!(:find_by_id).with(user.id.to_s).and_return(user) diff --git a/spec/models/jobs/post_to_services_spec.rb b/spec/models/jobs/post_to_services_spec.rb index 09809c5d1..706119adf 100644 --- a/spec/models/jobs/post_to_services_spec.rb +++ b/spec/models/jobs/post_to_services_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Jobs::PostToServices 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") post = user.post(:status_message, :message => 'foo', :to => aspect.id) User.stub!(:find_by_id).with(user.id.to_s).and_return(user) diff --git a/spec/models/jobs/receive_local_spec.rb b/spec/models/jobs/receive_local_spec.rb index 454d64e4e..4ea62d920 100644 --- a/spec/models/jobs/receive_local_spec.rb +++ b/spec/models/jobs/receive_local_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Jobs::ReceiveLocal do before do - @user1 = Factory.create(:user) - @user2 = Factory.create(:user) + @user1 = alice + @user2 = eve @status = Factory(:status_message) @status_type = @status.class.to_s diff --git a/spec/models/jobs/receive_salmon_spec.rb b/spec/models/jobs/receive_salmon_spec.rb index b5cd2f290..15bc2de2a 100644 --- a/spec/models/jobs/receive_salmon_spec.rb +++ b/spec/models/jobs/receive_salmon_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Jobs::ReceiveSalmon do before do - @user = Factory.create(:user) + @user = alice @xml = '' User.stub(:find){ |id| if id == @user.id diff --git a/spec/models/jobs/receive_spec.rb b/spec/models/jobs/receive_spec.rb index 0a93fba68..c5f34895e 100644 --- a/spec/models/jobs/receive_spec.rb +++ b/spec/models/jobs/receive_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Jobs::Receive do before do - @user = Factory.create(:user) + @user = alice @person = Factory(:person) @xml = '' User.stub(:find){ |id| diff --git a/spec/models/jobs/socket_webfinger_spec.rb b/spec/models/jobs/socket_webfinger_spec.rb index 4d1e53645..c17b70a07 100644 --- a/spec/models/jobs/socket_webfinger_spec.rb +++ b/spec/models/jobs/socket_webfinger_spec.rb @@ -2,7 +2,7 @@ require File.join(Rails.root, 'spec/spec_helper') describe Jobs::SocketWebfinger do before do - @user = Factory.create(:user) + @user = alice @account = "tom@tom.joindiaspora.com" end it 'Makes a Webfinger object' do @@ -30,7 +30,7 @@ describe Jobs::SocketWebfinger do Webfinger.stub(:new).and_return(finger) person = Factory.create(:person) finger.stub(:fetch).and_return(person) - + opts = {:symbol => true} person.should_receive(:socket_to_user).with(@user, opts) Jobs::SocketWebfinger.perform(@user.id, @account, opts) @@ -39,10 +39,10 @@ describe Jobs::SocketWebfinger do finger = mock() Webfinger.stub(:new).and_return(finger) finger.stub(:fetch).and_raise(Webfinger::WebfingerFailedError) - + 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) Jobs::SocketWebfinger.perform(@user.id, @account) - + end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index d7243ae44..85a5cfd53 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -8,8 +8,8 @@ describe Notification do before do @sm = Factory(:status_message) @person = Factory(:person) - @user = Factory.create(:user) - @user2 = Factory.create(:user) + @user = alice + @user2 = eve @aspect = @user.aspects.create(:name => "dudes") @opts = {:target_id => @sm.id, :target_type => @sm.class.name, diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 3609e84d7..4c9041ff2 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' describe Photo do before do - @user = Factory.create(:user) - @aspect = @user.aspects.create(:name => "losers") + @user = alice + @aspect = @user.aspects.first @fixture_filename = 'button.png' @fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename) diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 6236ae42a..2269e855f 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(:user) + @user = alice @aspect = @user.aspects.create(:name => "winners") end diff --git a/spec/models/post_visibility_spec.rb b/spec/models/post_visibility_spec.rb index cd371ba81..3c2cf91c3 100644 --- a/spec/models/post_visibility_spec.rb +++ b/spec/models/post_visibility_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe PostVisibility do before do - @user = Factory(:user) + @user = alice @aspect = @user.aspects.create(:name => 'Boozers') @person = Factory(:person) diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index da60168a4..5d2050bbc 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.create(:user) } + let(:user) { alice } let(:person) { Factory(:person) } let(:aspect) { user.aspects.create(:name => "Bruisers") } let!(:activation) { user.activate_contact(person, aspect) } diff --git a/spec/models/services/facebook_spec.rb b/spec/models/services/facebook_spec.rb index eb851e67f..dd911cd10 100644 --- a/spec/models/services/facebook_spec.rb +++ b/spec/models/services/facebook_spec.rb @@ -1,10 +1,9 @@ require 'spec_helper' -describe Services::Facebook do +describe Services::Facebook do before do - @user = Factory.create(:user) - @user.aspects.create(:name => "whatever") + @user = alice @post = @user.post(:status_message, :message => "hello", :to =>@user.aspects.first.id) @service = Services::Facebook.new(:access_token => "yeah") @user.services << @service @@ -12,7 +11,7 @@ describe Services::Facebook do describe '#post' 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) end it 'swallows exception raised by facebook always being down' do diff --git a/spec/models/services/twitter_spec.rb b/spec/models/services/twitter_spec.rb index ccf8b20d4..5d6005ced 100644 --- a/spec/models/services/twitter_spec.rb +++ b/spec/models/services/twitter_spec.rb @@ -1,10 +1,9 @@ require 'spec_helper' -describe Services::Twitter do +describe Services::Twitter do before do - @user = Factory.create(:user) - @user.aspects.create(:name => "whatever") + @user = alice @post = @user.post(:status_message, :message => "hello", :to =>@user.aspects.first.id) @service = Services::Twitter.new(:access_token => "yeah", :access_secret => "foobar") @user.services << @service @@ -12,7 +11,7 @@ describe Services::Twitter do describe '#post' 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) end diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index dc203946e..2d51d6cda 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' describe StatusMessage do before do - @user = Factory(:user) - @aspect = @user.aspects.create(:name => "losers") + @user = alice + @aspect = @user.aspects.first end describe '#diaspora_handle=' do diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index c5c93b0da..9978e5181 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -6,13 +6,13 @@ require 'spec_helper' describe "attack vectors" do - let(:user) { Factory.create(:user) } - let(:aspect) { user.aspects.create(:name => 'heroes') } + let(:user) { alice } + let(:aspect) { user.aspects.first } let(:bad_user) { Factory.create(:user)} - let(:user2) { Factory.create(:user) } - let(:aspect2) { user2.aspects.create(:name => 'losers') } + let(:user2) { eve } + let(:aspect2) { user2.aspects.first } let(:user3) { Factory.create(:user) } let(:aspect3) { user3.aspects.create(:name => 'heroes') } diff --git a/spec/models/user/commenting_spec.rb b/spec/models/user/commenting_spec.rb index bbf4561d5..8534549e5 100644 --- a/spec/models/user/commenting_spec.rb +++ b/spec/models/user/commenting_spec.rb @@ -6,13 +6,12 @@ require 'spec_helper' describe User do - let!(:user1){Factory.create(:user)} - let!(:user2){Factory.create(:user)} - let!(:aspect1){user1.aspects.create(:name => 'heroes')} - let!(:aspect2){user2.aspects.create(:name => 'others')} + let!(:user1){alice} + let!(:user2){bob} + let!(:aspect1){user1.aspects.first} + let!(:aspect2){user2.aspects.first} before do - connect_users(user1, aspect1, user2, aspect2) @post = user1.build_post(:status_message, :message => "hey", :to => aspect1.id) @post.save user1.dispatch_post(@post, :to => "all") @@ -23,7 +22,7 @@ describe User do it "doesn't call receive on local users" do user1.should_not_receive(:receive_comment) user2.should_not_receive(:receive_comment) - + comment = user2.build_comment "why so formal?", :on => @post comment.save! user2.dispatch_comment comment @@ -34,7 +33,7 @@ describe User do it "doesn't call receive on local users" do user1.should_not_receive(:receive_comment) user2.should_not_receive(:receive_comment) - + comment = user1.build_comment "why so formal?", :on => @post comment.save! user1.dispatch_comment comment diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index d0b9be4ab..d27655352 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe Diaspora::UserModules::Connecting do - let(:user) { Factory.create(:user) } + let(:user) { alice } let(:aspect) { user.aspects.create(:name => 'heroes') } let(:aspect1) { user.aspects.create(:name => 'other') } let(:person) { Factory.create(:person) } @@ -14,7 +14,7 @@ describe Diaspora::UserModules::Connecting do let(:person_two) { 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") } describe '#send_contact_request_to' do diff --git a/spec/models/user/invite_spec.rb b/spec/models/user/invite_spec.rb index 0e120e6b2..7f5c9612a 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) {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(:another_user) {Factory.create(:user)} + let(:another_user) {alice} 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(:aspect2) {inviter_with_3_invites.aspects.create(:name => "Jersey Girls")} diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 8615e6de4..eef990404 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -6,12 +6,12 @@ require 'spec_helper' describe User do - let!(:user) { Factory.create(:user) } - let!(:user2) { Factory.create(:user) } + let!(:user) { alice } + let!(:user2) { eve } - let!(:aspect) { user.aspects.create(:name => 'heroes') } + let!(:aspect) { user.aspects.first } 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!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s } diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index 875b2963a..0b7ba0ef7 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -7,9 +7,9 @@ require 'spec_helper' describe User do before do - @user = Factory(:user) - @aspect = @user.aspects.create(:name => "cats") - @user2 = Factory(:user_with_aspect) + @user = alice + @aspect = @user.aspects.first + @user2 = eve @aspect2 = @user2.aspects.first @person_one = Factory.create :person diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a7df19be0..ef1a48569 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.create(:user) } + let(:user) { alice } let(:aspect) { user.aspects.create(:name => 'heroes') } - let(:user2) { Factory.create(:user) } + let(:user2) { eve } let(:aspect2) { user2.aspects.create(:name => 'stuff') } it 'should have a key' do @@ -16,7 +16,6 @@ describe User do describe 'overwriting people' 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.persisted?.should be_true new_user.id.should_not == user.id diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b824f3dfd..45bd7401a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,12 +21,13 @@ include HelperMethods Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| - #DatabaseCleaner.strategy = nil config.mock_with :mocha config.mock_with :rspec config.use_transactional_fixtures = true + config.global_fixtures = :all + config.before(:each) do I18n.locale = :en RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success)) @@ -36,14 +37,17 @@ RSpec.configure do |config| end def alice + #users(:alice) User.where(:username => 'alice').first end def bob + #users(:bob) User.where(:username => 'bob').first end def eve + #users(:eve) User.where(:username => 'eve').first end module Diaspora::WebSocket From 88ebd14799123d69c171cc2d61d1648f1fbedc47 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 14:53:46 -0800 Subject: [PATCH 06/10] Fixture builder working, need to make specs not require a clean db --- spec/fixtures/aspect_memberships.yml | 16 ++-- spec/fixtures/aspects.yml | 18 ++-- spec/fixtures/contacts.yml | 32 +++---- spec/fixtures/people.yml | 78 ++++++++--------- spec/fixtures/profiles.yml | 72 ++++++++-------- spec/fixtures/users.yml | 114 ++++++++++++------------- spec/lib/diaspora/parser_spec.rb | 10 +-- spec/models/jobs/receive_local_spec.rb | 8 +- spec/spec_helper.rb | 3 +- spec/support/fixture_builder.rb | 2 +- 10 files changed, 177 insertions(+), 176 deletions(-) diff --git a/spec/fixtures/aspect_memberships.yml b/spec/fixtures/aspect_memberships.yml index 4a5f858e3..e2d5d3eb4 100644 --- a/spec/fixtures/aspect_memberships.yml +++ b/spec/fixtures/aspect_memberships.yml @@ -1,25 +1,25 @@ --- aspect_memberships_002: - created_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z aspect_id: 1 - updated_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 22:45:18 Z contact_id: 2 id: 2 aspect_memberships_003: - created_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z aspect_id: 2 - updated_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 22:45:18 Z contact_id: 3 id: 3 aspect_memberships_004: - created_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z aspect_id: 3 - updated_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 22:45:18 Z contact_id: 4 id: 4 aspect_memberships_001: - created_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z aspect_id: 2 - updated_at: 2011-01-18 18:44:07 Z + updated_at: 2011-01-18 22:45:18 Z contact_id: 1 id: 1 diff --git a/spec/fixtures/aspects.yml b/spec/fixtures/aspects.yml index 08ba5e30c..5322d4d24 100644 --- a/spec/fixtures/aspects.yml +++ b/spec/fixtures/aspects.yml @@ -2,24 +2,24 @@ generic_1: name: generic mongo_id: - created_at: 2011-01-18 18:44:06 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:17 Z + updated_at: 2011-01-18 22:45:17 Z id: 2 user_mongo_id: - user_id: 4 + user_id: 2 generic_2: name: generic mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:17 Z + updated_at: 2011-01-18 22:45:18 Z id: 3 user_mongo_id: - user_id: 5 + user_id: 3 generic: name: generic mongo_id: - created_at: 2011-01-18 18:44:06 Z - updated_at: 2011-01-18 18:44:06 Z + created_at: 2011-01-18 22:45:17 Z + updated_at: 2011-01-18 22:45:17 Z id: 1 user_mongo_id: - user_id: 3 + user_id: 1 diff --git a/spec/fixtures/contacts.yml b/spec/fixtures/contacts.yml index 9c788d0ad..402513b89 100644 --- a/spec/fixtures/contacts.yml +++ b/spec/fixtures/contacts.yml @@ -2,32 +2,32 @@ contacts_003: pending: false mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z + updated_at: 2011-01-18 22:45:18 Z id: 3 - user_id: 4 - person_id: 5 + user_id: 2 + person_id: 3 contacts_004: pending: false mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z + updated_at: 2011-01-18 22:45:18 Z id: 4 - user_id: 5 - person_id: 4 + user_id: 3 + person_id: 2 contacts_001: pending: false mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z + updated_at: 2011-01-18 22:45:18 Z id: 1 - user_id: 4 - person_id: 3 + user_id: 2 + person_id: 1 contacts_002: pending: false mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z + updated_at: 2011-01-18 22:45:18 Z id: 2 - user_id: 3 - person_id: 4 + user_id: 1 + person_id: 2 diff --git a/spec/fixtures/people.yml b/spec/fixtures/people.yml index 95b3f2321..c0694a984 100644 --- a/spec/fixtures/people.yml +++ b/spec/fixtures/people.yml @@ -1,49 +1,49 @@ --- people_001: mongo_id: - created_at: 2011-01-18 18:44:06 Z - guid: 89e32c010f204d98 - updated_at: 2011-01-18 18:44:06 Z - url: http://google-1d915c9.com/ + created_at: 2011-01-18 22:45:17 Z + guid: a26933a9a45ac375 + updated_at: 2011-01-18 22:45:17 Z + url: http://google-1eac19e.com/ serialized_public_key: | -----BEGIN RSA PUBLIC KEY----- - MIGJAoGBAPEQ08ZWNCiEh/fV/aQ19fMGdeK2r0ns+MB8kcbrkduTqvQ/c/RFkhJX - KWti8QomQVudx30mKMuD+r8XY48xw3H3XQDK2rtpFQmgJ4f/Wj4E6yFJo5pC7OL9 - 253WWqLGAJOJy9IxF76Mlo9Qazm7Z7aj1zp5kUXYusge2XAfkb0fAgMBAAE= + MIGJAoGBAKw1mMlExMJ9k5Q1E1EEPpmhqbFHdnxX7V5RIMKCwAgOq++SrzXlJfKv + nP11IK3CFZ1E+G/8H/MBf1insc9wQrjKQLlEN4UbeiPA2ahqAPApJ7PpyQBlaN4f + NjQyEm3M1QgdemiBzVYUZOU1gfkKpDoPPMIFgqKkl8O6ZJe6pcrfAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: 1 + id: 1 + diaspora_handle: alice@example.org +people_002: + mongo_id: + created_at: 2011-01-18 22:45:17 Z + guid: d04ada2056f7202c + updated_at: 2011-01-18 22:45:17 Z + url: http://google-2542fc1.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAKw1mMlExMJ9k5Q1E1EEPpmhqbFHdnxX7V5RIMKCwAgOq++SrzXlJfKv + nP11IK3CFZ1E+G/8H/MBf1insc9wQrjKQLlEN4UbeiPA2ahqAPApJ7PpyQBlaN4f + NjQyEm3M1QgdemiBzVYUZOU1gfkKpDoPPMIFgqKkl8O6ZJe6pcrfAgMBAAE= + -----END RSA PUBLIC KEY----- + + owner_id: 2 + id: 2 + diaspora_handle: bob@example.org +people_003: + mongo_id: + created_at: 2011-01-18 22:45:18 Z + guid: 03637d1d38abd29d + updated_at: 2011-01-18 22:45:18 Z + url: http://google-3a77e5a.com/ + serialized_public_key: | + -----BEGIN RSA PUBLIC KEY----- + MIGJAoGBAKw1mMlExMJ9k5Q1E1EEPpmhqbFHdnxX7V5RIMKCwAgOq++SrzXlJfKv + nP11IK3CFZ1E+G/8H/MBf1insc9wQrjKQLlEN4UbeiPA2ahqAPApJ7PpyQBlaN4f + NjQyEm3M1QgdemiBzVYUZOU1gfkKpDoPPMIFgqKkl8O6ZJe6pcrfAgMBAAE= -----END RSA PUBLIC KEY----- owner_id: 3 id: 3 - diaspora_handle: alice@example.org -people_002: - mongo_id: - created_at: 2011-01-18 18:44:07 Z - guid: 5d3d9ce10a10eafe - updated_at: 2011-01-18 18:44:07 Z - url: http://google-245c017.com/ - serialized_public_key: | - -----BEGIN RSA PUBLIC KEY----- - MIGJAoGBAPEQ08ZWNCiEh/fV/aQ19fMGdeK2r0ns+MB8kcbrkduTqvQ/c/RFkhJX - KWti8QomQVudx30mKMuD+r8XY48xw3H3XQDK2rtpFQmgJ4f/Wj4E6yFJo5pC7OL9 - 253WWqLGAJOJy9IxF76Mlo9Qazm7Z7aj1zp5kUXYusge2XAfkb0fAgMBAAE= - -----END RSA PUBLIC KEY----- - - owner_id: 4 - id: 4 - diaspora_handle: bob@example.org -people_003: - mongo_id: - created_at: 2011-01-18 18:44:07 Z - guid: 742a7d253debf2d6 - updated_at: 2011-01-18 18:44:07 Z - url: http://google-330296d.com/ - serialized_public_key: | - -----BEGIN RSA PUBLIC KEY----- - MIGJAoGBAPEQ08ZWNCiEh/fV/aQ19fMGdeK2r0ns+MB8kcbrkduTqvQ/c/RFkhJX - KWti8QomQVudx30mKMuD+r8XY48xw3H3XQDK2rtpFQmgJ4f/Wj4E6yFJo5pC7OL9 - 253WWqLGAJOJy9IxF76Mlo9Qazm7Z7aj1zp5kUXYusge2XAfkb0fAgMBAAE= - -----END RSA PUBLIC KEY----- - - owner_id: 5 - id: 5 diaspora_handle: eve@example.org diff --git a/spec/fixtures/profiles.yml b/spec/fixtures/profiles.yml index 97cf135d7..6517a4f44 100644 --- a/spec/fixtures/profiles.yml +++ b/spec/fixtures/profiles.yml @@ -2,48 +2,48 @@ profiles_001: image_url_medium: mongo_id: - created_at: 2011-01-18 18:44:06 Z + created_at: 2011-01-18 22:45:17 Z searchable: true image_url: - updated_at: 2011-01-18 18:44:06 Z + updated_at: 2011-01-18 22:45:17 Z + id: 1 + gender: + diaspora_handle: + person_id: 1 + last_name: Grimm12900f1 + birthday: + image_url_small: + bio: + first_name: Robert1459630 +profiles_002: + image_url_medium: + mongo_id: + created_at: 2011-01-18 22:45:17 Z + searchable: true + image_url: + updated_at: 2011-01-18 22:45:17 Z + id: 2 + gender: + diaspora_handle: + person_id: 2 + last_name: Grimm2f63d16 + birthday: + image_url_small: + bio: + first_name: Robert26c81a0 +profiles_003: + image_url_medium: + mongo_id: + created_at: 2011-01-18 22:45:17 Z + searchable: true + image_url: + updated_at: 2011-01-18 22:45:18 Z id: 3 gender: diaspora_handle: person_id: 3 - last_name: Grimm1a80b30 + last_name: Grimm3f266bd birthday: image_url_small: bio: - first_name: Robert19c3152 -profiles_002: - image_url_medium: - mongo_id: - created_at: 2011-01-18 18:44:06 Z - searchable: true - image_url: - updated_at: 2011-01-18 18:44:07 Z - id: 4 - gender: - diaspora_handle: - person_id: 4 - last_name: Grimm295050b - birthday: - image_url_small: - bio: - first_name: Robert2909f07 -profiles_003: - image_url_medium: - mongo_id: - created_at: 2011-01-18 18:44:07 Z - searchable: true - image_url: - updated_at: 2011-01-18 18:44:07 Z - id: 5 - gender: - diaspora_handle: - person_id: 5 - last_name: Grimm3c16b10 - birthday: - image_url_small: - bio: - first_name: Robert3574823 + first_name: Robert3938df3 diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 02648fdf6..ddea41d5e 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -1,35 +1,35 @@ --- alice: - encrypted_password: $2a$10$10wn.2788it4RyLvmIqap.zJfK8kAoM7IVsD6l0vPyzxQY7aH4m4m + encrypted_password: $2a$10$xbdc6ex5521gL/zGLbweNuF9echW6Q74L8sNu.Cug1e9fjBo2AZV6 serialized_private_key: | -----BEGIN RSA PRIVATE KEY----- - MIICXQIBAAKBgQDxENPGVjQohIf31f2kNfXzBnXitq9J7PjAfJHG65Hbk6r0P3P0 - RZISVylrYvEKJkFbncd9JijLg/q/F2OPMcNx910Aytq7aRUJoCeH/1o+BOshSaOa - Quzi/dud1lqixgCTicvSMRe+jJaPUGs5u2e2o9c6eZFF2LrIHtlwH5G9HwIDAQAB - AoGAIk7BxPVZwPZzn1ruGSOw2CBwQI69TakTEdnoqUW3YWeXqeEp8HbCPif3dhgD - s+0T2iUPUglPPv+OfQmoGqX7aYMTJOIrFPxYkBKkbfW8ZoNy/GHibblLJscJ54iF - iJcGL6bBGga36QSA+aw29N7+qtMQdebsBHsj6qZpFxS+N3ECQQD6/t4eX8BdHKoB - IfWpZV1JETyZAE+sGiUUF3QgyE3C7v5o99xtEZ6jvRMcwURf/3Dw3FeATSAgVC0Q - LReupEHZAkEA9d9GkOyioKoAEmVfjc08va0otSv9OR81MYWfXRuCliMMQC3wHdU4 - kr912zY2FDHLZtxy12YImDG/hpHYbpYjtwJBALvoIxJKTRFobD381pXDNVuGc/93 - pC4MRMYN6PrB+rV9hym+pl9hWYrr+msEpdPYwQ0RaNC87NhHLJV3rMsqXcECQFC8 - UF+mVICNUhi4UPgvPJLMGWHkX/Ix3TW1uu7H6cmDGLK6Yu5o5XrKg9jHpFpdP303 - Rj6Usp3HOCzoFzm482ECQQCYJ01wP0IsjFruXqhlclYxk/1cKuRt5NmhkNflJSWl - BrEFy9v3tTGVI6AAR1S7cYWFEyOj0OICMOqGHU72GIIv + MIICXgIBAAKBgQCsNZjJRMTCfZOUNRNRBD6ZoamxR3Z8V+1eUSDCgsAIDqvvkq81 + 5SXyr5z9dSCtwhWdRPhv/B/zAX9Yp7HPcEK4ykC5RDeFG3ojwNmoagDwKSez6ckA + ZWjeHzY0MhJtzNUIHXpogc1WFGTlNYH5CqQ6DzzCBYKipJfDumSXuqXK3wIDAQAB + AoGBAJt8pSANBG7q/WYS6gb7gx4p9lKHyLaKmVrQe3jEn2hm/t0IH0TVSocuAtxi + dggNNoDSdlJ+XcaGspm0h/pZTROa05er055twa4JxdwFTxGpv6pBgV56TXugzsYD + fF+pQQmfSl0TZ7nTL1DHWlGufrBUyOQ0cevcEvwlzUCdkhHpAkEA1+QVzevb0rCf + jf4GOG/D9PrgJBPtkhglxm81deQntfkfaNZLkMGEds41REijiEoftOPEdHt7Porq + sQuGdCTZ0wJBAMwz/InrGxlTxLky1dcZd+2DJCQks2OFBnyzf0kamN7KoEBv0K/w + yX/1C0JFu6h/6UTe9E+k4Xfnzhm+K9byd0UCQQDPlvDkbbuU7uKtHSqMD+Qj5yup + ZUQWK4P/N6X3MyiAEQkDvLMygPHHb2bGvvYIMgYk4LJhsu6B5//dt5BUk66jAkBy + aSIyZ+6r9xo+pXPYa6WdBqAGPCXiOZMT5UIIxIUoNqEo2T00hpVvQu1G+WkWFGyv + MLfzs668Dr2UAM/xQ7J9AkEAoR9VaZemxV8thA+w8EeIeBWjAjFY2kZJpPJIQIEv + VtOzYCHm0WXjuyyKHY9AOPLEO9RB4XXW0qmtE28kUCMXGw== -----END RSA PRIVATE KEY----- mongo_id: - created_at: 2011-01-18 18:44:06 Z - updated_at: 2011-01-18 18:44:06 Z + created_at: 2011-01-18 22:45:17 Z + updated_at: 2011-01-18 22:45:17 Z last_sign_in_ip: invites: 0 username: alice last_sign_in_at: language: en sign_in_count: 0 - id: 3 + id: 1 disable_mail: false - password_salt: $2a$10$10wn.2788it4RyLvmIqap. + password_salt: $2a$10$xbdc6ex5521gL/zGLbweNu reset_password_token: remember_token: current_sign_in_ip: @@ -38,38 +38,38 @@ alice: invitation_sent_at: invitation_token: getting_started: true - email: bob1f866f6@pivotallabs.com + email: bob1810d2e@pivotallabs.com eve: - encrypted_password: $2a$10$uDyK3VOraaekpPhbr8dPjuGqdshJlt9vSRUWvh9R1obnqqMgp60ry + encrypted_password: $2a$10$MunrAlmGUbgmhg0gYo/cqOPm5ObMjHA/rWsSVZiKD1ue0yFQ2AGbO serialized_private_key: | -----BEGIN RSA PRIVATE KEY----- - MIICXQIBAAKBgQDxENPGVjQohIf31f2kNfXzBnXitq9J7PjAfJHG65Hbk6r0P3P0 - RZISVylrYvEKJkFbncd9JijLg/q/F2OPMcNx910Aytq7aRUJoCeH/1o+BOshSaOa - Quzi/dud1lqixgCTicvSMRe+jJaPUGs5u2e2o9c6eZFF2LrIHtlwH5G9HwIDAQAB - AoGAIk7BxPVZwPZzn1ruGSOw2CBwQI69TakTEdnoqUW3YWeXqeEp8HbCPif3dhgD - s+0T2iUPUglPPv+OfQmoGqX7aYMTJOIrFPxYkBKkbfW8ZoNy/GHibblLJscJ54iF - iJcGL6bBGga36QSA+aw29N7+qtMQdebsBHsj6qZpFxS+N3ECQQD6/t4eX8BdHKoB - IfWpZV1JETyZAE+sGiUUF3QgyE3C7v5o99xtEZ6jvRMcwURf/3Dw3FeATSAgVC0Q - LReupEHZAkEA9d9GkOyioKoAEmVfjc08va0otSv9OR81MYWfXRuCliMMQC3wHdU4 - kr912zY2FDHLZtxy12YImDG/hpHYbpYjtwJBALvoIxJKTRFobD381pXDNVuGc/93 - pC4MRMYN6PrB+rV9hym+pl9hWYrr+msEpdPYwQ0RaNC87NhHLJV3rMsqXcECQFC8 - UF+mVICNUhi4UPgvPJLMGWHkX/Ix3TW1uu7H6cmDGLK6Yu5o5XrKg9jHpFpdP303 - Rj6Usp3HOCzoFzm482ECQQCYJ01wP0IsjFruXqhlclYxk/1cKuRt5NmhkNflJSWl - BrEFy9v3tTGVI6AAR1S7cYWFEyOj0OICMOqGHU72GIIv + MIICXgIBAAKBgQCsNZjJRMTCfZOUNRNRBD6ZoamxR3Z8V+1eUSDCgsAIDqvvkq81 + 5SXyr5z9dSCtwhWdRPhv/B/zAX9Yp7HPcEK4ykC5RDeFG3ojwNmoagDwKSez6ckA + ZWjeHzY0MhJtzNUIHXpogc1WFGTlNYH5CqQ6DzzCBYKipJfDumSXuqXK3wIDAQAB + AoGBAJt8pSANBG7q/WYS6gb7gx4p9lKHyLaKmVrQe3jEn2hm/t0IH0TVSocuAtxi + dggNNoDSdlJ+XcaGspm0h/pZTROa05er055twa4JxdwFTxGpv6pBgV56TXugzsYD + fF+pQQmfSl0TZ7nTL1DHWlGufrBUyOQ0cevcEvwlzUCdkhHpAkEA1+QVzevb0rCf + jf4GOG/D9PrgJBPtkhglxm81deQntfkfaNZLkMGEds41REijiEoftOPEdHt7Porq + sQuGdCTZ0wJBAMwz/InrGxlTxLky1dcZd+2DJCQks2OFBnyzf0kamN7KoEBv0K/w + yX/1C0JFu6h/6UTe9E+k4Xfnzhm+K9byd0UCQQDPlvDkbbuU7uKtHSqMD+Qj5yup + ZUQWK4P/N6X3MyiAEQkDvLMygPHHb2bGvvYIMgYk4LJhsu6B5//dt5BUk66jAkBy + aSIyZ+6r9xo+pXPYa6WdBqAGPCXiOZMT5UIIxIUoNqEo2T00hpVvQu1G+WkWFGyv + MLfzs668Dr2UAM/xQ7J9AkEAoR9VaZemxV8thA+w8EeIeBWjAjFY2kZJpPJIQIEv + VtOzYCHm0WXjuyyKHY9AOPLEO9RB4XXW0qmtE28kUCMXGw== -----END RSA PRIVATE KEY----- mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:18 Z + updated_at: 2011-01-18 22:45:18 Z last_sign_in_ip: invites: 0 username: eve last_sign_in_at: language: en sign_in_count: 0 - id: 5 + id: 3 disable_mail: false - password_salt: $2a$10$uDyK3VOraaekpPhbr8dPju + password_salt: $2a$10$MunrAlmGUbgmhg0gYo/cqO reset_password_token: remember_token: current_sign_in_ip: @@ -78,38 +78,38 @@ eve: invitation_sent_at: invitation_token: getting_started: true - email: bob3884c35@pivotallabs.com + email: bob3d6acb8@pivotallabs.com bob: - encrypted_password: $2a$10$YXDxHoVUIaIgyS405RS3NeenGVRrexiZei0.7l.LbyLDf.YqtCvfS + encrypted_password: $2a$10$O07zBbVmaUpAyLo6nBmOAur5BcrXLmb5kKRrx2eX04qo3Bi0uXWfu serialized_private_key: | -----BEGIN RSA PRIVATE KEY----- - MIICXQIBAAKBgQDxENPGVjQohIf31f2kNfXzBnXitq9J7PjAfJHG65Hbk6r0P3P0 - RZISVylrYvEKJkFbncd9JijLg/q/F2OPMcNx910Aytq7aRUJoCeH/1o+BOshSaOa - Quzi/dud1lqixgCTicvSMRe+jJaPUGs5u2e2o9c6eZFF2LrIHtlwH5G9HwIDAQAB - AoGAIk7BxPVZwPZzn1ruGSOw2CBwQI69TakTEdnoqUW3YWeXqeEp8HbCPif3dhgD - s+0T2iUPUglPPv+OfQmoGqX7aYMTJOIrFPxYkBKkbfW8ZoNy/GHibblLJscJ54iF - iJcGL6bBGga36QSA+aw29N7+qtMQdebsBHsj6qZpFxS+N3ECQQD6/t4eX8BdHKoB - IfWpZV1JETyZAE+sGiUUF3QgyE3C7v5o99xtEZ6jvRMcwURf/3Dw3FeATSAgVC0Q - LReupEHZAkEA9d9GkOyioKoAEmVfjc08va0otSv9OR81MYWfXRuCliMMQC3wHdU4 - kr912zY2FDHLZtxy12YImDG/hpHYbpYjtwJBALvoIxJKTRFobD381pXDNVuGc/93 - pC4MRMYN6PrB+rV9hym+pl9hWYrr+msEpdPYwQ0RaNC87NhHLJV3rMsqXcECQFC8 - UF+mVICNUhi4UPgvPJLMGWHkX/Ix3TW1uu7H6cmDGLK6Yu5o5XrKg9jHpFpdP303 - Rj6Usp3HOCzoFzm482ECQQCYJ01wP0IsjFruXqhlclYxk/1cKuRt5NmhkNflJSWl - BrEFy9v3tTGVI6AAR1S7cYWFEyOj0OICMOqGHU72GIIv + MIICXgIBAAKBgQCsNZjJRMTCfZOUNRNRBD6ZoamxR3Z8V+1eUSDCgsAIDqvvkq81 + 5SXyr5z9dSCtwhWdRPhv/B/zAX9Yp7HPcEK4ykC5RDeFG3ojwNmoagDwKSez6ckA + ZWjeHzY0MhJtzNUIHXpogc1WFGTlNYH5CqQ6DzzCBYKipJfDumSXuqXK3wIDAQAB + AoGBAJt8pSANBG7q/WYS6gb7gx4p9lKHyLaKmVrQe3jEn2hm/t0IH0TVSocuAtxi + dggNNoDSdlJ+XcaGspm0h/pZTROa05er055twa4JxdwFTxGpv6pBgV56TXugzsYD + fF+pQQmfSl0TZ7nTL1DHWlGufrBUyOQ0cevcEvwlzUCdkhHpAkEA1+QVzevb0rCf + jf4GOG/D9PrgJBPtkhglxm81deQntfkfaNZLkMGEds41REijiEoftOPEdHt7Porq + sQuGdCTZ0wJBAMwz/InrGxlTxLky1dcZd+2DJCQks2OFBnyzf0kamN7KoEBv0K/w + yX/1C0JFu6h/6UTe9E+k4Xfnzhm+K9byd0UCQQDPlvDkbbuU7uKtHSqMD+Qj5yup + ZUQWK4P/N6X3MyiAEQkDvLMygPHHb2bGvvYIMgYk4LJhsu6B5//dt5BUk66jAkBy + aSIyZ+6r9xo+pXPYa6WdBqAGPCXiOZMT5UIIxIUoNqEo2T00hpVvQu1G+WkWFGyv + MLfzs668Dr2UAM/xQ7J9AkEAoR9VaZemxV8thA+w8EeIeBWjAjFY2kZJpPJIQIEv + VtOzYCHm0WXjuyyKHY9AOPLEO9RB4XXW0qmtE28kUCMXGw== -----END RSA PRIVATE KEY----- mongo_id: - created_at: 2011-01-18 18:44:07 Z - updated_at: 2011-01-18 18:44:07 Z + created_at: 2011-01-18 22:45:17 Z + updated_at: 2011-01-18 22:45:17 Z last_sign_in_ip: invites: 0 username: bob last_sign_in_at: language: en sign_in_count: 0 - id: 4 + id: 2 disable_mail: false - password_salt: $2a$10$YXDxHoVUIaIgyS405RS3Ne + password_salt: $2a$10$O07zBbVmaUpAyLo6nBmOAu reset_password_token: remember_token: current_sign_in_ip: @@ -118,4 +118,4 @@ bob: invitation_sent_at: invitation_token: getting_started: true - email: bob25202ed@pivotallabs.com + email: bob2532cbe@pivotallabs.com diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 2cab417bb..8d51a839c 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -19,7 +19,7 @@ describe Diaspora::Parser do describe "parsing compliant XML object" do it 'should be able to correctly parse comment fields' do - post = @user1.post :status_message, :message => "hello", :to => @aspect.id + post = @user1.post :status_message, :message => "hello", :to => @aspect1.id comment = Factory.create(:comment, :post => post, :person => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!") comment.delete xml = comment.to_diaspora_xml @@ -42,15 +42,15 @@ describe Diaspora::Parser do end it "should activate the Person if I initiated a request to that url" do - @user1.send_contact_request_to(@user3.person, @aspect) + @user1.send_contact_request_to(@user3.person, @aspect1) request = @user3.request_from(@user1.person) fantasy_resque do @user3.accept_and_respond(request.id, @aspect3.id) end @user1.reload - @aspect.reload + @aspect1.reload new_contact = @user1.contact_for(@user3.person) - @aspect.contacts.include?(new_contact).should be true + @aspect1.contacts.include?(new_contact).should be true @user1.contacts.include?(new_contact).should be true end @@ -62,7 +62,7 @@ describe Diaspora::Parser do zord = Postzord::Receiver.new(@user1, :person => @user2.person) zord.parse_and_receive(retraction_xml) }.should change { - @aspect.contacts(true).size }.by(-1) + @aspect1.contacts(true).size }.by(-1) end it 'should marshal a profile for a person' do diff --git a/spec/models/jobs/receive_local_spec.rb b/spec/models/jobs/receive_local_spec.rb index 4ea62d920..ea7e07564 100644 --- a/spec/models/jobs/receive_local_spec.rb +++ b/spec/models/jobs/receive_local_spec.rb @@ -3,7 +3,9 @@ require 'spec_helper' describe Jobs::ReceiveLocal do before do @user1 = alice + @person1 = @user1.person @user2 = eve + @person2 = @user2.person @status = Factory(:status_message) @status_type = @status.class.to_s @@ -16,8 +18,8 @@ describe Jobs::ReceiveLocal do } Person.stub(:find){ |id| - if id == @user2.person.id - @user2.person + if id == @person2.id + @person2 else nil end @@ -36,6 +38,6 @@ describe Jobs::ReceiveLocal do m = mock() m.should_receive(:receive_object) Postzord::Receiver.should_receive(:new).and_return(m) - Jobs::ReceiveLocal.perform(@user1.id, @user2.person.id, @status_type, @status.id) + Jobs::ReceiveLocal.perform(@user1.id, @person2.id, @status_type, @status.id) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 45bd7401a..2de47f3f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,7 +17,6 @@ include HelperMethods # # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. -#DatabaseCleaner.clean_with(:truncation) Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| @@ -26,7 +25,7 @@ RSpec.configure do |config| config.use_transactional_fixtures = true - config.global_fixtures = :all +# config.global_fixtures = :all config.before(:each) do I18n.locale = :en diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 161590b19..658c56615 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -1,7 +1,7 @@ # I usually put this file in spec/support/fixture_builder.rb FixtureBuilder.configure do |fbuilder| # rebuild fixtures automatically when these files change: - fbuilder.files_to_check += Dir["app/models/*.rb", "lib/**/*.rb", "spec/factories/*.rb", "spec/support/fixture_builder.rb"] + fbuilder.files_to_check += Dir["app/models/*.rb", "lib/**/*.rb", "spec/factories/*.rb", "spec/support/fixture_builder.rb"] # now declare objects fbuilder.factory do From bad7399eeb809541da5d5c9b55336c6ef3bc19a2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 15:18:58 -0800 Subject: [PATCH 07/10] Remove yml files from git --- .gitignore | 2 +- spec/fixtures/aspect_memberships.yml | 25 ----- spec/fixtures/aspects.yml | 25 ----- spec/fixtures/comments.yml | 2 - spec/fixtures/contacts.yml | 33 ------ spec/fixtures/invitations.yml | 2 - spec/fixtures/mongo_aspect_memberships.yml | 2 - spec/fixtures/mongo_aspects.yml | 2 - spec/fixtures/mongo_comments.yml | 2 - spec/fixtures/mongo_contacts.yml | 2 - spec/fixtures/mongo_invitations.yml | 2 - spec/fixtures/mongo_notifications.yml | 2 - spec/fixtures/mongo_people.yml | 2 - spec/fixtures/mongo_post_visibilities.yml | 2 - spec/fixtures/mongo_posts.yml | 2 - spec/fixtures/mongo_profiles.yml | 2 - spec/fixtures/mongo_requests.yml | 2 - spec/fixtures/mongo_services.yml | 2 - spec/fixtures/mongo_users.yml | 2 - spec/fixtures/notifications.yml | 2 - spec/fixtures/people.yml | 49 --------- spec/fixtures/post_visibilities.yml | 2 - spec/fixtures/posts.yml | 2 - spec/fixtures/profiles.yml | 49 --------- spec/fixtures/requests.yml | 2 - spec/fixtures/services.yml | 2 - spec/fixtures/users.yml | 121 --------------------- 27 files changed, 1 insertion(+), 343 deletions(-) delete mode 100644 spec/fixtures/aspect_memberships.yml delete mode 100644 spec/fixtures/aspects.yml delete mode 100644 spec/fixtures/comments.yml delete mode 100644 spec/fixtures/contacts.yml delete mode 100644 spec/fixtures/invitations.yml delete mode 100644 spec/fixtures/mongo_aspect_memberships.yml delete mode 100644 spec/fixtures/mongo_aspects.yml delete mode 100644 spec/fixtures/mongo_comments.yml delete mode 100644 spec/fixtures/mongo_contacts.yml delete mode 100644 spec/fixtures/mongo_invitations.yml delete mode 100644 spec/fixtures/mongo_notifications.yml delete mode 100644 spec/fixtures/mongo_people.yml delete mode 100644 spec/fixtures/mongo_post_visibilities.yml delete mode 100644 spec/fixtures/mongo_posts.yml delete mode 100644 spec/fixtures/mongo_profiles.yml delete mode 100644 spec/fixtures/mongo_requests.yml delete mode 100644 spec/fixtures/mongo_services.yml delete mode 100644 spec/fixtures/mongo_users.yml delete mode 100644 spec/fixtures/notifications.yml delete mode 100644 spec/fixtures/people.yml delete mode 100644 spec/fixtures/post_visibilities.yml delete mode 100644 spec/fixtures/posts.yml delete mode 100644 spec/fixtures/profiles.yml delete mode 100644 spec/fixtures/requests.yml delete mode 100644 spec/fixtures/services.yml delete mode 100644 spec/fixtures/users.yml diff --git a/.gitignore b/.gitignore index ca65b9e95..3c04bc4db 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ public/stylesheets/sessions.css public/stylesheets/ui.css public/stylesheets/mobile.css public/diaspora -spec/fixtures/users.yaml +spec/fixtures/*.yml # Uploded files and local files public/uploads/* diff --git a/spec/fixtures/aspect_memberships.yml b/spec/fixtures/aspect_memberships.yml deleted file mode 100644 index e2d5d3eb4..000000000 --- a/spec/fixtures/aspect_memberships.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -aspect_memberships_002: - created_at: 2011-01-18 22:45:18 Z - aspect_id: 1 - updated_at: 2011-01-18 22:45:18 Z - contact_id: 2 - id: 2 -aspect_memberships_003: - created_at: 2011-01-18 22:45:18 Z - aspect_id: 2 - updated_at: 2011-01-18 22:45:18 Z - contact_id: 3 - id: 3 -aspect_memberships_004: - created_at: 2011-01-18 22:45:18 Z - aspect_id: 3 - updated_at: 2011-01-18 22:45:18 Z - contact_id: 4 - id: 4 -aspect_memberships_001: - created_at: 2011-01-18 22:45:18 Z - aspect_id: 2 - updated_at: 2011-01-18 22:45:18 Z - contact_id: 1 - id: 1 diff --git a/spec/fixtures/aspects.yml b/spec/fixtures/aspects.yml deleted file mode 100644 index 5322d4d24..000000000 --- a/spec/fixtures/aspects.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -generic_1: - name: generic - mongo_id: - created_at: 2011-01-18 22:45:17 Z - updated_at: 2011-01-18 22:45:17 Z - id: 2 - user_mongo_id: - user_id: 2 -generic_2: - name: generic - mongo_id: - created_at: 2011-01-18 22:45:17 Z - updated_at: 2011-01-18 22:45:18 Z - id: 3 - user_mongo_id: - user_id: 3 -generic: - name: generic - mongo_id: - created_at: 2011-01-18 22:45:17 Z - updated_at: 2011-01-18 22:45:17 Z - id: 1 - user_mongo_id: - user_id: 1 diff --git a/spec/fixtures/comments.yml b/spec/fixtures/comments.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/comments.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/contacts.yml b/spec/fixtures/contacts.yml deleted file mode 100644 index 402513b89..000000000 --- a/spec/fixtures/contacts.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -contacts_003: - pending: false - mongo_id: - created_at: 2011-01-18 22:45:18 Z - updated_at: 2011-01-18 22:45:18 Z - id: 3 - user_id: 2 - person_id: 3 -contacts_004: - pending: false - mongo_id: - created_at: 2011-01-18 22:45:18 Z - updated_at: 2011-01-18 22:45:18 Z - id: 4 - user_id: 3 - person_id: 2 -contacts_001: - pending: false - mongo_id: - created_at: 2011-01-18 22:45:18 Z - updated_at: 2011-01-18 22:45:18 Z - id: 1 - user_id: 2 - person_id: 1 -contacts_002: - pending: false - mongo_id: - created_at: 2011-01-18 22:45:18 Z - updated_at: 2011-01-18 22:45:18 Z - id: 2 - user_id: 1 - person_id: 2 diff --git a/spec/fixtures/invitations.yml b/spec/fixtures/invitations.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/invitations.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_aspect_memberships.yml b/spec/fixtures/mongo_aspect_memberships.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_aspect_memberships.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_aspects.yml b/spec/fixtures/mongo_aspects.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_aspects.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_comments.yml b/spec/fixtures/mongo_comments.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_comments.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_contacts.yml b/spec/fixtures/mongo_contacts.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_contacts.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_invitations.yml b/spec/fixtures/mongo_invitations.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_invitations.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_notifications.yml b/spec/fixtures/mongo_notifications.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_notifications.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_people.yml b/spec/fixtures/mongo_people.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_people.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_post_visibilities.yml b/spec/fixtures/mongo_post_visibilities.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_post_visibilities.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_posts.yml b/spec/fixtures/mongo_posts.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_posts.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_profiles.yml b/spec/fixtures/mongo_profiles.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_profiles.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_requests.yml b/spec/fixtures/mongo_requests.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_requests.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_services.yml b/spec/fixtures/mongo_services.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_services.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/mongo_users.yml b/spec/fixtures/mongo_users.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/mongo_users.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/notifications.yml b/spec/fixtures/notifications.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/notifications.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/people.yml b/spec/fixtures/people.yml deleted file mode 100644 index c0694a984..000000000 --- a/spec/fixtures/people.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -people_001: - mongo_id: - created_at: 2011-01-18 22:45:17 Z - guid: a26933a9a45ac375 - updated_at: 2011-01-18 22:45:17 Z - url: http://google-1eac19e.com/ - serialized_public_key: | - -----BEGIN RSA PUBLIC KEY----- - MIGJAoGBAKw1mMlExMJ9k5Q1E1EEPpmhqbFHdnxX7V5RIMKCwAgOq++SrzXlJfKv - nP11IK3CFZ1E+G/8H/MBf1insc9wQrjKQLlEN4UbeiPA2ahqAPApJ7PpyQBlaN4f - NjQyEm3M1QgdemiBzVYUZOU1gfkKpDoPPMIFgqKkl8O6ZJe6pcrfAgMBAAE= - -----END RSA PUBLIC KEY----- - - owner_id: 1 - id: 1 - diaspora_handle: alice@example.org -people_002: - mongo_id: - created_at: 2011-01-18 22:45:17 Z - guid: d04ada2056f7202c - updated_at: 2011-01-18 22:45:17 Z - url: http://google-2542fc1.com/ - serialized_public_key: | - -----BEGIN RSA PUBLIC KEY----- - MIGJAoGBAKw1mMlExMJ9k5Q1E1EEPpmhqbFHdnxX7V5RIMKCwAgOq++SrzXlJfKv - nP11IK3CFZ1E+G/8H/MBf1insc9wQrjKQLlEN4UbeiPA2ahqAPApJ7PpyQBlaN4f - NjQyEm3M1QgdemiBzVYUZOU1gfkKpDoPPMIFgqKkl8O6ZJe6pcrfAgMBAAE= - -----END RSA PUBLIC KEY----- - - owner_id: 2 - id: 2 - diaspora_handle: bob@example.org -people_003: - mongo_id: - created_at: 2011-01-18 22:45:18 Z - guid: 03637d1d38abd29d - updated_at: 2011-01-18 22:45:18 Z - url: http://google-3a77e5a.com/ - serialized_public_key: | - -----BEGIN RSA PUBLIC KEY----- - MIGJAoGBAKw1mMlExMJ9k5Q1E1EEPpmhqbFHdnxX7V5RIMKCwAgOq++SrzXlJfKv - nP11IK3CFZ1E+G/8H/MBf1insc9wQrjKQLlEN4UbeiPA2ahqAPApJ7PpyQBlaN4f - NjQyEm3M1QgdemiBzVYUZOU1gfkKpDoPPMIFgqKkl8O6ZJe6pcrfAgMBAAE= - -----END RSA PUBLIC KEY----- - - owner_id: 3 - id: 3 - diaspora_handle: eve@example.org diff --git a/spec/fixtures/post_visibilities.yml b/spec/fixtures/post_visibilities.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/post_visibilities.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/posts.yml b/spec/fixtures/posts.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/posts.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/profiles.yml b/spec/fixtures/profiles.yml deleted file mode 100644 index 6517a4f44..000000000 --- a/spec/fixtures/profiles.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -profiles_001: - image_url_medium: - mongo_id: - created_at: 2011-01-18 22:45:17 Z - searchable: true - image_url: - updated_at: 2011-01-18 22:45:17 Z - id: 1 - gender: - diaspora_handle: - person_id: 1 - last_name: Grimm12900f1 - birthday: - image_url_small: - bio: - first_name: Robert1459630 -profiles_002: - image_url_medium: - mongo_id: - created_at: 2011-01-18 22:45:17 Z - searchable: true - image_url: - updated_at: 2011-01-18 22:45:17 Z - id: 2 - gender: - diaspora_handle: - person_id: 2 - last_name: Grimm2f63d16 - birthday: - image_url_small: - bio: - first_name: Robert26c81a0 -profiles_003: - image_url_medium: - mongo_id: - created_at: 2011-01-18 22:45:17 Z - searchable: true - image_url: - updated_at: 2011-01-18 22:45:18 Z - id: 3 - gender: - diaspora_handle: - person_id: 3 - last_name: Grimm3f266bd - birthday: - image_url_small: - bio: - first_name: Robert3938df3 diff --git a/spec/fixtures/requests.yml b/spec/fixtures/requests.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/requests.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/services.yml b/spec/fixtures/services.yml deleted file mode 100644 index 20670d5f5..000000000 --- a/spec/fixtures/services.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- {} - diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml deleted file mode 100644 index ddea41d5e..000000000 --- a/spec/fixtures/users.yml +++ /dev/null @@ -1,121 +0,0 @@ ---- -alice: - encrypted_password: $2a$10$xbdc6ex5521gL/zGLbweNuF9echW6Q74L8sNu.Cug1e9fjBo2AZV6 - serialized_private_key: | - -----BEGIN RSA PRIVATE KEY----- - MIICXgIBAAKBgQCsNZjJRMTCfZOUNRNRBD6ZoamxR3Z8V+1eUSDCgsAIDqvvkq81 - 5SXyr5z9dSCtwhWdRPhv/B/zAX9Yp7HPcEK4ykC5RDeFG3ojwNmoagDwKSez6ckA - ZWjeHzY0MhJtzNUIHXpogc1WFGTlNYH5CqQ6DzzCBYKipJfDumSXuqXK3wIDAQAB - AoGBAJt8pSANBG7q/WYS6gb7gx4p9lKHyLaKmVrQe3jEn2hm/t0IH0TVSocuAtxi - dggNNoDSdlJ+XcaGspm0h/pZTROa05er055twa4JxdwFTxGpv6pBgV56TXugzsYD - fF+pQQmfSl0TZ7nTL1DHWlGufrBUyOQ0cevcEvwlzUCdkhHpAkEA1+QVzevb0rCf - jf4GOG/D9PrgJBPtkhglxm81deQntfkfaNZLkMGEds41REijiEoftOPEdHt7Porq - sQuGdCTZ0wJBAMwz/InrGxlTxLky1dcZd+2DJCQks2OFBnyzf0kamN7KoEBv0K/w - yX/1C0JFu6h/6UTe9E+k4Xfnzhm+K9byd0UCQQDPlvDkbbuU7uKtHSqMD+Qj5yup - ZUQWK4P/N6X3MyiAEQkDvLMygPHHb2bGvvYIMgYk4LJhsu6B5//dt5BUk66jAkBy - aSIyZ+6r9xo+pXPYa6WdBqAGPCXiOZMT5UIIxIUoNqEo2T00hpVvQu1G+WkWFGyv - MLfzs668Dr2UAM/xQ7J9AkEAoR9VaZemxV8thA+w8EeIeBWjAjFY2kZJpPJIQIEv - VtOzYCHm0WXjuyyKHY9AOPLEO9RB4XXW0qmtE28kUCMXGw== - -----END RSA PRIVATE KEY----- - - mongo_id: - created_at: 2011-01-18 22:45:17 Z - updated_at: 2011-01-18 22:45:17 Z - last_sign_in_ip: - invites: 0 - username: alice - last_sign_in_at: - language: en - sign_in_count: 0 - id: 1 - disable_mail: false - password_salt: $2a$10$xbdc6ex5521gL/zGLbweNu - reset_password_token: - remember_token: - current_sign_in_ip: - remember_created_at: - current_sign_in_at: - invitation_sent_at: - invitation_token: - getting_started: true - email: bob1810d2e@pivotallabs.com -eve: - encrypted_password: $2a$10$MunrAlmGUbgmhg0gYo/cqOPm5ObMjHA/rWsSVZiKD1ue0yFQ2AGbO - serialized_private_key: | - -----BEGIN RSA PRIVATE KEY----- - MIICXgIBAAKBgQCsNZjJRMTCfZOUNRNRBD6ZoamxR3Z8V+1eUSDCgsAIDqvvkq81 - 5SXyr5z9dSCtwhWdRPhv/B/zAX9Yp7HPcEK4ykC5RDeFG3ojwNmoagDwKSez6ckA - ZWjeHzY0MhJtzNUIHXpogc1WFGTlNYH5CqQ6DzzCBYKipJfDumSXuqXK3wIDAQAB - AoGBAJt8pSANBG7q/WYS6gb7gx4p9lKHyLaKmVrQe3jEn2hm/t0IH0TVSocuAtxi - dggNNoDSdlJ+XcaGspm0h/pZTROa05er055twa4JxdwFTxGpv6pBgV56TXugzsYD - fF+pQQmfSl0TZ7nTL1DHWlGufrBUyOQ0cevcEvwlzUCdkhHpAkEA1+QVzevb0rCf - jf4GOG/D9PrgJBPtkhglxm81deQntfkfaNZLkMGEds41REijiEoftOPEdHt7Porq - sQuGdCTZ0wJBAMwz/InrGxlTxLky1dcZd+2DJCQks2OFBnyzf0kamN7KoEBv0K/w - yX/1C0JFu6h/6UTe9E+k4Xfnzhm+K9byd0UCQQDPlvDkbbuU7uKtHSqMD+Qj5yup - ZUQWK4P/N6X3MyiAEQkDvLMygPHHb2bGvvYIMgYk4LJhsu6B5//dt5BUk66jAkBy - aSIyZ+6r9xo+pXPYa6WdBqAGPCXiOZMT5UIIxIUoNqEo2T00hpVvQu1G+WkWFGyv - MLfzs668Dr2UAM/xQ7J9AkEAoR9VaZemxV8thA+w8EeIeBWjAjFY2kZJpPJIQIEv - VtOzYCHm0WXjuyyKHY9AOPLEO9RB4XXW0qmtE28kUCMXGw== - -----END RSA PRIVATE KEY----- - - mongo_id: - created_at: 2011-01-18 22:45:18 Z - updated_at: 2011-01-18 22:45:18 Z - last_sign_in_ip: - invites: 0 - username: eve - last_sign_in_at: - language: en - sign_in_count: 0 - id: 3 - disable_mail: false - password_salt: $2a$10$MunrAlmGUbgmhg0gYo/cqO - reset_password_token: - remember_token: - current_sign_in_ip: - remember_created_at: - current_sign_in_at: - invitation_sent_at: - invitation_token: - getting_started: true - email: bob3d6acb8@pivotallabs.com -bob: - encrypted_password: $2a$10$O07zBbVmaUpAyLo6nBmOAur5BcrXLmb5kKRrx2eX04qo3Bi0uXWfu - serialized_private_key: | - -----BEGIN RSA PRIVATE KEY----- - MIICXgIBAAKBgQCsNZjJRMTCfZOUNRNRBD6ZoamxR3Z8V+1eUSDCgsAIDqvvkq81 - 5SXyr5z9dSCtwhWdRPhv/B/zAX9Yp7HPcEK4ykC5RDeFG3ojwNmoagDwKSez6ckA - ZWjeHzY0MhJtzNUIHXpogc1WFGTlNYH5CqQ6DzzCBYKipJfDumSXuqXK3wIDAQAB - AoGBAJt8pSANBG7q/WYS6gb7gx4p9lKHyLaKmVrQe3jEn2hm/t0IH0TVSocuAtxi - dggNNoDSdlJ+XcaGspm0h/pZTROa05er055twa4JxdwFTxGpv6pBgV56TXugzsYD - fF+pQQmfSl0TZ7nTL1DHWlGufrBUyOQ0cevcEvwlzUCdkhHpAkEA1+QVzevb0rCf - jf4GOG/D9PrgJBPtkhglxm81deQntfkfaNZLkMGEds41REijiEoftOPEdHt7Porq - sQuGdCTZ0wJBAMwz/InrGxlTxLky1dcZd+2DJCQks2OFBnyzf0kamN7KoEBv0K/w - yX/1C0JFu6h/6UTe9E+k4Xfnzhm+K9byd0UCQQDPlvDkbbuU7uKtHSqMD+Qj5yup - ZUQWK4P/N6X3MyiAEQkDvLMygPHHb2bGvvYIMgYk4LJhsu6B5//dt5BUk66jAkBy - aSIyZ+6r9xo+pXPYa6WdBqAGPCXiOZMT5UIIxIUoNqEo2T00hpVvQu1G+WkWFGyv - MLfzs668Dr2UAM/xQ7J9AkEAoR9VaZemxV8thA+w8EeIeBWjAjFY2kZJpPJIQIEv - VtOzYCHm0WXjuyyKHY9AOPLEO9RB4XXW0qmtE28kUCMXGw== - -----END RSA PRIVATE KEY----- - - mongo_id: - created_at: 2011-01-18 22:45:17 Z - updated_at: 2011-01-18 22:45:17 Z - last_sign_in_ip: - invites: 0 - username: bob - last_sign_in_at: - language: en - sign_in_count: 0 - id: 2 - disable_mail: false - password_salt: $2a$10$O07zBbVmaUpAyLo6nBmOAu - reset_password_token: - remember_token: - current_sign_in_ip: - remember_created_at: - current_sign_in_at: - invitation_sent_at: - invitation_token: - getting_started: true - email: bob2532cbe@pivotallabs.com From 6ccf8a4d2df97154ab1fe9e7511334ad112e03ac Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 18 Jan 2011 16:05:50 -0800 Subject: [PATCH 08/10] Fixed connecting spec, magic import failure disappearance --- spec/models/aspect_spec.rb | 5 ++- spec/models/user/connecting_spec.rb | 59 ++++++++++++++++------------- spec/models/user_spec.rb | 21 +++++----- spec/spec_helper.rb | 4 +- spec/support/fixture_builder.rb | 2 +- 5 files changed, 50 insertions(+), 41 deletions(-) diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index ae8adb5bd..ff30f64c1 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -59,8 +59,9 @@ describe Aspect do end it 'has no uniqueness between users' do + aspect = user.aspects.create(:name => "New Aspect") aspect2 = user2.aspects.create(:name => aspect.name) - aspect2.valid?.should be_true + aspect2.should be_valid end end @@ -76,7 +77,7 @@ describe Aspect do end it 'should have contacts' do - aspect.contacts.size.should == 1 + aspect.contacts.size.should == 2 end describe '#aspects_with_person' do diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index d27655352..fb49ef4f6 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -60,6 +60,12 @@ describe Diaspora::UserModules::Connecting do Request.where(:recipient_id => user.person.id).all.should include @r end + it 'creates no contact' do + lambda { + received_req = @r.receive(user, person_one) + }.should_not change(Contact, :count) + end + it 'enqueues a mail job' do Resque.should_receive(:enqueue).with(Jobs::MailRequestReceived, user.id, person.id) zord = Postzord::Receiver.new(user, :object => @r, :person => person) @@ -131,11 +137,6 @@ describe Diaspora::UserModules::Connecting do describe 'multiple users accepting/rejecting the same person' do before do - Request.where(:recipient_id => user.person.id).count.should == 0 - user.contacts.empty?.should be true - Request.where(:recipient_id => user2.person.id).count.should == 0 - user2.contacts.empty?.should be true - @request1 = Request.diaspora_initialize(:to => user.person, :from => person_one) @request2 = Request.diaspora_initialize(:to => user2.person, :from => person_one) @request3 = Request.diaspora_initialize(:to => user2.person, :from => user.person) @@ -214,29 +215,33 @@ describe Diaspora::UserModules::Connecting do describe 'a user accepting rejecting multiple people' do before do - @request = Request.diaspora_initialize(:to => user.person, :from => person_one) - @request_two = Request.diaspora_initialize(:to => user.person, :from => person_two) + request = Request.diaspora_initialize(:to => user.person, :from => person_one) + @received_request = request.receive(user, person_one) end - - it "keeps the right counts of contacts" do - received_req = @request.receive(user, person_one) - - Request.where(:recipient_id => user.person.id).count.should == 1 - user.reload.contacts.size.should be 0 - - received_req2 = @request_two.receive(user, person_two) - Request.where(:recipient_id => user.person.id).count.should == 2 - user.reload.contacts.size.should be 0 - - user.accept_contact_request received_req, aspect - Request.where(:recipient_id => user.person.id).count.should == 1 - user.reload.contacts.size.should be 1 - user.contact_for(person_one).should_not be_nil - - user.ignore_contact_request received_req2.id - Request.where(:recipient_id => user.person.id).count.should == 0 - user.reload.contacts.size.should be 1 - user.contact_for(person_two).should be_nil + describe '#accept_contact_request' do + it "deletes the received request" do + lambda { + user.accept_contact_request(@received_request, aspect) + }.should change(Request, :count).by(-1) + end + it "creates a new contact" do + lambda { + user.accept_contact_request(@received_request, aspect) + }.should change(Contact, :count).by(1) + user.contact_for(person_one).should_not be_nil + end + end + describe '#ignore_contact_request' do + it "removes the request" do + lambda { + user.ignore_contact_request(@received_request.id) + }.should change(Request, :count).by(-1) + end + it "creates no new contact" do + lambda { + user.ignore_contact_request(@received_request) + }.should_not change(Contact, :count) + end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ef1a48569..bf9eeac28 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -16,9 +16,9 @@ describe User do describe 'overwriting people' do it 'does not overwrite old users with factory' do - new_user = Factory.create(:user, :id => user.id) - new_user.persisted?.should be_true - new_user.id.should_not == user.id + lambda { + new_user = Factory.create(:user, :id => user.id) + }.should raise_error ActiveRecord::RecordNotUnique end it 'does not overwrite old users with create' do params = {:username => "ohai", @@ -266,9 +266,9 @@ describe User do it "only pushes to non-pending contacts" do connect_users(user, aspect, user2, aspect2) - user.contacts.count.should == 1 - user.send_contact_request_to(Factory(:user).person, aspect) - user.contacts.count.should == 2 + lambda { + user.send_contact_request_to(Factory(:user).person, aspect) + }.should change(user.contacts, :count).by(1) m = mock() m.should_receive(:post) @@ -338,7 +338,9 @@ describe User do it 'should remove all aspects' do aspect - lambda {user.destroy}.should change{user.aspects.reload.count}.by(-1) + lambda { + user.destroy + }.should change{ user.aspects(true).count }.by(-2) end describe '#remove_person' do @@ -360,9 +362,10 @@ describe User do describe '#disconnect_everyone' do it 'should send retractions to remote poeple' do + person = user2.person user2.delete - user2.person.owner_id = nil - user2.person.save + person.owner_id = nil + person.save user.activate_contact(user2.person, aspect) user.should_receive(:disconnect).once diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2de47f3f6..35323e43b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,10 +23,10 @@ RSpec.configure do |config| config.mock_with :mocha config.mock_with :rspec + # config.fixture_path = "#{Rails.root}/spec/fixtures" + # config.global_fixtures = :all config.use_transactional_fixtures = true -# config.global_fixtures = :all - config.before(:each) do I18n.locale = :en RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success)) diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 658c56615..e6681b620 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -11,6 +11,6 @@ FixtureBuilder.configure do |fbuilder| connect_users(bob, bob.aspects.first, alice, alice.aspects.first) connect_users(bob, bob.aspects.first, eve, eve.aspects.first) - end + end end From 1fa39ad20d477fccc7d80ec1546e2947f59f652e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 18 Jan 2011 16:58:59 -0800 Subject: [PATCH 09/10] fixed issue in attack_vectors_spec --- spec/models/user/attack_vectors_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index 9978e5181..476fc26d0 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe "attack vectors" do - let(:user) { alice } + let(:user) { Factory.create(:user_with_aspect) } let(:aspect) { user.aspects.first } let(:bad_user) { Factory.create(:user)} @@ -207,7 +207,6 @@ describe "attack vectors" do end it 'does not let me update other persons post' do - pending "this needs to be a photo" original_message = user2.post(:photo, :user_file => uploaded_photo, :caption => "store this!", :to => aspect2.id) salmon_xml = user2.salmon(original_message).xml_for(user.person) From 4f25dfa6d33f19c23dc0ba278d3adb042be37a12 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 18 Jan 2011 17:14:32 -0800 Subject: [PATCH 10/10] publics controller merge fix --- spec/controllers/publics_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 1ad6264e2..12d3a73fe 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -21,7 +21,7 @@ describe PublicsController do end 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, "guid" => @user.person.guid.to_s, "xml" => xml end