Sha256: 4a8af068270c6b997e055c2f3e9a1eb0bb8bcddfaaecbc4464bab36864b49549

Contents?: true

Size: 1.57 KB

Versions: 46

Compression:

Stored size: 1.57 KB

Contents

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

class EmailTestContext < Card::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

46 entries across 46 versions & 1 rubygems

Version Path
card-1.100.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.6 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.5 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.4 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.3 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.2 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.1 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.99.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.98.3 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.98.2 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.98.1 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.98.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.97.0.1 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.97.0 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.96.8 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.96.7 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.96.6 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.96.5 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.96.4 db/migrate_core_cards/20170209132834_email_test_context.rb
card-1.96.3 db/migrate_core_cards/20170209132834_email_test_context.rb