-
Notifications
You must be signed in to change notification settings - Fork 6
COR-749: Set up Flipper #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
config/application.rb
Outdated
|
||
Flipper.register(:internal) { |request| request.internal? } | ||
Flipper.register(:authenticated) { |request| request.session[:current_user].present? && request.session[:current_user][:authenticated] } | ||
Flipper.register(:hiring_dot) { |request| request.host == 'admin.cbcortex.com' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the hiring_dot
group used for? Is this misnamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is misnamed, my bad
config/application.rb
Outdated
# Needed until there is a better fix for Paperclip. https://github.com/thoughtbot/paperclip/issues/1924#issuecomment-123927367 | ||
Paperclip.options[:content_type_mappings] = {:csv => 'text/plain'} | ||
|
||
config.middleware.use Flipper::Middleware::Memoizer, lambda { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using a lambda, we can throw this line and our group definitions in the flipper.rb
initializer. This'll also cut down on the noise in application.rb
(and we should eventually do the same for our CORS middleware init). For example, flipper.rb
might look like:
module Cortex
def self.flipper
@flipper ||= Flipper.new(Flipper::Adapters::ActiveRecord.new)
end
end
Cortex::Application.config.middleware.use Flipper::Middleware::Memoizer, Cortex.flipper
Flipper.register(:internal) { |request| request.internal? }
Flipper.register(:authenticated) { |request| request.session[:current_user].present? && request.session[:current_user][:authenticated] }
Flipper.register(:hiring_dot) { |request| request.host == 'admin.cbcortex.com' }
Flipper.register(:dev) { |request| request.host == 'dev.admin.cbcortex.com' || request.host == 'localhost' }
Flipper.register(:staging) { |request| request.host == 'stg.admin.cbcortex.com' }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we tried this on Employer and the reason I ultimately moved this chunk of code into application.rb
is that the Memorizer can't properly lazy load Flipper if it's in the initializer / we encountered some issues with the Memorizer and the Webpack building
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it out before I made the comment, so I believe it /should/ work - I didn't test Webpack, however.
Would you also mind looking into why your migrations generate |
@toastercup I noticed that too, I think the random noise comes from rolled back changes in my local schema.rb that has collected over time...I will remove the noise |
@toastercup Applied changes and cleaned Schema |
Purpose:
Sets up and configures the Flipper feature flagging gem for Cortex to allow for controlled releases of content / in-site A/B testing.
JIRA:
https://cb-content-enablement.atlassian.net/browse/COR-749
Steps to Take On Prod
/flipper
Changes:
Changes to setup
Architectural changes
Migrations
Library changes
Side effects
Screenshots
Before
N/A
After
N/A
QA Links:
http://web.cortex-7.development.c66.me
How to Verify These Changes
Specific pages to visit
/flipper
Steps to take
Because of the admin restriction there are three different paths to verifying this story
** Admin Route - Log in as an Admin and go to
/flipper
. You should succeed.** Anonymous Route - Don't Log in, then go to
/flipper
. You should fail.** Regular User Route - Log in and go to
/flipper
. You should fail.Responsive considerations
Relevant PRs/Dependencies:
N/A
Additional Information
Based on the Employer implementation.