1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-26 18:18:51 +01:00

Allow admins to directly set translations

This commit is contained in:
2019-02-23 13:49:25 +01:00
parent 1c2a73ba54
commit d56f0bf587
6 changed files with 49 additions and 8 deletions

View File

@@ -40,6 +40,28 @@ class TranslationsControllerTest < ActionDispatch::IntegrationTest
assert_equal users(:translator), Translation.last.author
end
test "should create and accept translation from admin" do
login_admin
assert_difference('Translation.count') do
post problem_translations_url(problem_id: 1, translation: @update, accept: true)
end
assert_redirected_to problem_path(id: 1)
assert_equal users(:admin), Translation.last.author
assert_equal Problem.find(1).translation, Translation.last
end
test "should create but not accept translation from normal user" do
login_translator
assert_difference('Translation.count') do
post problem_translations_url(problem_id: 1, translation: @update, accept: true)
end
assert_redirected_to problem_path(id: 1)
assert_equal users(:translator), Translation.last.author
assert_not_equal Problem.find(1).translation, Translation.last
end
test "should not create incorrect translation" do
assert_no_difference('Translation.count') do
post problem_translations_url(problem_id: 1, translation: @incorrect)