-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature flag for interview survey feature
Because: * We want to be able to turn on and off the feature. This commit: * Adds a feature flag for the interview survey feature. * Adds a view, controller, and route for the feature. * Adds 2 tests for the feature flag.
- Loading branch information
1 parent
70f4654
commit a9dd576
Showing
6 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class InterviewSurveysController < ApplicationController | ||
def new | ||
unless Feature.enabled?(:survey_feature, current_user) | ||
redirect_to dashboard_path, notice: 'Feature not enabled' | ||
end | ||
end | ||
|
||
def create | ||
# puts params[:survey] | ||
redirect_to dashboard_path, notice: 'Survey Submitted' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<%= title('Interview Survey') %> | ||
|
||
<div> | ||
<div class="page-container"> | ||
<h1 class="page-heading-title">Interview Survey</h1> | ||
|
||
<div class='max-w-xl mx-auto'> | ||
<%# where form will be rendered %> | ||
</div> | ||
</div> | ||
</div> |
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
18 changes: 18 additions & 0 deletions
18
db/migrate/20240530151357_change_flipper_gates_value_to_text.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class ChangeFlipperGatesValueToText < ActiveRecord::Migration[7.0] | ||
def up | ||
# Ensure this incremental update migration is idempotent | ||
return unless connection.column_exists? :flipper_gates, :value, :string | ||
|
||
if index_exists? :flipper_gates, %i[feature_key key value] | ||
remove_index :flipper_gates, %i[feature_key key value] | ||
end | ||
change_column :flipper_gates, :value, :text | ||
add_index :flipper_gates, %i[feature_key key value], unique: true, length: { value: 255 } | ||
end | ||
|
||
def down | ||
change_column :flipper_gates, :value, :string | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Interview survey' do | ||
let(:user) { create(:user) } | ||
|
||
before do | ||
sign_in(user) | ||
end | ||
|
||
context 'when the feature is enabled' do | ||
before do | ||
Flipper.enable(:survey_feature) | ||
end | ||
|
||
it 'shows the survey' do | ||
visit new_interview_survey_path | ||
expect(page).to have_content('Interview Survey') | ||
end | ||
end | ||
|
||
context 'when the feature is disabled' do | ||
it 'redirects to the dashboard' do | ||
visit new_interview_survey_path | ||
expect(page).to have_content('Feature not enabled') | ||
expect(page).to have_current_path(dashboard_path) | ||
end | ||
end | ||
end |