-
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/mvp interview survey (#4549)
## Because <!-- Summarize the purpose or reasons for this PR, e.g. what problem it solves or what benefit it provides. --> - We need a feature flag to hide the interview survey feature behind. ## This PR <!-- A bullet point list of one or more items describing the specific changes. --> - Creates route, controller, view, and updates flipper gates - Adds feature flag check to controller - System test coverage for feature flag behavior to ensure no one can access the feature if it is disabled ## Issue <!-- If this PR closes an open issue in this repo, replace the XXXXX below with the issue number, e.g. Closes #2013. If this PR closes an open issue in another TOP repo, replace the #XXXXX with the URL of the issue, e.g. Closes https://github.com/TheOdinProject/curriculum/issues/XXXXX If this PR does not close, but is related to another issue or PR, you can link it as above without the 'Closes' keyword, e.g. 'Related to #2013'. --> Related to #4524 ~~Missing tests that were called for in that issue.~~ There are now two system tests. ## Additional Information <!-- Any other information about this PR, such as a link to a Discord discussion. --> ~~The feature flag does work correctly in the view, but I'm not getting a redirect to work in the controller if the feature is disabled. It still renders the page as if the feature was enabled.~~ This is resolved.
- Loading branch information
1 parent
fa2994f
commit 6950307
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 |