Skip to content
Snippets Groups Projects
Commit 2255e80b authored by Sarah Mei's avatar Sarah Mei
Browse files

So. It turns out that postgresql has a less-consistent idea of what .first...

So. It turns out that postgresql has a less-consistent idea of what .first means in an association with no default ordering. All the places we were doing bob.aspects.first (& etc.) needed to be more specific. & o ya, POSTGRES IS GREEN.
parent e8eb496e
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,8 @@ describe AspectsController do
describe "post visibilities" do
before do
@status = bob.post(:status_message, :text=> "hello", :to => bob.aspects.first)
aspect_to_post = bob.aspects.where(:name => "generic").first
@status = bob.post(:status_message, :text=> "hello", :to => aspect_to_post)
@vis = @status.post_visibilities.first
end
......
......@@ -6,8 +6,8 @@ require 'spec_helper'
describe CommentsController do
before do
@aspect1 = alice.aspects.first
@aspect2 = bob.aspects.first
@aspect1 = alice.aspects.where(:name => "generic").first
@aspect2 = bob.aspects.where(:name => "generic").first
@controller.stub(:current_user).and_return(alice)
sign_in :user, alice
......@@ -124,7 +124,8 @@ describe CommentsController do
describe '#index' do
before do
@message = bob.post(:status_message, :text => "hey", :to => bob.aspects.first.id)
aspect_to_post = bob.aspects.where(:name => "generic").first
@message = bob.post(:status_message, :text => "hey", :to => aspect_to_post.id)
@comments = [alice, bob, eve].map{ |u| u.comment("hey", :post => @message) }
end
it 'works for mobile' do
......@@ -141,7 +142,8 @@ describe CommentsController do
response.status.should == 404
end
it 'returns a 404 on a post that is not visible to the signed in user' do
message = eve.post(:status_message, :text => "hey", :to => eve.aspects.first.id)
aspect_to_post = eve.aspects.where(:name => "generic").first
message = eve.post(:status_message, :text => "hey", :to => aspect_to_post.id)
bob.comment("hey", :post => @message)
get :index, :post_id => message.id, :format => 'js'
response.status.should == 404
......
......@@ -6,13 +6,10 @@ require 'spec_helper'
describe LikesController do
before do
@user1 = alice
@user2 = bob
@alices_aspect = alice.aspects.where(:name => "generic").first
@bobs_aspect = bob.aspects.where(:name => "generic").first
@aspect1 = @user1.aspects.first
@aspect2 = @user2.aspects.first
sign_in :user, @user1
sign_in :user, alice
end
[Comment, Post].each do |class_const|
......@@ -33,9 +30,9 @@ describe LikesController do
context "on my own post" do
before do
@target = @user1.post :status_message, :text => "AWESOME", :to => @aspect1.id
@target = alice.post :status_message, :text => "AWESOME", :to => @alices_aspect.id
@target = @user1.comment "hey", :post => @target if class_const == Comment
@target = alice.comment "hey", :post => @target if class_const == Comment
end
it 'responds to format js' do
......@@ -46,8 +43,8 @@ describe LikesController do
context "on a post from a contact" do
before do
@target = @user2.post :status_message, :text => "AWESOME", :to => @aspect2.id
@target = @user2.comment "hey", :post => @target if class_const == Comment
@target = bob.post :status_message, :text => "AWESOME", :to => @bobs_aspect.id
@target = bob.comment "hey", :post => @target if class_const == Comment
end
it 'likes' do
......@@ -61,7 +58,7 @@ describe LikesController do
end
it "doesn't post multiple times" do
@user1.like(1, :target => @target)
alice.like(1, :target => @target)
post :create, dislike_hash
response.code.should == '422'
end
......@@ -74,7 +71,7 @@ describe LikesController do
end
it "doesn't post" do
@user1.should_not_receive(:like)
alice.should_not_receive(:like)
post :create, like_hash
response.code.should == '422'
end
......@@ -83,7 +80,7 @@ describe LikesController do
describe '#index' do
before do
@message = alice.post(:status_message, :text => "hey", :to => @aspect1.id)
@message = alice.post(:status_message, :text => "hey", :to => @alices_aspect.id)
@message = alice.comment( "hey", :post => @message) if class_const == Comment
end
it 'returns a 404 for a post not visible to the user' do
......@@ -107,7 +104,7 @@ describe LikesController do
describe '#destroy' do
before do
@message = bob.post(:status_message, :text => "hey", :to => @aspect1.id)
@message = bob.post(:status_message, :text => "hey", :to => @alices_aspect.id)
@message = bob.comment( "hey", :post => @message) if class_const == Comment
@like = alice.build_like(:positive => true, :target => @message)
@like.save
......
......@@ -253,8 +253,10 @@ describe PeopleController do
it "assigns only the posts the current user can see" do
bob.posts.should be_empty
posts_user_can_see = []
posts_user_can_see << bob.post(:status_message, :text => "to an aspect @user is in", :to => bob.aspects[0].id)
bob.post(:status_message, :text => "to an aspect @user is not in", :to => bob.aspects[1].id)
aspect_user_is_in = bob.aspects.where(:name => "generic").first
aspect_user_is_not_in = bob.aspects.where(:name => "empty").first
posts_user_can_see << bob.post(:status_message, :text => "to an aspect @user is in", :to => aspect_user_is_in.id)
bob.post(:status_message, :text => "to an aspect @user is not in", :to => aspect_user_is_not_in.id)
posts_user_can_see << bob.post(:status_message, :text => "to all aspects", :to => 'all')
posts_user_can_see << bob.post(:status_message, :text => "public", :to => 'all', :public => true)
bob.reload.posts.length.should == 4
......
......@@ -11,7 +11,7 @@ describe AspectMembership do
@aspect = alice.aspects.create(:name => "two")
@contact = alice.contact_for(bob.person)
@am = alice.aspects.first.aspect_memberships.first
@am = alice.aspects.where(:name => "generic").first.aspect_memberships.first
@am.stub!(:user).and_return(alice)
end
......
......@@ -90,17 +90,21 @@ describe Contact do
@eve = eve
@bob.aspects.create(:name => 'next')
@bob.aspects(true)
@original_aspect = @bob.aspects.where(:name => "generic").first
@new_aspect = @bob.aspects.where(:name => "next").first
@people1 = []
@people2 = []
1.upto(5) do
person = Factory(:person)
@bob.contacts.create(:person => person, :aspects => [@bob.aspects.first])
@bob.contacts.create(:person => person, :aspects => [@original_aspect])
@people1 << person
end
1.upto(5) do
person = Factory(:person)
@bob.contacts.create(:person => person, :aspects => [@bob.aspects.last])
@bob.contacts.create(:person => person, :aspects => [@new_aspect])
@people2 << person
end
#eve <-> bob <-> alice
......@@ -118,9 +122,8 @@ describe Contact do
end
it 'returns nothing if contacts_visible is false in that aspect' do
asp = @bob.aspects.first
asp.contacts_visible = false
asp.save
@original_aspect.contacts_visible = false
@original_aspect.save
@contact.contacts.should == []
end
......
......@@ -8,12 +8,17 @@ FixtureBuilder.configure do |fbuilder|
fbuilder.factory do
# Users
alice = Factory(:user_with_aspect, :username => "alice")
alices_aspect = alice.aspects.where(:name => "generic").first
eve = Factory(:user_with_aspect, :username => "eve")
eves_aspect = eve.aspects.where(:name => "generic").first
bob = Factory(:user_with_aspect, :username => "bob")
bobs_aspect = bob.aspects.where(:name => "generic").first
Factory(:aspect, :name => "empty", :user => bob)
connect_users(bob, bob.aspects.first, alice, alice.aspects.first)
connect_users(bob, bob.aspects.first, eve, eve.aspects.first)
connect_users(bob, bobs_aspect, alice, alices_aspect)
connect_users(bob, bobs_aspect, eve, eves_aspect)
# Set up friends
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment