Skip to content
Extraits de code Groupes Projets
notes_controller_test.rb 1 ko
Newer Older
  • Learn to ignore specific revisions
  • echarp's avatar
    echarp a validé
    require 'test_helper'
    
    
    echarp's avatar
    echarp a validé
    class NotesControllerTest < ActionController::TestCase
    
    echarp's avatar
    echarp a validé
      setup do
        @note = notes(:one)
    
    
    echarp's avatar
    echarp a validé
      end
    
    
        get :new, moderation_id: @note.event.id
    
    echarp's avatar
    echarp a validé
        assert_response :success
      end
    
    
    echarp's avatar
    echarp a validé
        assert_difference('Note.count') do
    
          post :create, moderation_id: @note.event.id, note: {
    
            contents: @note.contents
    
    echarp's avatar
    echarp a validé
        end
    
    
        assert_redirected_to moderations_path
    
    echarp's avatar
    echarp a validé
      end
    
    
      test 'should send mail' do
        assert_difference('Note.count') do
          post :create, moderation_id: @note.event.id, envoiParMail: 'oui', note: {
            contents: @note.contents
          }
        end
    
        assert ActionMailer::Base.deliveries.present?
    
        assert_redirected_to moderations_path
      end
    
      test 'should not create note' do
        assert_no_difference('Note.count') do
          post :create, moderation_id: @note.event.id, note: {
            nothing: 'almost'
          }
        end
      end
    
    echarp's avatar
    echarp a validé
    end