Skip to content

Instantly share code, notes, and snippets.

@Heavyblade
Created July 28, 2021 15:17
Show Gist options
  • Save Heavyblade/1bfcdec7a43b75b0d05eaac22f353e03 to your computer and use it in GitHub Desktop.
Save Heavyblade/1bfcdec7a43b75b0d05eaac22f353e03 to your computer and use it in GitHub Desktop.
describe "When updating privacy policy on an non defult locale" do
let(:brand) { create(:brand, :with_legal_documents, text_translations: { "en-US" => "en US", "en-AU" => "en AU"}) }
let(:privacy_policy_attributes) do
{ "0" =>
{
"id" => brand.current_privacy_policy.id,
"text_translations" => { "en-AU" => "en-AU updated" },
"document_type" => "privacy_policy"
}
}
end
before do
brand.config.update_column(:enabled_locales, ["en-AU", "en-US"])
brand_attributes["brand_legal_documents_attributes"] = privacy_policy_attributes
end
it "should not create a new brand legal document version for the privacy" do
byebug
ENV["NEW_TERMS_ENABLED_BRANDS"] = brand.id.to_s
put :update, params: {
id: brand.id,
brand: brand_attributes.except(:platform, :auth_schemas)
}
assert_equal 2, brand.brand_legal_documents.count
assert_equal "en AU", brand.current_privacy_policy.text_translations['en-AU']
end
end
describe "When updating privacy policy on the default locale and another enabled locale" do
let(:privacy_policy_attributes) do
{ "0" =>
{
"id" => brand.current_privacy_policy.id,
"text_translations" => { "en-AU" => "en-AU updated", "en-US" => "a new version of privacy" },
"document_type" => "privacy_policy"
}
}
end
before do
ENV["NEW_TERMS_ENABLED_BRANDS"] = brand.id.to_s
brand.config.update_column(:enabled_locales, ["en-AU", "en-US"])
brand_attributes["brand_legal_documents_attributes"] = privacy_policy_attributes
put :update, params: {
id: brand.id,
brand: brand_attributes.except(:platform, :auth_schemas)
}
end
it "should not create a new brand legal document version for the privacy" do
byebug
assert_equal 4, brand.brand_legal_documents.count
assert_equal "a new version of privacy", brand.current_privacy_policy.text_translations['en-US']
assert_equal "en-AU updated", brand.current_privacy_policy.text_translations['en-AU']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment