2017-12-11 04:05:11 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-04 22:27:41 +00:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
RSpec.describe Translation, type: :model, versioning: true do
|
2021-08-30 02:22:39 +00:00
|
|
|
context "with non-US translations" do
|
2017-07-04 22:27:41 +00:00
|
|
|
it "not change the number of versions" do
|
|
|
|
described_class.create!(headline: "Headline")
|
|
|
|
expect(PaperTrail::Version.count).to(eq(0))
|
|
|
|
end
|
|
|
|
|
2021-08-30 02:22:39 +00:00
|
|
|
context "when after update" do
|
2017-07-04 22:27:41 +00:00
|
|
|
it "not change the number of versions" do
|
|
|
|
translation = described_class.create!(headline: "Headline")
|
2018-12-04 21:10:35 +00:00
|
|
|
translation.update(content: "Content")
|
2017-07-04 22:27:41 +00:00
|
|
|
expect(PaperTrail::Version.count).to(eq(0))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-30 02:22:39 +00:00
|
|
|
context "when after destroy" do
|
2017-07-04 22:27:41 +00:00
|
|
|
it "not change the number of versions" do
|
|
|
|
translation = described_class.create!(headline: "Headline")
|
|
|
|
translation.destroy
|
|
|
|
expect(PaperTrail::Version.count).to(eq(0))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-30 02:22:39 +00:00
|
|
|
context "with US translations" do
|
|
|
|
context "with drafts" do
|
2017-07-04 22:27:41 +00:00
|
|
|
it "creation does not change the number of versions" do
|
|
|
|
translation = described_class.new(headline: "Headline")
|
|
|
|
translation.language_code = "US"
|
|
|
|
translation.type = "DRAFT"
|
|
|
|
translation.save!
|
|
|
|
expect(PaperTrail::Version.count).to(eq(0))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "update does not change the number of versions" do
|
|
|
|
translation = described_class.new(headline: "Headline")
|
|
|
|
translation.language_code = "US"
|
|
|
|
translation.type = "DRAFT"
|
|
|
|
translation.save!
|
2018-12-04 21:10:35 +00:00
|
|
|
translation.update(content: "Content")
|
2017-07-04 22:27:41 +00:00
|
|
|
expect(PaperTrail::Version.count).to(eq(0))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-30 02:22:39 +00:00
|
|
|
context "with non-drafts" do
|
2017-07-04 22:27:41 +00:00
|
|
|
it "create changes the number of versions" do
|
|
|
|
described_class.create!(headline: "Headline", language_code: "US")
|
|
|
|
expect(PaperTrail::Version.count).to(eq(1))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "update does not change the number of versions" do
|
|
|
|
translation = described_class.create!(headline: "Headline", language_code: "US")
|
2018-12-04 21:10:35 +00:00
|
|
|
translation.update(content: "Content")
|
2017-07-04 22:27:41 +00:00
|
|
|
expect(PaperTrail::Version.count).to(eq(2))
|
|
|
|
expect(translation.versions.size).to(eq(2))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "destroy does not change the number of versions" do
|
|
|
|
translation = described_class.new(headline: "Headline")
|
|
|
|
translation.language_code = "US"
|
|
|
|
translation.save!
|
|
|
|
translation.destroy
|
|
|
|
expect(PaperTrail::Version.count).to(eq(2))
|
|
|
|
expect(translation.versions.size).to(eq(2))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|