Refactor PostsController spec code a little. (DRY up a bit)
This commit is contained in:
parent
fae9aee425
commit
511d51318d
1 changed files with 20 additions and 17 deletions
|
|
@ -55,18 +55,27 @@ describe PostsController do
|
||||||
|
|
||||||
context 'user not signed in' do
|
context 'user not signed in' do
|
||||||
|
|
||||||
it 'shows a public post' do
|
context 'given a public post' do
|
||||||
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
before :each do
|
||||||
|
@status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||||
|
end
|
||||||
|
|
||||||
get :show, :id => status.id
|
it 'shows a public post' do
|
||||||
response.status.should == 200
|
get :show, :id => @status.id
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
it 'shows a public photo' do
|
it 'shows a public photo' do
|
||||||
|
|
@ -83,12 +92,6 @@ describe PostsController do
|
||||||
response.status = 302
|
response.status = 302
|
||||||
end
|
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
|
# 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
|
# 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.
|
# guids set to hex(8) since we started using them.
|
||||||
|
|
@ -151,7 +154,7 @@ describe PostsController do
|
||||||
before do
|
before do
|
||||||
sign_in alice
|
sign_in alice
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'will succeed if admin' do
|
it 'will succeed if admin' do
|
||||||
AppConfig[:admins] = [alice.username]
|
AppConfig[:admins] = [alice.username]
|
||||||
get :index
|
get :index
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue