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