|
|
|
@ -11,6 +11,12 @@ class ModerationsControllerTest < ActionController::TestCase
|
|
|
|
|
sign_in users(:one)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should get index' do
|
|
|
|
|
get :index
|
|
|
|
|
assert_response :success
|
|
|
|
|
assert_not_nil assigns(:events)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should preview event' do
|
|
|
|
|
patch :preview, id: @moderation, event: {
|
|
|
|
|
title: 'hello world',
|
|
|
|
@ -26,6 +32,13 @@ class ModerationsControllerTest < ActionController::TestCase
|
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should not edit event' do
|
|
|
|
|
put :update, id: @moderation, event: {
|
|
|
|
|
title: nil
|
|
|
|
|
}
|
|
|
|
|
assert_not_empty assigns(:moderation).errors
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should accept event' do
|
|
|
|
|
@moderation = events :proposed
|
|
|
|
|
|
|
|
|
@ -50,21 +63,23 @@ class ModerationsControllerTest < ActionController::TestCase
|
|
|
|
|
start_time: @moderation.start_time,
|
|
|
|
|
end_time: @moderation.end_time,
|
|
|
|
|
description: @moderation.description,
|
|
|
|
|
city: @moderation.city,
|
|
|
|
|
region: @moderation.related_region,
|
|
|
|
|
locality: @moderation.locality,
|
|
|
|
|
url: @moderation.url,
|
|
|
|
|
contact: @moderation.contact,
|
|
|
|
|
moderated: @moderation.moderated,
|
|
|
|
|
secret: @moderation.secret,
|
|
|
|
|
submission_time: @moderation.submission_time,
|
|
|
|
|
submitter: @moderation.submitter,
|
|
|
|
|
tags: @moderation.tags }
|
|
|
|
|
tags: @moderation.tags
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert_empty assigns(:moderation).errors
|
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should not update event' do
|
|
|
|
|
patch :update, id: @moderation, secret: 'MyString', event: {
|
|
|
|
|
title: nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert_not_empty assigns(:moderation).errors
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should reject event' do
|
|
|
|
|
assert_difference 'Event.count', -1 do
|
|
|
|
|
delete :destroy, id: @moderation
|
|
|
|
@ -74,4 +89,14 @@ class ModerationsControllerTest < ActionController::TestCase
|
|
|
|
|
|
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test 'should reject event with a reason' do
|
|
|
|
|
assert_difference 'Event.count', -1 do
|
|
|
|
|
delete :destroy, id: @moderation, reason: 'r_4'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_empty assigns(:moderation).errors
|
|
|
|
|
|
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|