1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

test invalid abuse

This commit is contained in:
Sylvain 2016-04-06 14:58:53 +02:00
parent 773e87ecd4
commit 150e58d47f
2 changed files with 27 additions and 0 deletions

View File

@ -5,6 +5,8 @@ class Abuse < ActiveRecord::Base
after_create :notify_admins_abuse_reported
validates :first_name, :last_name, :email, :message, :presence => true
private
def notify_admins_abuse_reported

View File

@ -50,4 +50,29 @@ class AbusesTest < ActionDispatch::IntegrationTest
assert_includes notified_users_ids, adm.id, "Admin #{adm.id} was not notified"
end
end
# Incomplete abuse report
test 'visitor send an invalid report' do
project = Project.first
post '/api/abuses',
{
abuse: {
signaled_type: 'Project',
signaled_id: project.id,
first_name: 'John',
last_name: 'Wrong',
email: '',
message: ''
}
}.to_json,
{
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
}
assert_equal 422, response.status, response.body
assert_match /can't be blank/, response.body
end
end