2014-01-06 11:22:39 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class ModerationsControllerTest < ActionController::TestCase
|
2014-07-01 15:50:39 +02:00
|
|
|
include Devise::TestHelpers
|
|
|
|
|
|
|
|
setup do
|
|
|
|
@moderation = events :one
|
|
|
|
|
|
|
|
sign_in users(:one)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should edit event' do
|
|
|
|
put :update, id: @moderation, event: {
|
|
|
|
title: 'hello world',
|
|
|
|
related_region: regions(:region_one)
|
|
|
|
}
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should accept event' do
|
2014-07-28 16:16:27 +02:00
|
|
|
@moderation = events :proposed
|
|
|
|
|
|
|
|
decision = @moderation.decision_time
|
|
|
|
assert !@moderation.moderated?
|
|
|
|
|
|
|
|
assert_difference 'Event.moderated.count' do
|
|
|
|
put :accept, id: @moderation
|
|
|
|
end
|
2014-07-01 15:50:39 +02:00
|
|
|
|
2014-07-07 13:14:17 +02:00
|
|
|
assert assigns(:moderation).moderated?
|
2014-07-01 15:50:39 +02:00
|
|
|
assert_empty assigns(:moderation).errors
|
2014-07-28 16:16:27 +02:00
|
|
|
|
|
|
|
assert decision < assigns(:moderation).decision_time
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
assert_redirected_to moderations_path
|
|
|
|
end
|
|
|
|
|
2014-07-20 21:46:28 +02:00
|
|
|
test 'should update event' do
|
|
|
|
patch :update, id: @moderation, secret: 'MyString', event: {
|
|
|
|
title: @moderation.title,
|
|
|
|
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 }
|
|
|
|
|
|
|
|
assert_empty assigns(:moderation).errors
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'should reject event' do
|
|
|
|
assert_difference 'Event.count', -1 do
|
|
|
|
delete :destroy, id: @moderation
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_empty assigns(:moderation).errors
|
|
|
|
|
|
|
|
assert_redirected_to moderations_path
|
|
|
|
end
|
2014-01-06 11:22:39 +01:00
|
|
|
end
|