mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 00:36:42 +01:00
49 lines
1.2 KiB
Ruby
49 lines
1.2 KiB
Ruby
require 'test_helper'
|
|
|
|
class TranslationsControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@update = {
|
|
title: 'New title',
|
|
content: 'This is the new content',
|
|
}
|
|
@incorrect = {
|
|
title: '',
|
|
content: ''
|
|
}
|
|
end
|
|
|
|
test "should get new for translated problem" do
|
|
get new_problem_translation_url(problem_id: 1)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should get new for untranslated problem" do
|
|
get new_problem_translation_url(problem_id: 3)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should create translation anonymously" do
|
|
assert_difference('Translation.count') do
|
|
post problem_translations_url(problem_id: 1, translation: @update)
|
|
end
|
|
|
|
assert_redirected_to problem_path(id: 1)
|
|
end
|
|
|
|
test "should create translation with user" do
|
|
login_translator
|
|
assert_difference('Translation.count') do
|
|
post problem_translations_url(problem_id: 1, translation: @update)
|
|
end
|
|
|
|
assert_redirected_to problem_path(id: 1)
|
|
assert_equal users(:translator), Translation.last.author
|
|
end
|
|
|
|
test "should not create incorrect translation" do
|
|
assert_no_difference('Translation.count') do
|
|
post problem_translations_url(problem_id: 1, translation: @incorrect)
|
|
end
|
|
end
|
|
end
|