Created
August 26, 2012 20:07
-
-
Save samsworldofno/3483222 to your computer and use it in GitHub Desktop.
Continuous Deployment / Rollout Gem Code Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BroadcastFlow | |
class V2Decorator < ApplicationDecorator | |
def navigation_partial | |
end | |
def show_path | |
h.event_path(model) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DecoratedEventHelper | |
def decorate_event(event, promoter) | |
if rollout.active?(:new_broadcast_flow, promoter) | |
BroadcastFlow::V2Decorator | |
else | |
BroadcastFlow::V1Decorator | |
end.decorate(event) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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