diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index df4ac9a0a..c2c97099d 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -55,18 +55,27 @@ describe PostsController do context 'user not signed in' do - it 'shows a public post' do - status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all') + context 'given a public post' do + before :each do + @status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all') + end - get :show, :id => status.id - response.status.should == 200 - end + it 'shows a public post' do + get :show, :id => @status.id + response.status.should == 200 + end + + it 'succeeds for statusnet' do + @request.env["HTTP_ACCEPT"] = "application/html+xml,text/html" + get :show, :id => @status.id + response.should be_success + end + + it 'responds with diaspora xml if format is xml' do + get :show, :id => @status.guid, :format => :xml + response.body.should == @status.to_diaspora_xml + end - it 'succeeds for statusnet' do - status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all') - @request.env["HTTP_ACCEPT"] = "application/html+xml,text/html" - get :show, :id => status.id - response.should be_success end it 'shows a public photo' do @@ -83,12 +92,6 @@ describe PostsController do response.status = 302 end - it 'responds with diaspora xml if format is xml' do - status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all') - get :show, :id => status.guid, :format => :xml - response.body.should == status.to_diaspora_xml - end - # We want to be using guids from now on for this post route, but do not want to break # pre-exisiting permalinks. We can assume a guid is 8 characters long as we have # guids set to hex(8) since we started using them. @@ -151,7 +154,7 @@ describe PostsController do before do sign_in alice end - + it 'will succeed if admin' do AppConfig[:admins] = [alice.username] get :index