always pass desired format in specs unless it's html
This commit is contained in:
parent
645a427798
commit
21feb91d27
4 changed files with 23 additions and 18 deletions
|
|
@ -139,12 +139,12 @@ describe CommentsController do
|
|||
it 'returns all the comments for a post' do
|
||||
comments = [alice, bob, eve].map{ |u| u.comment!(@message, "hey") }
|
||||
|
||||
get :index, :post_id => @message.id, :format => 'js'
|
||||
get :index, :post_id => @message.id, :format => :json
|
||||
assigns[:comments].map(&:id).should =~ comments.map(&:id)
|
||||
end
|
||||
|
||||
it 'returns a 404 on a nonexistent post' do
|
||||
get :index, :post_id => 235236, :format => 'js'
|
||||
get :index, :post_id => 235236, :format => :json
|
||||
response.status.should == 404
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ describe ConversationsController do
|
|||
context 'with a valid conversation' do
|
||||
before do
|
||||
@hash = {
|
||||
:format => :js,
|
||||
:conversation => {
|
||||
:subject => "secret stuff",
|
||||
:text => 'text debug'
|
||||
|
|
@ -131,6 +132,7 @@ describe ConversationsController do
|
|||
context 'with empty subject' do
|
||||
before do
|
||||
@hash = {
|
||||
:format => :js,
|
||||
:conversation => {
|
||||
:subject => ' ',
|
||||
:text => 'text debug'
|
||||
|
|
@ -162,6 +164,7 @@ describe ConversationsController do
|
|||
context 'with empty text' do
|
||||
before do
|
||||
@hash = {
|
||||
:format => :js,
|
||||
:conversation => {
|
||||
:subject => 'secret stuff',
|
||||
:text => ' '
|
||||
|
|
@ -192,6 +195,7 @@ describe ConversationsController do
|
|||
context 'with empty contact' do
|
||||
before do
|
||||
@hash = {
|
||||
:format => :js,
|
||||
:conversation => {
|
||||
:subject => 'secret stuff',
|
||||
:text => 'text debug'
|
||||
|
|
@ -222,6 +226,7 @@ describe ConversationsController do
|
|||
context 'with nil contact' do
|
||||
before do
|
||||
@hash = {
|
||||
:format => :js,
|
||||
:conversation => {
|
||||
:subject => 'secret stuff',
|
||||
:text => 'text debug'
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@ describe NotificationsController do
|
|||
note = mock_model( Notification )
|
||||
Notification.should_receive( :where ).and_return( [note] )
|
||||
note.should_receive( :set_read_state ).with( true )
|
||||
get :update, "id" => note.id
|
||||
get :update, "id" => note.id, :format => :json
|
||||
end
|
||||
it 'marks a notification as read if it is told to' do
|
||||
note = mock_model( Notification )
|
||||
Notification.should_receive( :where ).and_return( [note] )
|
||||
note.should_receive( :set_read_state ).with( true )
|
||||
get :update, "id" => note.id, :set_unread => "false"
|
||||
get :update, "id" => note.id, :set_unread => "false", :format => :json
|
||||
end
|
||||
|
||||
it 'marks a notification as unread if it is told to' do
|
||||
note = mock_model( Notification )
|
||||
Notification.should_receive( :where ).and_return( [note] )
|
||||
note.should_receive( :set_read_state ).with( false )
|
||||
get :update, "id" => note.id, :set_unread => "true"
|
||||
get :update, "id" => note.id, :set_unread => "true", :format => :json
|
||||
end
|
||||
|
||||
it 'only lets you read your own notifications' do
|
||||
|
|
@ -36,7 +36,7 @@ describe NotificationsController do
|
|||
FactoryGirl.create(:notification, :recipient => alice)
|
||||
note = FactoryGirl.create(:notification, :recipient => user2)
|
||||
|
||||
get :update, "id" => note.id, :set_unread => "false"
|
||||
get :update, "id" => note.id, :set_unread => "false", :format => :json
|
||||
|
||||
Notification.find(note.id).unread.should == true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ describe PhotosController do
|
|||
end
|
||||
|
||||
it 'will let you delete your profile picture' do
|
||||
get :make_profile_photo, :photo_id => @alices_photo.id
|
||||
get :make_profile_photo, :photo_id => @alices_photo.id, :format => :js
|
||||
delete :destroy, :id => @alices_photo.id
|
||||
Photo.find_by_id(@alices_photo.id).should be_nil
|
||||
end
|
||||
|
|
@ -155,21 +155,21 @@ describe PhotosController do
|
|||
|
||||
describe "#update" do
|
||||
it "updates the caption of a photo" do
|
||||
put :update, :id => @alices_photo.id, :photo => { :text => "now with lasers!" }
|
||||
put :update, :id => @alices_photo.id, :photo => { :text => "now with lasers!" }, :format => :js
|
||||
@alices_photo.reload.text.should == "now with lasers!"
|
||||
end
|
||||
|
||||
it "doesn't allow mass assignment of person" do
|
||||
new_user = FactoryGirl.create(:user)
|
||||
params = { :text => "now with lasers!", :author => new_user }
|
||||
put :update, :id => @alices_photo.id, :photo => params
|
||||
put :update, :id => @alices_photo.id, :photo => params, :format => :js
|
||||
@alices_photo.reload.author.should == alice.person
|
||||
end
|
||||
|
||||
it "doesn't allow mass assignment of person_id" do
|
||||
new_user = FactoryGirl.create(:user)
|
||||
params = { :text => "now with lasers!", :author_id => new_user.id }
|
||||
put :update, :id => @alices_photo.id, :photo => params
|
||||
put :update, :id => @alices_photo.id, :photo => params, :format => :js
|
||||
@alices_photo.reload.author_id.should == alice.person.id
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue