2013-12-28 23:45:13 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class EventsControllerTest < ActionController::TestCase
|
|
|
|
setup do
|
|
|
|
@event = events(:one)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get index" do
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:events)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get new" do
|
|
|
|
get :new
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2014-01-01 21:26:35 +01:00
|
|
|
test "should preview event" do
|
|
|
|
assert_no_difference('Event.count') do
|
|
|
|
post :create, visu: 'visualise', event: {
|
|
|
|
title: @event.title,
|
|
|
|
start_time: @event.start_time,
|
|
|
|
end_time: @event.end_time,
|
|
|
|
description: @event.description,
|
|
|
|
city: @event.city,
|
|
|
|
region: regions(:region_one),
|
|
|
|
locality: @event.locality,
|
|
|
|
url: @event.url,
|
|
|
|
contact: @event.contact,
|
|
|
|
submitter: @event.submitter,
|
|
|
|
tags: @event.tags
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2013-12-28 23:45:13 +01: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,
|
|
|
|
region: regions(:region_one),
|
|
|
|
locality: @event.locality,
|
|
|
|
url: @event.url,
|
|
|
|
contact: @event.contact,
|
|
|
|
submitter: @event.submitter,
|
|
|
|
tags: @event.tags
|
|
|
|
}
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to event_path(assigns(:event))
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should show event" do
|
|
|
|
get :show, id: @event
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
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-05-25 23:59:03 +02:00
|
|
|
test "should not get edit" do
|
|
|
|
get :edit, id: @event
|
|
|
|
assert_redirected_to event_path(assigns(:event))
|
|
|
|
end
|
|
|
|
|
2013-12-28 23:45:13 +01: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,
|
|
|
|
region: regions(:region_one),
|
|
|
|
locality: @event.locality,
|
|
|
|
url: @event.url,
|
|
|
|
contact: @event.contact,
|
|
|
|
moderated: @event.moderated,
|
|
|
|
moderator_mail_id: @event.moderator_mail_id,
|
|
|
|
secret: @event.secret,
|
|
|
|
submission_time: @event.submission_time,
|
|
|
|
submitter: @event.submitter,
|
|
|
|
submitter_mail_id: @event.submitter_mail_id,
|
|
|
|
tags: @event.tags }
|
2013-12-28 23:45:13 +01:00
|
|
|
assert_redirected_to event_path(assigns(:event))
|
|
|
|
end
|
|
|
|
|
2014-05-25 23:59:03 +02:00
|
|
|
test "should get cancel page" do
|
|
|
|
get :cancel, id: @event, secret: 'MyString'
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2013-12-28 23:45:13 +01:00
|
|
|
test "should destroy event" do
|
|
|
|
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
|