1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2025-12-10 00:36:42 +01:00

Add presence of problem to translation

This commit is contained in:
Philipp Fischbeck 2014-12-29 15:29:01 +01:00
parent bbe80b1409
commit fa86abc06d
5 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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