Skip to content

Instantly share code, notes, and snippets.

@samsworldofno
Created August 26, 2012 20:07
Show Gist options
  • Save samsworldofno/3483222 to your computer and use it in GitHub Desktop.
Save samsworldofno/3483222 to your computer and use it in GitHub Desktop.
Continuous Deployment / Rollout Gem Code Examples
module BroadcastFlow
class V1Decorator < ApplicationDecorator
def navigation_partial
h.render 'events_wizard/wizard_steps'
end
def show_path
h.events_wizard_path(model)
end
end
end
module BroadcastFlow
class V2Decorator < ApplicationDecorator
def navigation_partial
end
def show_path
h.event_path(model)
end
end
end
module DecoratedEventHelper
def decorate_event(event, promoter)
if rollout.active?(:new_broadcast_flow, promoter)
BroadcastFlow::V2Decorator
else
BroadcastFlow::V1Decorator
end.decorate(event)
end
end
Feature: New event
In order to get more attendees to my event
As a promoter
I want to add it to broadcast it to lots of listings sites
Background:
Given I am signed in as a full promoter
Scenario: Create event without new broadcast flow
Given I do not have access to the "new broadcast flow"
When I go to the events page
And I click "New Event"
Then I should be on event wizard v2
And I should be using the old broadcast flow
Scenario: Create event with new broadcast flow
Given I have access to the "new broadcast flow"
When I go to the events page
And I click "New Event"
Then I should be on event wizard v2
And I should be using the new broadcast flow
Given /^I have access to(?: the)? "([^"]*)"$/ do |feature|
activate_feature(feature)
end
Given /^I do not have access to(?: the)? "([^"]*)"$/ do |feature|
deactivate_feature(feature)
end
module RolloutHelpers
# Activates a feature in for a given user in Rollout
#
# @param [String] feature which will look something like "new broadcast flow"
# @param [User] user or more likely a promoter
def activate_feature(feature, user)
rollout_feature(:activate, feature, user)
end
# Deactivates a feature in for a given user in Rollout
#
# @param [String] feature which will look something like "new broadcast flow"
# @param [User] user or more likely a promoter
def deactivate_feature(feature, user)
rollout_feature(:deactivate, feature, user)
end
def deactivate_all_features
# ...
end
private
def rollout_feature(action, feature, user)
feature = feature.parameterize.underscore.to_sym
RolloutConnection.rollout.send("#{action}_user", feature, user)
end
end
World(RolloutHelpers)
After { deactivate_all_features }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment