agenda-libre-ruby/test/controllers/notes_controller_test.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

2014-02-18 09:28:04 +01:00
require 'test_helper'
# Test the notes life cycle
2018-01-01 17:52:33 +01:00
class NotesControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
2014-02-18 09:28:04 +01:00
setup do
@note = notes(:one)
sign_in users(:one)
2014-02-18 09:28:04 +01:00
end
test 'should get new' do
2018-01-01 17:52:33 +01:00
get new_moderation_note_url(@note.event)
2014-02-18 09:28:04 +01:00
assert_response :success
end
test 'should create note' do
assert_difference 'Note.count' do
2018-01-01 17:52:33 +01:00
post moderation_notes_url(@note.event), params: {
note: { contents: @note.contents }
}
2018-01-01 17:52:33 +01:00
assert_empty assigns(:note).errors.messages
2014-02-18 09:28:04 +01:00
end
assert_redirected_to moderations_path
2014-02-18 09:28:04 +01:00
end
2014-09-03 02:14:21 +02:00
test 'should send mail' do
assert_difference 'Note.count' do
2018-01-01 17:52:33 +01:00
post moderation_notes_url(@note.event), params: {
envoiParMail: 'oui',
note: { contents: @note.contents }
2014-09-03 02:14:21 +02:00
}
2018-01-01 17:52:33 +01:00
assert_empty assigns(:note).errors.messages
2014-09-03 02:14:21 +02:00
end
assert ActionMailer::Base.deliveries.present?
assert_redirected_to moderations_path
end
test 'should not create note' do
assert_no_difference 'Note.count' do
2018-01-01 17:52:33 +01:00
post moderation_notes_url(@note.event), params: {
note: { nothing: 'almost' }
2014-09-03 02:14:21 +02:00
}
2018-01-01 17:52:33 +01:00
assert_not_empty assigns(:note).errors.messages
2014-09-03 02:14:21 +02:00
end
end
2014-02-18 09:28:04 +01:00
end