Skip to content

Commit

Permalink
Feature Flags (#252)
Browse files Browse the repository at this point in the history
* add flipper feature flags

* fix rubocop
  • Loading branch information
raul-gracia authored Sep 22, 2023
1 parent 5381713 commit 821f299
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ gem "phonelib"
gem "audited", "~> 5.3", ">= 5.3.3"
gem "config", "~> 4.2"
gem "devise", "~> 4.9"
gem "flipper"
gem "flipper-active_record"
gem "flipper-ui"
gem "httparty", "~> 0.21"
gem "invisible_captcha"
gem "omniauth-azure-activedirectory-v2"
Expand Down
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,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 @@ -169,6 +170,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 @@ -381,6 +394,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 @@ -463,6 +479,9 @@ DEPENDENCIES
dotenv-rails
factory_bot_rails
faker
flipper
flipper-active_record
flipper-ui
foreman
govuk-components (= 4.1.1)
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, %i[feature_key key value], unique: true
end

def self.down
drop_table :flipper_gates
drop_table :flipper_features
end
end
16 changes: 16 additions & 0 deletions db/schema.rb

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

0 comments on commit 821f299

Please sign in to comment.