Skip to content
Permalink
Browse files

AO3-5650 Set work language from API (#3553)

  • Loading branch information...
ariana-paris authored and redsummernight committed Apr 2, 2019
1 parent 18768c3 commit f27189d9c1e5c4ba5d78329180b112b81afc7898
@@ -211,6 +211,7 @@ def story_parser_options(archivist, work_params)
relationship: work_params[:relationships],
category: work_params[:categories],
freeform: work_params[:additional_tags],
language_id: Language.find_by(short: work_params[:language_code])&.id,
summary: work_params[:summary],
notes: work_params[:notes],
encoding: work_params[:encoding],
@@ -29,7 +29,7 @@ def api_fields
characters: "API 1, API 2", rating: "General", relationships: "bar 1/bar 2",
categories: "M/M", freeform: "API tag 1, API tag 2", external_author_name: "API Author",
external_author_email: "api@foo.com", notes: "This is an <i>API note</i>.",
date: "2002-01-12", chapter_title: "API chapter title (TBD)"
date: "2002-01-12", chapter_title: "API chapter title (TBD)", language_code: "es"
}
end

@@ -131,6 +131,8 @@
describe "Provided API metadata should be used if present" do
before(:all) do
Rails.cache.clear
Language.find_or_create_by(short: "es", name: "Español")

mock_external

archivist = create(:archivist)
@@ -148,10 +150,12 @@
relationships: api_fields[:relationships],
categories: api_fields[:categories],
additional_tags: api_fields[:freeform],
language_code: api_fields[:language_code],
external_author_name: api_fields[:external_author_name],
external_author_email: api_fields[:external_author_email],
notes: api_fields[:notes],
chapter_urls: ["http://foo"] }
chapter_urls: ["http://foo"]
}
]
}

@@ -196,6 +200,9 @@
it "API should override content for Additional Tags" do
expect(@work.freeforms.flat_map(&:name)).to eq(api_fields[:freeform].split(", "))
end
it "API should override content for Language" do
expect(Language.find_by(id: @work.language_id).short).to eq(api_fields[:language_code])
end
it "API should override content for Notes" do
expect(@work.notes).to eq("<p>" + api_fields[:notes] + "</p>")
end
@@ -329,6 +336,9 @@
it "Additional Tags should be empty" do
expect(@work.freeforms).to be_empty
end
it "Language should be English" do
expect(@work.language_id).to eq(Language.find_by(short: "en").id)
end
it "Notes should be empty" do
expect(@work.notes).to be_empty
end

0 comments on commit f27189d

Please sign in to comment.
You can’t perform that action at this time.