2016-09-11 17:40:49 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
# Test event callbacks
|
|
|
|
class EventCallbacksTest < ActiveSupport::TestCase
|
|
|
|
setup do
|
|
|
|
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'schedule' do
|
2017-10-21 22:12:19 +02:00
|
|
|
event = Event.new(
|
2016-09-11 17:40:49 +02:00
|
|
|
title: 'hello world',
|
|
|
|
start_time: Time.zone.now, end_time: Time.zone.now + 1.hour,
|
|
|
|
description: 'et hop!',
|
|
|
|
city: City.first, region: Region.first,
|
|
|
|
url: 'http://example.com',
|
|
|
|
contact: 'contact@example.com',
|
2016-12-17 16:59:11 +01:00
|
|
|
tag_list: 'hello world'
|
2016-09-11 17:40:49 +02:00
|
|
|
)
|
|
|
|
assert_difference 'Event.count' do
|
2017-10-21 22:12:19 +02:00
|
|
|
assert event.save, event.errors.messages
|
2016-09-11 17:40:49 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'moderation' do
|
2017-10-21 22:12:19 +02:00
|
|
|
event = Event.new(
|
2016-09-11 17:40:49 +02:00
|
|
|
title: 'hello world',
|
|
|
|
start_time: Time.zone.now + 1.hour, end_time: Time.zone.now + 2.hours,
|
|
|
|
repeat: 1, rule: 'monthly',
|
|
|
|
description: 'et hop!',
|
|
|
|
city: City.first, region: Region.first,
|
|
|
|
url: 'http://example.com',
|
|
|
|
contact: 'contact@example.com',
|
2016-12-17 16:59:11 +01:00
|
|
|
tag_list: 'hello world'
|
2016-09-11 17:40:49 +02:00
|
|
|
)
|
|
|
|
|
2017-10-21 22:12:19 +02:00
|
|
|
assert event.save, event.errors.messages
|
|
|
|
assert_not event.moderated?
|
2016-09-11 17:40:49 +02:00
|
|
|
|
|
|
|
assert_difference 'Event.count' do
|
2017-10-21 22:12:19 +02:00
|
|
|
event.update moderated: 1
|
2016-09-11 17:40:49 +02:00
|
|
|
end
|
|
|
|
|
2017-10-21 22:12:19 +02:00
|
|
|
assert event.moderated?, event.errors.messages
|
2016-09-11 17:40:49 +02:00
|
|
|
end
|
|
|
|
end
|