Permalink
Browse files

Set attr_accessible on Document

Since #paragraph_id_list and #tlanslated are calculated
automatically, they should not be passed to .new
  • Loading branch information...
Yutaka HARA
Yutaka HARA committed Jun 3, 2012
1 parent 87579d3 commit 0cb4e33a5ad8d331f0c37d28f7a9fbfb6a4b468b
Showing with 4 additions and 2 deletions.
  1. +2 −0 app/models/document.rb
  2. +2 −2 test/unit/document_test.rb
View
@@ -2,6 +2,8 @@ class Document < ActiveRecord::Base
belongs_to :entry
belongs_to :language
+ attr_accessible :entry, :language, :body
+
validates :entry_id, presence: true, uniqueness: {
scope: [:language_id],
message: "already has a Document for the language and version for entry %{value}"
@@ -7,8 +7,8 @@ class DocumentTest < ActiveSupport::TestCase
should "check <translated> has valid value" do
doc = Document.new(entry: entries("builtin19"),
language: languages("ja"),
- body: "",
- translated: "xxxx")
+ body: "")
+ doc.translated = "xxxx"
assert_equal false, doc.valid?
assert_match /unknown state/, doc.errors[:translated].first
end

0 comments on commit 0cb4e33

Please sign in to comment.