115 lines
2.7 KiB
Ruby
115 lines
2.7 KiB
Ruby
require 'test_helper'
|
|
|
|
# Event life cycle
|
|
class EventsControllerTest < ActionController::TestCase
|
|
include Devise::TestHelpers
|
|
|
|
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
|
|
|
|
test 'should preview event' do
|
|
assert_no_difference 'Event.count' do
|
|
patch :preview_create, event: {
|
|
title: @event.title,
|
|
start_time: @event.start_time,
|
|
end_time: @event.end_time,
|
|
description: @event.description,
|
|
city: @event.city,
|
|
region: @event.related_region,
|
|
locality: @event.locality,
|
|
url: @event.url,
|
|
contact: @event.contact,
|
|
submitter: @event.submitter,
|
|
tags: @event.tags
|
|
}
|
|
|
|
assert_empty assigns(:event).errors
|
|
end
|
|
|
|
assert_response :success
|
|
end
|
|
|
|
test 'should create event' do
|
|
assert_difference 'Event.count' do
|
|
post :create, event: {
|
|
title: @event.title,
|
|
start_time: @event.start_time,
|
|
end_time: @event.end_time,
|
|
description: @event.description,
|
|
city: @event.city,
|
|
region: @event.related_region,
|
|
locality: @event.locality,
|
|
url: @event.url,
|
|
contact: @event.contact,
|
|
submitter: @event.submitter,
|
|
tags: @event.tags
|
|
}
|
|
|
|
assert_empty assigns(:event).errors.messages
|
|
end
|
|
|
|
assert_redirected_to root_url
|
|
end
|
|
|
|
test 'should show event' do
|
|
get :show, id: @event
|
|
assert_response :success
|
|
end
|
|
|
|
test 'should get edit' do
|
|
get :edit, id: @event, secret: 'MyString'
|
|
assert_response :success
|
|
end
|
|
|
|
test 'should not get edit' do
|
|
get :edit, id: @event
|
|
assert_redirected_to root_url
|
|
end
|
|
|
|
test 'should update event' do
|
|
patch :update, id: @event, secret: 'MyString', event: {
|
|
title: @event.title,
|
|
start_time: @event.start_time,
|
|
end_time: @event.end_time,
|
|
description: @event.description,
|
|
city: @event.city,
|
|
region: @event.related_region,
|
|
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 }
|
|
|
|
assert_empty assigns(:event).errors.messages
|
|
assert_redirected_to :root
|
|
end
|
|
|
|
test 'should get cancel page' do
|
|
get :cancel, id: @event, secret: 'MyString'
|
|
assert_response :success
|
|
end
|
|
|
|
test 'should destroy event' do
|
|
assert_difference('Event.count', -1) do
|
|
delete :destroy, id: @event, secret: 'MyString'
|
|
end
|
|
|
|
assert_redirected_to events_path
|
|
end
|
|
end
|