require 'test_helper' class EventTest < ActiveSupport::TestCase test 'basic event' do @event = Event.new( title: 'hello world', start_time: Time.new(), end_time: Time.new() + 1, description: 'et hop!', city: City.first(), related_region: Region.first(), url: 'http://example.com', contact: 'contact@example.com', submitter: 'submitter@example.com' ) assert @event.save(), @event.errors.messages assert_equal 32, @event.secret.size() assert_equal 32, @event.moderator_mail_id.size() assert_equal 32, @event.submitter_mail_id.size() end test 'validations' do @event = Event.new( title: 'hello world', start_time: Time.new(), end_time: Time.new() + 1, description: 'et hop!', city: City.first(), related_region: Region.first(), 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 # Check invalid url @event.url = 'htt://truc.com' assert !@event.valid?, @event.errors.messages @event.url = 'http:/truc.com' assert !@event.valid?, @event.errors.messages end test 'moderation' do @event = Event.new( title: 'hello world', start_time: Time.new(), end_time: Time.new() + 1, description: 'et hop!', city: City.first(), related_region: Region.first(), url: 'http://example.com', contact: 'contact@example.com' ) assert @event.save(), @event.errors.messages assert !@event.moderated? @event.update(moderated: 1) assert @event.moderated?, @event.errors.messages end end