Skip to content

Instantly share code, notes, and snippets.

@jonstorer
Last active December 19, 2015 19:49
Show Gist options
  • Save jonstorer/6009054 to your computer and use it in GitHub Desktop.
Save jonstorer/6009054 to your computer and use it in GitHub Desktop.
Testing data for verifying Missions in Production.
# A sample Gemfile
source "https://rubygems.org"
gem 'hashie'
# gem "rails"
GEM
remote: https://rubygems.org/
specs:
hashie (2.0.5)
PLATFORMS
ruby
DEPENDENCIES
hashie
require 'hashie'
module MissionsTest
def self.path
File.expand_path(File.join(File.expand_path(__FILE__), '..', 'missions.yml'))
end
def self.missions_data
YAML::load_file(path).map {|md| Hashie::Mash.new(md)}
end
def self.data_for(title)
missions_data.find {|m| m.title == title }
end
def self.add_tracking_numbers!
Mission.all.each do |mission|
mission.participations.each do |mission_progress|
mission_progress.phase_progresses.each do |phase_progress|
phase_progress.step_progresses.where(:_type => 'StepProgress::ConfirmAddress').each do |step_progress|
step_progress.set(:tracking_number, SecureRandom.hex(6))
end
end
end
end
end
def self.add_downloads!
Mission.all.each do |mission|
mission.phases.each do |phase|
phase.steps.where(:_type => 'Step::Download').each do |step|
rand(3).times do |i|
download = Download.create!(:download_step_id => step.id, :title => "#{phase.name} Links (#{i})" )
download.add_links 100.times.map{ "http://bit.ly/#{SecureRandom.hex(3)}" }
end
end
end
end
end
def self.reset_missions_and_participations!
Download.destroy_all
Mission.all.each do |mission|
mission.set(:phases, [])
mission.participations.each do |participation|
participation.set(:stage, 'targeted')
participation.set(:phase_progresses, [])
end
mission_data = data_for(mission.title)
if mission_data
mission_data.phases.each do |phase_data|
steps_data = phase_data.delete(:steps)
phase = mission.phases.find_or_create_by(phase_data)
steps_data.each do |step_data|
type = step_data.delete(:type)
phase.steps.find_or_create_by(step_data, type.constantize)
end
end
mission.save!
else
puts "no data for #{mission.title}"
end
end
end
end
-
:title: Find Poutine
:description: Eat the Poutine
:phases:
-
:name: Download our Poutine Recipe
:position: 0
:steps:
-
:position: 0
:type: 'Step::Download'
-
:name: Get our special sauce delivered!
:position: 1
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:title: Homo Milk
:description: Good for you Bones
:phases:
-
:name: Get a bottle delivered
:position: 0
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:name: Download Nutrition Facts
:position: 1
:steps:
-
:position: 0
:type: 'Step::Download'
-
:title: Pizza Pizza
:description: Not Little Caesars
:phases:
-
:name: Download Money Saving Coupons
:position: 0
:steps:
-
:position: 0
:type: 'Step::Download'
-
:name: Free breadsticks delivered
:position: 1
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:title: Ice Cream Mafia
:description: Mr Softy vs FroYo
:phases:
-
:name: Print and wave your flag!
:position: 0
:steps:
-
:position: 0
:type: 'Step::Download'
-
:name: Mr Softy to your house!
:position: 1
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:title: Poutine is delicious
:description: And Healthy
:phases:
-
:name: Get your own gravy pool!
:position: 0
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:name: Gravy recipe
:position: 1
:steps:
-
:position: 0
:type: 'Step::Download'
-
:title: Drink homo milk
:description: Until you vomm
:phases:
-
:name: Homo Milk Facts
:position: 0
:steps:
-
:position: 0
:type: 'Step::Download'
-
:name: Milk Delivery
:position: 1
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:title: Pizza Pizza Pizza Pizza Pizza Pizza
:description: Diabeetus
:phases:
-
:name: Pizza in yo FACE
:position: 0
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:name: Moar Coupons!
:position: 1
:steps:
-
:position: 0
:type: 'Step::Download'
-
:title: The Mafia of Ice Cream
:description: Will drown you in cow
:phases:
-
:name: Milk murder directions
:position: 0
:steps:
-
:position: 0
:type: 'Step::Download'
-
:name: "We'll hide the body!"
:position: 1
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:title: Wax Your Leg
:description: Wax one and only one leg.
:phases:
-
:name: Get the Wax
:position: 0
:steps:
-
:position: 0
:type: 'Step::ConfirmAddress'
-
:name: Download waxing instructions
:position: 1
:steps:
-
:position: 0
:type: 'Step::Download'
-
:title: Hit on a Mom
:description: If you get a date, double points.
:phases:
-
:name: Pickup Lines Packet
:position: 0
:steps:
-
:type: 'Step::ConfirmAddress'
:position: 0
-
:title: Funnel 3 beers
:description: College
:phases:
-
:name: Build a Funnel Instructions
:position: 0
:steps:
-
:type: 'Step::Download'
:position: 0
-
:title: Get an old man to pose on camera
:description: Clothed
:phases:
-
:name: Receive your camera!
:position: 0
:steps:
-
:type: 'Step::ConfirmAddress'
:position: 0
-
:name: Download todos
:position: 1
:steps:
-
:type: 'Step::Download'
:position: 0
@benson
Copy link

benson commented Jul 16, 2013

BrandActionGroupQuota isn't actually being created, need to do package.brand_action_group_quotas.create

@benson
Copy link

benson commented Jul 16, 2013

And make sure we don't use Crowdtap VIPs in production

@benson
Copy link

benson commented Sep 6, 2013

need some steps with multiple phases

@yodarjun
Copy link

yodarjun commented Sep 6, 2013

Assign an internal_name to the brand action group

@yodarjun
Copy link

yodarjun commented Sep 6, 2013

Otherwise, lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment