mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Merge pull request #31 from PFischbeck/prefill_translation
Prefill translation form with old translation if possible
This commit is contained in:
commit
0e9a1ce617
@ -17,6 +17,10 @@ class TranslationsController < ApplicationController
|
|||||||
# GET /translations/new
|
# GET /translations/new
|
||||||
def new
|
def new
|
||||||
@translation = @problem.translations.build
|
@translation = @problem.translations.build
|
||||||
|
if @problem.is_translated?
|
||||||
|
@translation.title = @problem.translation.title
|
||||||
|
@translation.content = @problem.translation.content
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /translations
|
# POST /translations
|
||||||
|
|||||||
@ -23,11 +23,16 @@ class TranslationsControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:translations)
|
assert_not_nil assigns(:translations)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get new" do
|
test "should get new for translated problem" do
|
||||||
get :new, problem_id: 1
|
get :new, problem_id: 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "should get new for untranslated problem" do
|
||||||
|
get :new, problem_id: 3
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
test "should create translation" do
|
test "should create translation" do
|
||||||
assert_difference('Translation.count') do
|
assert_difference('Translation.count') do
|
||||||
post :create, problem_id: 1, translation: @update
|
post :create, problem_id: 1, translation: @update
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user