2013-12-28 23:45:13 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
# Test events, which are the application central part
|
2013-12-28 23:45:13 +01:00
|
|
|
class EventTest < ActiveSupport::TestCase
|
2014-06-29 14:09:02 +02:00
|
|
|
test 'basic event' do
|
2014-05-25 23:59:03 +02:00
|
|
|
@event = Event.new(
|
|
|
|
title: 'hello world',
|
2014-08-06 14:47:47 +02:00
|
|
|
start_time: Time.new,
|
|
|
|
end_time: Time.new + 1,
|
2014-05-25 23:59:03 +02:00
|
|
|
description: 'et hop!',
|
2014-08-06 14:47:47 +02:00
|
|
|
city: City.first,
|
|
|
|
related_region: Region.first,
|
2014-05-26 01:06:43 +02:00
|
|
|
url: 'http://example.com',
|
2014-05-31 23:13:43 +02:00
|
|
|
contact: 'contact@example.com',
|
|
|
|
submitter: 'submitter@example.com'
|
2014-05-25 23:59:03 +02:00
|
|
|
)
|
2014-08-06 14:47:47 +02:00
|
|
|
assert @event.save, @event.errors.messages
|
2014-05-25 23:59:03 +02:00
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
assert_equal 32, @event.secret.size
|
|
|
|
assert_equal 32, @event.moderator_mail_id.size
|
|
|
|
assert_equal 32, @event.submitter_mail_id.size
|
2014-05-31 23:13:43 +02:00
|
|
|
end
|
|
|
|
|
2014-06-29 14:09:02 +02:00
|
|
|
test 'validations' do
|
2014-05-31 23:13:43 +02:00
|
|
|
@event = Event.new(
|
|
|
|
title: 'hello world',
|
2014-08-06 14:47:47 +02:00
|
|
|
start_time: Time.new,
|
|
|
|
end_time: Time.new + 1,
|
2014-05-31 23:13:43 +02:00
|
|
|
description: 'et hop!',
|
2014-08-06 14:47:47 +02:00
|
|
|
city: City.first,
|
|
|
|
related_region: Region.first,
|
2014-05-31 23:13:43 +02:00
|
|
|
url: 'http://example.com',
|
|
|
|
contact: 'contact@example.com'
|
|
|
|
)
|
|
|
|
|
|
|
|
assert @event.valid?, @event.errors.messages
|
|
|
|
assert_equal @event.contact, @event.submitter
|
|
|
|
|
|
|
|
@event.contact = 'hop@@@'
|
|
|
|
assert !@event.valid?, @event.errors.messages
|
|
|
|
|
|
|
|
@event.contact = 'contact@example.com'
|
|
|
|
assert @event.valid?, @event.errors.messages
|
2014-05-26 01:06:43 +02:00
|
|
|
|
|
|
|
# Check invalid url
|
|
|
|
@event.url = 'htt://truc.com'
|
2014-05-31 23:13:43 +02:00
|
|
|
assert !@event.valid?, @event.errors.messages
|
2014-05-26 01:06:43 +02:00
|
|
|
|
|
|
|
@event.url = 'http:/truc.com'
|
2014-05-31 23:13:43 +02:00
|
|
|
assert !@event.valid?, @event.errors.messages
|
2014-05-25 23:59:03 +02:00
|
|
|
end
|
2014-07-28 16:16:27 +02:00
|
|
|
|
|
|
|
test 'moderation' do
|
|
|
|
@event = Event.new(
|
|
|
|
title: 'hello world',
|
2014-08-06 14:47:47 +02:00
|
|
|
start_time: Time.new,
|
|
|
|
end_time: Time.new + 1,
|
2014-07-28 16:16:27 +02:00
|
|
|
description: 'et hop!',
|
2014-08-06 14:47:47 +02:00
|
|
|
city: City.first,
|
|
|
|
related_region: Region.first,
|
2014-07-28 16:16:27 +02:00
|
|
|
url: 'http://example.com',
|
|
|
|
contact: 'contact@example.com'
|
|
|
|
)
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
assert @event.save, @event.errors.messages
|
2014-07-28 16:16:27 +02:00
|
|
|
assert !@event.moderated?
|
|
|
|
|
|
|
|
@event.update(moderated: 1)
|
|
|
|
|
|
|
|
assert @event.moderated?, @event.errors.messages
|
|
|
|
end
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|