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

48 lines
1022 B
Ruby
Raw Normal View History

2014-02-18 09:28:04 +01:00
require 'test_helper'
# Test the notes life cycle
2014-02-18 09:28:04 +01:00
class NotesControllerTest < ActionController::TestCase
include Devise::TestHelpers
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
get :new, moderation_id: @note.event.id
2014-02-18 09:28:04 +01:00
assert_response :success
end
test 'should create note' do
assert_difference 'Note.count' do
post :create, moderation_id: @note.event.id, note: {
2014-09-03 02:14:21 +02:00
contents: @note.contents
}
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
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
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