2014-02-18 09:28:04 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
# Test the notes life cycle
|
2014-02-18 09:28:04 +01:00
|
|
|
class NotesControllerTest < ActionController::TestCase
|
2014-03-06 21:49:30 +01:00
|
|
|
include Devise::TestHelpers
|
|
|
|
|
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
|
2014-03-06 21:49:30 +01:00
|
|
|
get :new, moderation_id: @note.event.id
|
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
|
2014-03-06 21:49:30 +01:00
|
|
|
post :create, moderation_id: @note.event.id, note: {
|
2014-09-03 02:14:21 +02:00
|
|
|
contents: @note.contents
|
2014-03-06 21:49:30 +01:00
|
|
|
}
|
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
|
2014-09-03 02:14:21 +02:00
|
|
|
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
|
2015-07-25 18:32:27 +02:00
|
|
|
assert_no_difference 'Note.count' do
|
2014-09-03 02:14:21 +02:00
|
|
|
post :create, moderation_id: @note.event.id, note: {
|
|
|
|
nothing: 'almost'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2014-02-18 09:28:04 +01:00
|
|
|
end
|