mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Add presence of problem to translation
This commit is contained in:
parent
bbe80b1409
commit
fa86abc06d
@ -69,6 +69,6 @@ class TranslationsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def translation_params
|
||||
params.require(:translation).permit(:title, :content)
|
||||
params.require(:translation).permit(:title, :content, :problem_id)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
class Translation < ActiveRecord::Base
|
||||
belongs_to :problem, inverse_of: :translations
|
||||
|
||||
validates :title, :content, presence: true
|
||||
validates :title, :content, :problem, presence: true
|
||||
validates :title, uniqueness: true
|
||||
|
||||
self.per_page = 50
|
||||
|
||||
@ -5,7 +5,8 @@ class TranslationsControllerTest < ActionController::TestCase
|
||||
@translation = translations(:one)
|
||||
@update = {
|
||||
title: 'New title',
|
||||
content: 'This is the new content'
|
||||
content: 'This is the new content',
|
||||
problem_id: Problem.first
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
2
test/fixtures/translations.yml
vendored
2
test/fixtures/translations.yml
vendored
@ -1,9 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
problem: one
|
||||
title: First title
|
||||
content: The content of the translation
|
||||
|
||||
two:
|
||||
problem: two
|
||||
title: Second title
|
||||
content: The content of the second translation
|
||||
|
||||
@ -22,7 +22,8 @@ class TranslationTest < ActiveSupport::TestCase
|
||||
test "should save correct translation" do
|
||||
translation = Translation.new(
|
||||
title: 'A unique title',
|
||||
content: 'Some content'
|
||||
content: 'Some content',
|
||||
problem: Problem.first
|
||||
)
|
||||
assert translation.save
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user