Skip to content
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

Feature Flags #252

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ gem "httparty", "~> 0.21"
gem "invisible_captcha"
gem "omniauth-azure-activedirectory-v2"
gem "sentry-rails", "~> 5.11"
gem 'flipper'
gem 'flipper-active_record'
gem 'flipper-ui'

group :test do
gem "shoulda-matchers", "~> 5.0"
Expand Down
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ GEM
bootsnap (1.16.0)
msgpack (~> 1.2)
brakeman (6.0.1)
brow (0.4.1)
builder (3.2.4)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
Expand Down Expand Up @@ -167,6 +168,18 @@ GEM
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
flipper (1.0.0)
brow (~> 0.4.1)
concurrent-ruby (< 2)
flipper-active_record (1.0.0)
activerecord (>= 4.2, < 8)
flipper (~> 1.0.0)
flipper-ui (1.0.0)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 1.0.0)
rack (>= 1.4, < 4)
rack-protection (>= 1.5.3, <= 4.0.0)
sanitize (< 7)
foreman (0.87.2)
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
Expand Down Expand Up @@ -379,6 +392,9 @@ GEM
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sanitize (6.1.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
scenic (1.7.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
Expand Down Expand Up @@ -461,6 +477,9 @@ DEPENDENCIES
dotenv-rails
factory_bot_rails
faker
flipper
flipper-active_record
flipper-ui
foreman
govuk-components (= 4.1.0)
govuk_design_system_formbuilder
Expand Down
6 changes: 6 additions & 0 deletions config/initializers/flipper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CanAccessFlipperUI
def self.matches?(request)
current_user = request.env['warden'].user
current_user.present?
end
end
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
resources "reports", only: %i[show index]
get "/duplicates", to: "applicants#duplicates"
get "/audits", to: "audits#index"

constraints CanAccessFlipperUI do
mount Flipper::UI.app(Flipper) => '/features'
end
end
end
22 changes: 22 additions & 0 deletions db/migrate/20230915092215_create_flipper_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class CreateFlipperTables < ActiveRecord::Migration[7.0]
def self.up
create_table :flipper_features do |t|
t.string :key, null: false
t.timestamps null: false
end
add_index :flipper_features, :key, unique: true

create_table :flipper_gates do |t|
t.string :feature_key, null: false
t.string :key, null: false
t.string :value
t.timestamps null: false
end
add_index :flipper_gates, [:feature_key, :key, :value], unique: true
end

def self.down
drop_table :flipper_gates
drop_table :flipper_features
end
end
18 changes: 17 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading