2014-02-18 09:28:04 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
# Test the notes life cycle
|
2018-01-01 17:52:33 +01:00
|
|
|
class NotesControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
include Devise::Test::IntegrationHelpers
|
2014-03-06 21:49:30 +01:00
|
|
|
|
2014-02-18 09:28:04 +01:00
|
|
|
setup do
|
|
|
|
@note = notes(:one)
|
|
|
|
|
2014-03-06 21:49:30 +01:00
|
|
|
sign_in users(:one)
|
2014-02-18 09:28:04 +01:00
|
|
|
end
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
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
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
test 'should create note' do
|
2015-07-25 18:32:27 +02:00
|
|
|
assert_difference 'Note.count' do
|
2018-01-01 17:52:33 +01:00
|
|
|
post moderation_notes_url(@note.event), params: {
|
|
|
|
note: { contents: @note.contents }
|
2014-03-06 21:49:30 +01:00
|
|
|
}
|
2018-01-01 17:52:33 +01:00
|
|
|
assert_empty assigns(:note).errors.messages
|
2014-02-18 09:28:04 +01:00
|
|
|
end
|
|
|
|
|
2014-03-06 21:49:30 +01:00
|
|
|
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
|
2015-07-25 18:32:27 +02:00
|
|
|
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
|
2015-07-25 18:32:27 +02:00
|
|
|
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
|