2013-12-28 23:45:13 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class EventsControllerTest < ActionController::TestCase
|
2014-07-01 15:50:39 +02:00
|
|
|
include Devise::TestHelpers
|
|
|
|
|
2013-12-28 23:45:13 +01:00
|
|
|
setup do
|
2014-07-01 15:50:39 +02:00
|
|
|
@event = events :one
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should get index' do
|
2013-12-28 23:45:13 +01:00
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:events)
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should get new' do
|
2013-12-28 23:45:13 +01:00
|
|
|
get :new
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should preview event' do
|
|
|
|
assert_no_difference 'Event.count' do
|
2014-01-01 21:26:35 +01:00
|
|
|
post :create, visu: 'visualise', event: {
|
|
|
|
title: @event.title,
|
|
|
|
start_time: @event.start_time,
|
|
|
|
end_time: @event.end_time,
|
|
|
|
description: @event.description,
|
|
|
|
city: @event.city,
|
2014-07-01 15:50:39 +02:00
|
|
|
region: @event.related_region,
|
2014-01-01 21:26:35 +01:00
|
|
|
locality: @event.locality,
|
|
|
|
url: @event.url,
|
|
|
|
contact: @event.contact,
|
|
|
|
submitter: @event.submitter,
|
|
|
|
tags: @event.tags
|
|
|
|
}
|
2014-07-01 15:50:39 +02:00
|
|
|
|
|
|
|
assert_empty assigns(:event).errors
|
2014-01-01 21:26:35 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should create event' do
|
|
|
|
assert_difference 'Event.count' do
|
2014-01-01 21:26:35 +01:00
|
|
|
post :create, event: {
|
|
|
|
title: @event.title,
|
|
|
|
start_time: @event.start_time,
|
|
|
|
end_time: @event.end_time,
|
|
|
|
description: @event.description,
|
|
|
|
city: @event.city,
|
2014-07-01 15:50:39 +02:00
|
|
|
region: @event.related_region,
|
2014-01-01 21:26:35 +01:00
|
|
|
locality: @event.locality,
|
|
|
|
url: @event.url,
|
|
|
|
contact: @event.contact,
|
|
|
|
submitter: @event.submitter,
|
|
|
|
tags: @event.tags
|
|
|
|
}
|
2014-07-01 15:50:39 +02:00
|
|
|
|
|
|
|
assert_empty assigns(:event).errors.messages
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|
|
|
|
|
2014-06-29 14:09:02 +02:00
|
|
|
assert_redirected_to root_url
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should show event' do
|
2013-12-28 23:45:13 +01:00
|
|
|
get :show, id: @event
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should get edit' do
|
2014-05-25 23:59:03 +02:00
|
|
|
get :edit, id: @event, secret: 'MyString'
|
2013-12-28 23:45:13 +01:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should not get edit' do
|
2014-05-25 23:59:03 +02:00
|
|
|
get :edit, id: @event
|
2014-06-29 14:09:02 +02:00
|
|
|
assert_redirected_to root_url
|
2014-05-25 23:59:03 +02:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should update event' do
|
2014-05-25 23:59:03 +02:00
|
|
|
patch :update, id: @event, secret: 'MyString', event: {
|
2014-01-01 21:26:35 +01:00
|
|
|
title: @event.title,
|
|
|
|
start_time: @event.start_time,
|
|
|
|
end_time: @event.end_time,
|
|
|
|
description: @event.description,
|
|
|
|
city: @event.city,
|
2014-07-01 15:50:39 +02:00
|
|
|
region: @event.related_region,
|
2014-01-01 21:26:35 +01:00
|
|
|
locality: @event.locality,
|
|
|
|
url: @event.url,
|
|
|
|
contact: @event.contact,
|
|
|
|
moderated: @event.moderated,
|
|
|
|
secret: @event.secret,
|
|
|
|
submission_time: @event.submission_time,
|
|
|
|
submitter: @event.submitter,
|
|
|
|
tags: @event.tags }
|
2014-07-01 15:50:39 +02:00
|
|
|
|
|
|
|
assert_empty assigns(:event).errors.messages
|
2014-07-01 21:55:38 +02:00
|
|
|
assert_redirected_to :root
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should get cancel page' do
|
2014-05-25 23:59:03 +02:00
|
|
|
get :cancel, id: @event, secret: 'MyString'
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should destroy event' do
|
2013-12-28 23:45:13 +01:00
|
|
|
assert_difference('Event.count', -1) do
|
2014-05-25 23:59:03 +02:00
|
|
|
delete :destroy, id: @event, secret: 'MyString'
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to events_path
|
|
|
|
end
|
|
|
|
end
|