Sha256: 0cd24ef112c496c4a726a8332dc0886f80ac50e1f734369537a7f95cadd749a2

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 KB

Contents

# -*- encoding : utf-8 -*-

class EmailTestContext < Cardio::Migration::Core
  def up
    ensure_card "*test context",
                codename: :test_context
    ensure_card "*changed card",
                codename: :changed_card
    ensure_card "*test context+*right+*default",
                type_id: Card::PointerID
    Card::Cache.reset_all

    { verification_email: "Wagn Bot+*account",
      password_reset_email: "Wagn Bot+*account",
      signup_alert_email: "User",
      follower_notification_email: "*changed card",
      "welcome email" => "User" }.each do |template, content|
      add_test_context template, content
    end

    update_follower_notification_template
  end

  def update_follower_notification_template
    dir = File.join data_path, "mailer"
    name = "follower notification email"
    codename = "follower_notification_email"
    update_if_unchanged "#{name}+*html message",
                        File.read(File.join(dir, "#{codename}.html"))
    update_if_unchanged "#{name}+*text message",
                        File.read(File.join(dir, "#{codename}.txt"))
    update_if_unchanged "#{name}+*subject",
                        "{{_user|name}} {{_|last_action_verb}} \"{{_|name}}\""
  end

  def update_if_unchanged name, content
    return if (card = Card[name]) && card.updater.codename != :wagn_bot

    ensure_card name, content: content
  end

  def add_test_context email_template, content
    return unless Card[email_template]

    ensure_card [email_template, :test_context],
                content: content,
                type_id: Card::PointerID
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-1.104.2 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.104.1 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.104.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.103.4 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.103.3 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.103.2 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.103.1 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.103.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.101.7 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.102.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.101.6 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.101.5 db/migrate_core_cards/20170209132834_email_test_context.rb