Move a few specs out of an expensive context they don't need

This commit is contained in:
Sarah Mei 2011-03-27 10:47:04 -07:00
parent a5f6b6512d
commit 56b0d7821d

View file

@ -53,64 +53,25 @@ describe AspectsController do
get :index
save_fixture(html_for("body"), "aspects_index")
end
it "generates a jasmine fixture with a prefill" do
get :index, :prefill => "reshare things"
save_fixture(html_for("body"), "aspects_index_prefill")
end
it 'generates a jasmine fixture with services' do
@alice.services << Services::Facebook.create(:user_id => @alice.id)
@alice.services << Services::Twitter.create(:user_id => @alice.id)
get :index, :prefill => "reshare things"
save_fixture(html_for("body"), "aspects_index_services")
end
it 'generates a jasmine fixture with posts' do
@alice.post(:status_message, :text => "hello", :to => @alices_aspect_2.id)
get :index
save_fixture(html_for("body"), "aspects_index_with_posts")
end
context 'filtering' do
before do
@posts = []
2.times do |n|
user = Factory(:user)
aspect = user.aspects.create(:name => 'people')
connect_users(@alice, @alices_aspect_1, user, aspect)
target_aspect = n.even? ? @alices_aspect_1 : @alices_aspect_2
post = @alice.post(:status_message, :text=> "hello#{n}", :to => target_aspect)
post.created_at = Time.now - (2 - n).seconds
post.save!
@posts << post
end
@alice.build_comment('lalala', :on => @posts.first ).save
end
it "returns all posts by default" do
@alice.aspects.reload
get :index
assigns(:posts).length.should == 2
end
it "returns posts from a single aspect" do
get :index, :a_ids => [@alices_aspect_2.id.to_s]
assigns(:posts).length.should == 1
end
it "returns posts from multiple aspects" do
get :index, :a_ids => [@alices_aspect_1.id.to_s, @alices_aspect_2.id.to_s]
assigns(:posts).length.should == 2
end
describe "ordering" do
it "orders posts by updated_at by default" do
get :index
assigns(:posts).should == @posts
end
it "orders posts by created_at on request" do
get :index, :sort_order => 'created_at'
assigns(:posts).should == @posts.reverse
end
end
context 'with getting_started = true' do
before do
@alice.getting_started = true
@ -129,8 +90,53 @@ describe AspectsController do
response.should_not be_redirect
end
end
context 'with posts in multiple aspects' do
before do
@posts = []
2.times do |n|
user = Factory(:user)
aspect = user.aspects.create(:name => 'people')
connect_users(@alice, @alices_aspect_1, user, aspect)
target_aspect = n.even? ? @alices_aspect_1 : @alices_aspect_2
post = @alice.post(:status_message, :text=> "hello#{n}", :to => target_aspect)
post.created_at = Time.now - (2 - n).seconds
post.save!
@posts << post
end
context 'performance', :performance => true do
@alice.build_comment('lalala', :on => @posts.first ).save
end
describe "ordering" do
it "orders posts by updated_at by default" do
get :index
assigns(:posts).should == @posts
end
it "orders posts by created_at on request" do
get :index, :sort_order => 'created_at'
assigns(:posts).should == @posts.reverse
end
end
it "returns all posts by default" do
@alice.aspects.reload
get :index
assigns(:posts).length.should == 2
end
it "can filter to a single aspect" do
get :index, :a_ids => [@alices_aspect_2.id.to_s]
assigns(:posts).length.should == 1
end
it "can filter to multiple aspects" do
get :index, :a_ids => [@alices_aspect_1.id.to_s, @alices_aspect_2.id.to_s]
assigns(:posts).length.should == 2
end
end
describe 'performance', :performance => true do
before do
require 'benchmark'
8.times do |n|