Skip to content
Extraits de code Groupes Projets
Valider 21feb91d rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

always pass desired format in specs unless it's html

parent 645a4277
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -53,20 +53,20 @@ describe ConversationsController do
}
@conversations = Array.new(3) { Conversation.create(hash) }
end
it 'succeeds' do
get :index
response.should be_success
assigns[:conversations].should =~ @conversations
end
it 'succeeds with json' do
get :index, :format => :json
response.should be_success
json = JSON.parse(response.body)
json.first['conversation'].should be_present
end
it 'retrieves all conversations for a user' do
get :index
assigns[:conversations].count.should == 3
......@@ -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'
......@@ -254,13 +259,13 @@ describe ConversationsController do
}
@conversation = Conversation.create(hash)
end
it 'succeeds with js' do
get :show, :id => @conversation.id, :format => :js
response.should be_success
assigns[:conversation].should == @conversation
end
it 'succeeds with json' do
get :show, :id => @conversation.id, :format => :json
response.should be_success
......@@ -273,7 +278,7 @@ describe ConversationsController do
response.should redirect_to(conversations_path(:conversation_id => @conversation.id))
assigns[:conversation].should == @conversation
end
it 'does not let you access conversations where you are not a recipient' do
sign_in :user, eve
......
......@@ -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
......@@ -64,7 +64,7 @@ describe NotificationsController do
get :index, :format => :mobile
response.should be_success
end
it 'paginates the notifications' do
25.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
get :index
......@@ -76,7 +76,7 @@ describe NotificationsController do
it "supports a limit per_page parameter" do
5.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
get :index, "per_page" => 5
assigns[:notifications].count.should == 5
assigns[:notifications].count.should == 5
end
describe "special case for start sharing notifications" do
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter