Sha256: 547f3f54c8df2117df70e08f1a2844f8c3caa64b356624adb3e240911403743a

Contents?: true

Size: 1001 Bytes

Versions: 4

Compression:

Stored size: 1001 Bytes

Contents

# This migration comes from spree_promo (originally 20120119024721)
# LandingPage used to support static pages, we've moved to a static
# event. This adds path to promotions then migrates the old LandingPage rules
class ContentVisitedEvent < ActiveRecord::Migration

  # Removed Class for Migrations
  class Spree::Promotion::Rules::LandingPage < Spree::PromotionRule
    preference :path, :string
    def eligible?(order, options = {})
      true
    end
  end

  def up
    add_column :spree_activators, :path, :string

    Spree::Promotion::Rules::LandingPage.all.each do |promotion_rule|
      promotion = promotion_rule.promotion
      say "migrating #{promotion.name} promotion to use 'spree.content.visited' event"
      promotion.event_name = 'spree.content.visited'
      promotion.path = promotion_rule.preferred_path
      promotion.promotion_rules.delete promotion_rule
      promotion.save(:validate => false)
    end
  end

  def down
    remove_column :spree_activators, :path
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datashift_spree-0.3.0 spec/sandbox/db/migrate/20121023154480_content_visited_event.spree_promo.rb
datashift_spree-0.2.1 spec/sandbox/db/migrate/20121015151273_content_visited_event.spree_promo.rb
datashift_spree-0.2.0 spec/sandbox/db/migrate/20120925192841_content_visited_event.spree_promo.rb
datashift_spree-0.1.0 spec/sandbox/db/migrate/20120918081572_content_visited_event.spree_promo.rb