Move a few specs out of an expensive context they don't need
This commit is contained in:
parent
a5f6b6512d
commit
56b0d7821d
1 changed files with 41 additions and 35 deletions
|
|
@ -53,22 +53,45 @@ describe AspectsController do
|
||||||
get :index
|
get :index
|
||||||
save_fixture(html_for("body"), "aspects_index")
|
save_fixture(html_for("body"), "aspects_index")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "generates a jasmine fixture with a prefill" do
|
it "generates a jasmine fixture with a prefill" do
|
||||||
get :index, :prefill => "reshare things"
|
get :index, :prefill => "reshare things"
|
||||||
save_fixture(html_for("body"), "aspects_index_prefill")
|
save_fixture(html_for("body"), "aspects_index_prefill")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates a jasmine fixture with services' do
|
it 'generates a jasmine fixture with services' do
|
||||||
@alice.services << Services::Facebook.create(:user_id => @alice.id)
|
@alice.services << Services::Facebook.create(:user_id => @alice.id)
|
||||||
@alice.services << Services::Twitter.create(:user_id => @alice.id)
|
@alice.services << Services::Twitter.create(:user_id => @alice.id)
|
||||||
get :index, :prefill => "reshare things"
|
get :index, :prefill => "reshare things"
|
||||||
save_fixture(html_for("body"), "aspects_index_services")
|
save_fixture(html_for("body"), "aspects_index_services")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates a jasmine fixture with posts' do
|
it 'generates a jasmine fixture with posts' do
|
||||||
@alice.post(:status_message, :text => "hello", :to => @alices_aspect_2.id)
|
@alice.post(:status_message, :text => "hello", :to => @alices_aspect_2.id)
|
||||||
get :index
|
get :index
|
||||||
save_fixture(html_for("body"), "aspects_index_with_posts")
|
save_fixture(html_for("body"), "aspects_index_with_posts")
|
||||||
end
|
end
|
||||||
context 'filtering' do
|
|
||||||
|
context 'with getting_started = true' do
|
||||||
|
before do
|
||||||
|
@alice.getting_started = true
|
||||||
|
@alice.save
|
||||||
|
end
|
||||||
|
it 'redirects to getting_started' do
|
||||||
|
get :index
|
||||||
|
response.should redirect_to getting_started_path
|
||||||
|
end
|
||||||
|
it 'does not redirect mobile users to getting_started' do
|
||||||
|
get :index, :format => :mobile
|
||||||
|
response.should_not be_redirect
|
||||||
|
end
|
||||||
|
it 'does not redirect ajax to getting_started' do
|
||||||
|
get :index, :format => :js
|
||||||
|
response.should_not be_redirect
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with posts in multiple aspects' do
|
||||||
before do
|
before do
|
||||||
@posts = []
|
@posts = []
|
||||||
2.times do |n|
|
2.times do |n|
|
||||||
|
|
@ -84,22 +107,6 @@ describe AspectsController do
|
||||||
@alice.build_comment('lalala', :on => @posts.first ).save
|
@alice.build_comment('lalala', :on => @posts.first ).save
|
||||||
end
|
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
|
describe "ordering" do
|
||||||
it "orders posts by updated_at by default" do
|
it "orders posts by updated_at by default" do
|
||||||
get :index
|
get :index
|
||||||
|
|
@ -111,26 +118,25 @@ describe AspectsController do
|
||||||
assigns(:posts).should == @posts.reverse
|
assigns(:posts).should == @posts.reverse
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'with getting_started = true' do
|
|
||||||
before do
|
it "returns all posts by default" do
|
||||||
@alice.getting_started = true
|
@alice.aspects.reload
|
||||||
@alice.save
|
get :index
|
||||||
end
|
assigns(:posts).length.should == 2
|
||||||
it 'redirects to getting_started' do
|
end
|
||||||
get :index
|
|
||||||
response.should redirect_to getting_started_path
|
it "can filter to a single aspect" do
|
||||||
end
|
get :index, :a_ids => [@alices_aspect_2.id.to_s]
|
||||||
it 'does not redirect mobile users to getting_started' do
|
assigns(:posts).length.should == 1
|
||||||
get :index, :format => :mobile
|
end
|
||||||
response.should_not be_redirect
|
|
||||||
end
|
it "can filter to multiple aspects" do
|
||||||
it 'does not redirect ajax to getting_started' do
|
get :index, :a_ids => [@alices_aspect_1.id.to_s, @alices_aspect_2.id.to_s]
|
||||||
get :index, :format => :js
|
assigns(:posts).length.should == 2
|
||||||
response.should_not be_redirect
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'performance', :performance => true do
|
|
||||||
|
describe 'performance', :performance => true do
|
||||||
before do
|
before do
|
||||||
require 'benchmark'
|
require 'benchmark'
|
||||||
8.times do |n|
|
8.times do |n|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue